difftreelog
CORE-325 Make test to check supprot ERC721Metadata
in: master
2 files changed
tests/src/eth/metadata.test.tsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {expect} from 'chai';18import {createCollectionExpectSuccess} from '../util/helpers';19import {collectionIdToAddress, createEthAccountWithBalance, GAS_ARGS, itWeb3} from './util/helpers';20import fungibleMetadataAbi from './fungibleMetadataAbi.json';2122describe('Common metadata', () => {23 itWeb3('Returns collection name', async ({api, web3}) => {24 const collection = await createCollectionExpectSuccess({25 name: 'token name',26 mode: {type: 'NFT'},27 });28 const caller = await createEthAccountWithBalance(api, web3);2930 const address = collectionIdToAddress(collection);31 const contract = new web3.eth.Contract(fungibleMetadataAbi as any, address, {from: caller, ...GAS_ARGS});32 const name = await contract.methods.name().call();3334 expect(name).to.equal('token name');35 });3637 itWeb3('Returns symbol name', async ({api, web3}) => {38 const collection = await createCollectionExpectSuccess({39 tokenPrefix: 'TOK',40 mode: {type: 'NFT'},41 });42 const caller = await createEthAccountWithBalance(api, web3);4344 const address = collectionIdToAddress(collection);45 const contract = new web3.eth.Contract(fungibleMetadataAbi as any, address, {from: caller, ...GAS_ARGS});46 const symbol = await contract.methods.symbol().call();4748 expect(symbol).to.equal('TOK');49 });50});5152describe('Fungible metadata', () => {53 itWeb3('Returns fungible decimals', async ({api, web3}) => {54 const collection = await createCollectionExpectSuccess({55 mode: {type: 'Fungible', decimalPoints: 6},56 });57 const caller = await createEthAccountWithBalance(api, web3);5859 const address = collectionIdToAddress(collection);60 const contract = new web3.eth.Contract(fungibleMetadataAbi as any, address, {from: caller, ...GAS_ARGS});61 const decimals = await contract.methods.decimals().call();6263 expect(+decimals).to.equal(6);64 });65});tests/src/util/helpers.tsdiffbeforeafterboth--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -268,6 +268,7 @@
name: string,
description: string,
tokenPrefix: string,
+ shemaVersion: string,
};
const defaultCreateCollectionParams: CreateCollectionParams = {
@@ -275,10 +276,11 @@
mode: {type: 'NFT'},
name: 'name',
tokenPrefix: 'prefix',
+ shemaVersion: 'ImageURL',
};
export async function createCollectionExpectSuccess(params: Partial<CreateCollectionParams> = {}): Promise<number> {
- const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};
+ const {name, description, mode, tokenPrefix, shemaVersion} = {...defaultCreateCollectionParams, ...params};
let collectionId = 0;
await usingApi(async (api) => {
@@ -297,7 +299,13 @@
modeprm = {refungible: null};
}
- const tx = api.tx.unique.createCollectionEx({name: strToUTF16(name), description: strToUTF16(description), tokenPrefix: strToUTF16(tokenPrefix), mode: modeprm as any});
+ const tx = api.tx.unique.createCollectionEx({
+ name: strToUTF16(name),
+ description: strToUTF16(description),
+ tokenPrefix: strToUTF16(tokenPrefix),
+ mode: modeprm as any,
+ schemaVersion: shemaVersion,
+ });
const events = await submitTransactionAsync(alicePrivateKey, tx);
const result = getCreateCollectionResult(events);