git.delta.rocks / unique-network / refs/commits / 8bbc7539fcb3

difftreelog

source

tests/src/eth/metadata.test.ts2.6 KiBsourcehistory
1// 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});