git.delta.rocks / unique-network / refs/commits / 7ac9c8c5f413

difftreelog

source

tests/src/eth/metadata.test.ts2.0 KiBsourcehistory
1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import { expect } from 'chai';7import { createCollectionExpectSuccess } from '../util/helpers';8import { collectionIdToAddress, createEthAccountWithBalance, GAS_ARGS, itWeb3 } from './util/helpers';9import fungibleMetadataAbi from './fungibleMetadataAbi.json';1011describe('Common metadata', () => {12  itWeb3('Returns collection name', async ({ api, web3 }) => {13    const collection = await createCollectionExpectSuccess({14      name: 'token name',15      mode: { type: 'NFT' },16    });17    const caller = await createEthAccountWithBalance(api, web3);1819    const address = collectionIdToAddress(collection);20    const contract = new web3.eth.Contract(fungibleMetadataAbi as any, address, { from: caller, ...GAS_ARGS });21    const name = await contract.methods.name().call();2223    expect(name).to.equal('token name');24  });2526  itWeb3('Returns symbol name', async ({ api, web3 }) => {27    const collection = await createCollectionExpectSuccess({28      tokenPrefix: 'TOK',29      mode: { type: 'NFT' },30    });31    const caller = await createEthAccountWithBalance(api, web3);3233    const address = collectionIdToAddress(collection);34    const contract = new web3.eth.Contract(fungibleMetadataAbi as any, address, { from: caller, ...GAS_ARGS });35    const symbol = await contract.methods.symbol().call();3637    expect(symbol).to.equal('TOK');38  });39});4041describe('Fungible metadata', () => {42  itWeb3('Returns fungible decimals', async ({ api, web3 }) => {43    const collection = await createCollectionExpectSuccess({44      mode: { type: 'Fungible', decimalPoints: 6 },45    });46    const caller = await createEthAccountWithBalance(api, web3);4748    const address = collectionIdToAddress(collection);49    const contract = new web3.eth.Contract(fungibleMetadataAbi as any, address, { from: caller, ...GAS_ARGS });50    const decimals = await contract.methods.decimals().call();5152    expect(+decimals).to.equal(6);53  });54});