12import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, deployFlipper, ethBalanceViaSub, GAS_ARGS, itWeb3, recordEthFee} from './util/helpers';3import {expect} from 'chai';4import {createCollectionExpectSuccess, createItemExpectSuccess, UNIQUE} from '../util/helpers';5import nonFungibleAbi from './nonFungibleAbi.json';6import privateKey from '../substrate/privateKey';78describe('Contract calls', () => {9 itWeb3('Call of simple contract fee is less than 0.2 UNQ', async ({web3, api}) => {10 const deployer = await createEthAccountWithBalance(api, web3);11 const flipper = await deployFlipper(web3, deployer);1213 const cost = await recordEthFee(api, deployer, () => flipper.methods.flip().send({from: deployer}));14 expect(cost < BigInt(0.2 * Number(UNIQUE))).to.be.true;15 });1617 itWeb3('Balance transfer fee is less than 0.2 UNQ', async ({web3, api}) => {18 const userA = await createEthAccountWithBalance(api, web3);19 const userB = createEthAccount(web3);2021 const cost = await recordEthFee(api, userA, () => web3.eth.sendTransaction({from: userA, to: userB, value: '1000000', ...GAS_ARGS}));22 expect(cost - await ethBalanceViaSub(api, userB) < BigInt(0.2 * Number(UNIQUE))).to.be.true;23 });2425 itWeb3('NFT transfer is close to 0.15 UNQ', async ({web3, api}) => {26 const caller = await createEthAccountWithBalance(api, web3);27 const receiver = createEthAccount(web3);2829 const alice = privateKey('//Alice');30 const collection = await createCollectionExpectSuccess({31 mode: {type: 'NFT'},32 });33 const itemId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: caller});3435 const address = collectionIdToAddress(collection);36 const contract = new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS});3738 const cost = await recordEthFee(api, caller, () => contract.methods.transfer(receiver, itemId).send(caller));3940 const fee = Number(cost) / Number(UNIQUE);41 const expectedFee = 0.15;42 const tolerance = 0.002;4344 expect(Math.abs(fee - expectedFee) < tolerance).to.be.true;45 });46});