difftreelog
fix test name()
in: master
2 files changed
tests/src/eth/nativeFungible.test.tsdiffbeforeafterboth1// Copyright 2019-2023 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 {IKeyringPair} from '@polkadot/types/types';18import {expect, itEth, usingEthPlaygrounds} from './util';1920describe('NativeFungible: ERC20 calls', () => {21 let donor: IKeyringPair;2223 before(async function() {24 await usingEthPlaygrounds(async (helper, privateKey) => {25 donor = await privateKey({url: import.meta.url});26 // [alice] = await helper.arrange.createAccounts([30n], donor);27 });28 });2930 itEth('approve()', async ({helper}) => {31 const owner = await helper.eth.createAccountWithBalance(donor);32 const spender = helper.eth.createAccount();33 const collectionAddress = helper.ethAddress.fromCollectionId(0);34 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);3536 await expect(contract.methods.approve(spender, 100).call({from: owner})).to.be.rejectedWith('Approve not supported');37 });3839 itEth('balanceOf()', async ({helper}) => {40 const owner = await helper.eth.createAccountWithBalance(donor, 123n);41 const collectionAddress = helper.ethAddress.fromCollectionId(0);42 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);4344 const balance = await contract.methods.balanceOf(owner).call({from: owner});45 expect(balance).to.be.eq('123000000000000000000');46 });4748 itEth('decimals()', async ({helper}) => {49 const owner = await helper.eth.createAccountWithBalance(donor);50 const collectionAddress = helper.ethAddress.fromCollectionId(0);51 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);5253 const realDecimals = (await helper.chain.getChainProperties().tokenDecimals)[0].toString();54 const decimals = await contract.methods.decimals().call({from: owner});55 expect(decimals).to.be.eq(realDecimals);56 });5758 itEth('name()', async ({helper}) => {59 const owner = await helper.eth.createAccountWithBalance(donor);60 const collectionAddress = helper.ethAddress.fromCollectionId(0);61 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);6263 let realName;64 switch ((await helper.chain.getChainProperties().tokenSymbol)[0]) {65 case 'OPL': realName = 'opal'; break;66 case 'QTZ': realName = 'quartz'; break;67 case 'UNC': realName = 'unique'; break;68 default: realName = ''; break;69 }70 const name = await contract.methods.name().call({from: owner});71 expect(name).to.be.eq(realName);72 });7374 itEth('symbol()', async ({helper}) => {75 const owner = await helper.eth.createAccountWithBalance(donor);76 const collectionAddress = helper.ethAddress.fromCollectionId(0);77 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);7879 const realName = (await helper.chain.getChainProperties().tokenSymbol)[0];80 const name = await contract.methods.symbol().call({from: owner});81 expect(name).to.be.eq(realName);82 });8384 itEth('totalSupply()', async ({helper}) => {85 const owner = await helper.eth.createAccountWithBalance(donor);86 const collectionAddress = helper.ethAddress.fromCollectionId(0);87 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);8889 const totalSupplyEth = BigInt(await contract.methods.totalSupply().call({from: owner}));90 const totalSupplySub = await helper.balance.getTotalIssuance();91 expect(totalSupplyEth).to.be.eq(totalSupplySub);92 });9394 itEth('transfer()', async ({helper}) => {95 const owner = await helper.eth.createAccountWithBalance(donor);96 const receiver = await helper.eth.createAccountWithBalance(donor);97 const collectionAddress = helper.ethAddress.fromCollectionId(0);98 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);99100 const balanceOwnerBefore = await helper.balance.getEthereum(owner);101 const balanceReceiverBefore = await helper.balance.getEthereum(receiver);102103 await contract.methods.transfer(receiver, 50).send({from: owner});104105 const balanceOwnerAfter = await helper.balance.getEthereum(owner);106 const balanceReceiverAfter = await helper.balance.getEthereum(receiver);107108 expect(balanceOwnerBefore - 50n > balanceOwnerAfter).to.be.true;109 expect(balanceReceiverBefore === balanceReceiverAfter - 50n).to.be.true;110 });111112 itEth('transferFrom()', async ({helper}) => {113 const owner = await helper.eth.createAccountWithBalance(donor);114 const receiver = await helper.eth.createAccountWithBalance(donor);115 const collectionAddress = helper.ethAddress.fromCollectionId(0);116 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);117118 const balanceOwnerBefore = await helper.balance.getEthereum(owner);119 const balanceReceiverBefore = await helper.balance.getEthereum(receiver);120121 await contract.methods.transferFrom(owner, receiver, 50).send({from: owner});122123 const balanceOwnerAfter = await helper.balance.getEthereum(owner);124 const balanceReceiverAfter = await helper.balance.getEthereum(receiver);125126 expect(balanceOwnerBefore - 50n > balanceOwnerAfter).to.be.true;127 expect(balanceReceiverBefore === balanceReceiverAfter - 50n).to.be.true;128129 await expect(contract.methods.transferFrom(receiver, receiver, 50).call({from: owner})).to.be.rejectedWith('ApprovedValueTooLow');130 });131});132133describe('NativeFungible: ERC20UniqueExtensions calls', () => {134 let donor: IKeyringPair;135136 before(async function() {137 await usingEthPlaygrounds(async (helper, privateKey) => {138 donor = await privateKey({url: import.meta.url});139 // [alice] = await helper.arrange.createAccounts([30n], donor);140 });141 });142143 itEth('transferCross()', async ({helper}) => {144 const owner = await helper.eth.createAccountWithBalance(donor);145 const receiver = await helper.ethCrossAccount.createAccountWithBalance(donor);146 const collectionAddress = helper.ethAddress.fromCollectionId(0);147 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);148149 const balanceOwnerBefore = await helper.balance.getEthereum(owner);150 const balanceReceiverBefore = await helper.balance.getEthereum(receiver.eth);151152 await contract.methods.transferCross(receiver, 50).send({from: owner});153154 const balanceOwnerAfter = await helper.balance.getEthereum(owner);155 const balanceReceiverAfter = await helper.balance.getEthereum(receiver.eth);156157 expect(balanceOwnerBefore - 50n > balanceOwnerAfter).to.be.true;158 expect(balanceReceiverBefore === balanceReceiverAfter - 50n).to.be.true;159 });160161 itEth('transferFromCross()', async ({helper}) => {162 const owner = await helper.ethCrossAccount.createAccountWithBalance(donor);163 const receiver = await helper.ethCrossAccount.createAccountWithBalance(donor);164 const collectionAddress = helper.ethAddress.fromCollectionId(0);165 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner.eth);166167 const balanceOwnerBefore = await helper.balance.getEthereum(owner.eth);168 const balanceReceiverBefore = await helper.balance.getEthereum(receiver.eth);169170 await contract.methods.transferFromCross(owner, receiver, 50).send({from: owner.eth});171172 const balanceOwnerAfter = await helper.balance.getEthereum(owner.eth);173 const balanceReceiverAfter = await helper.balance.getEthereum(receiver.eth);174175 expect(balanceOwnerBefore - 50n > balanceOwnerAfter).to.be.true;176 expect(balanceReceiverBefore === balanceReceiverAfter - 50n).to.be.true;177178 await expect(contract.methods.transferFromCross(receiver, receiver, 50).call({from: owner.eth})).to.be.rejectedWith('no permission');179 });180});1// Copyright 2019-2023 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 {IKeyringPair} from '@polkadot/types/types';18import {expect, itEth, usingEthPlaygrounds} from './util';19import {UniqueHelper} from '../util/playgrounds/unique';2021describe('NativeFungible: ERC20 calls', () => {22 let donor: IKeyringPair;2324 before(async function() {25 await usingEthPlaygrounds(async (helper, privateKey) => {26 donor = await privateKey({url: import.meta.url});27 // [alice] = await helper.arrange.createAccounts([30n], donor);28 });29 });3031 itEth('approve()', async ({helper}) => {32 const owner = await helper.eth.createAccountWithBalance(donor);33 const spender = helper.eth.createAccount();34 const collectionAddress = helper.ethAddress.fromCollectionId(0);35 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);3637 await expect(contract.methods.approve(spender, 100).call({from: owner})).to.be.rejectedWith('Approve not supported');38 });3940 itEth('balanceOf()', async ({helper}) => {41 const owner = await helper.eth.createAccountWithBalance(donor, 123n);42 const collectionAddress = helper.ethAddress.fromCollectionId(0);43 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);4445 const balance = await contract.methods.balanceOf(owner).call({from: owner});46 expect(balance).to.be.eq('123000000000000000000');47 });4849 itEth('decimals()', async ({helper}) => {50 const owner = await helper.eth.createAccountWithBalance(donor);51 const collectionAddress = helper.ethAddress.fromCollectionId(0);52 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);5354 const realDecimals = (await helper.chain.getChainProperties().tokenDecimals)[0].toString();55 const decimals = await contract.methods.decimals().call({from: owner});56 expect(decimals).to.be.eq(realDecimals);57 });5859 itEth('name()', async ({helper}) => {60 const owner = await helper.eth.createAccountWithBalance(donor);61 const collectionAddress = helper.ethAddress.fromCollectionId(0);62 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);6364 const realName = await UniqueHelper.detectNetwork(helper.getApi());65 const name = await contract.methods.name().call({from: owner});66 expect(name).to.be.eq(realName);67 });6869 itEth('symbol()', async ({helper}) => {70 const owner = await helper.eth.createAccountWithBalance(donor);71 const collectionAddress = helper.ethAddress.fromCollectionId(0);72 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);7374 const realName = (await helper.chain.getChainProperties().tokenSymbol)[0];75 const name = await contract.methods.symbol().call({from: owner});76 expect(name).to.be.eq(realName);77 });7879 itEth('totalSupply()', async ({helper}) => {80 const owner = await helper.eth.createAccountWithBalance(donor);81 const collectionAddress = helper.ethAddress.fromCollectionId(0);82 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);8384 const totalSupplyEth = BigInt(await contract.methods.totalSupply().call({from: owner}));85 const totalSupplySub = await helper.balance.getTotalIssuance();86 expect(totalSupplyEth).to.be.eq(totalSupplySub);87 });8889 itEth('transfer()', async ({helper}) => {90 const owner = await helper.eth.createAccountWithBalance(donor);91 const receiver = await helper.eth.createAccountWithBalance(donor);92 const collectionAddress = helper.ethAddress.fromCollectionId(0);93 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);9495 const balanceOwnerBefore = await helper.balance.getEthereum(owner);96 const balanceReceiverBefore = await helper.balance.getEthereum(receiver);9798 await contract.methods.transfer(receiver, 50).send({from: owner});99100 const balanceOwnerAfter = await helper.balance.getEthereum(owner);101 const balanceReceiverAfter = await helper.balance.getEthereum(receiver);102103 expect(balanceOwnerBefore - 50n > balanceOwnerAfter).to.be.true;104 expect(balanceReceiverBefore === balanceReceiverAfter - 50n).to.be.true;105 });106107 itEth('transferFrom()', async ({helper}) => {108 const owner = await helper.eth.createAccountWithBalance(donor);109 const receiver = await helper.eth.createAccountWithBalance(donor);110 const collectionAddress = helper.ethAddress.fromCollectionId(0);111 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);112113 const balanceOwnerBefore = await helper.balance.getEthereum(owner);114 const balanceReceiverBefore = await helper.balance.getEthereum(receiver);115116 await contract.methods.transferFrom(owner, receiver, 50).send({from: owner});117118 const balanceOwnerAfter = await helper.balance.getEthereum(owner);119 const balanceReceiverAfter = await helper.balance.getEthereum(receiver);120121 expect(balanceOwnerBefore - 50n > balanceOwnerAfter).to.be.true;122 expect(balanceReceiverBefore === balanceReceiverAfter - 50n).to.be.true;123124 await expect(contract.methods.transferFrom(receiver, receiver, 50).call({from: owner})).to.be.rejectedWith('ApprovedValueTooLow');125 });126});127128describe('NativeFungible: ERC20UniqueExtensions calls', () => {129 let donor: IKeyringPair;130131 before(async function() {132 await usingEthPlaygrounds(async (helper, privateKey) => {133 donor = await privateKey({url: import.meta.url});134 // [alice] = await helper.arrange.createAccounts([30n], donor);135 });136 });137138 itEth('transferCross()', async ({helper}) => {139 const owner = await helper.eth.createAccountWithBalance(donor);140 const receiver = await helper.ethCrossAccount.createAccountWithBalance(donor);141 const collectionAddress = helper.ethAddress.fromCollectionId(0);142 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);143144 const balanceOwnerBefore = await helper.balance.getEthereum(owner);145 const balanceReceiverBefore = await helper.balance.getEthereum(receiver.eth);146147 await contract.methods.transferCross(receiver, 50).send({from: owner});148149 const balanceOwnerAfter = await helper.balance.getEthereum(owner);150 const balanceReceiverAfter = await helper.balance.getEthereum(receiver.eth);151152 expect(balanceOwnerBefore - 50n > balanceOwnerAfter).to.be.true;153 expect(balanceReceiverBefore === balanceReceiverAfter - 50n).to.be.true;154 });155156 itEth('transferFromCross()', async ({helper}) => {157 const owner = await helper.ethCrossAccount.createAccountWithBalance(donor);158 const receiver = await helper.ethCrossAccount.createAccountWithBalance(donor);159 const collectionAddress = helper.ethAddress.fromCollectionId(0);160 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner.eth);161162 const balanceOwnerBefore = await helper.balance.getEthereum(owner.eth);163 const balanceReceiverBefore = await helper.balance.getEthereum(receiver.eth);164165 await contract.methods.transferFromCross(owner, receiver, 50).send({from: owner.eth});166167 const balanceOwnerAfter = await helper.balance.getEthereum(owner.eth);168 const balanceReceiverAfter = await helper.balance.getEthereum(receiver.eth);169170 expect(balanceOwnerBefore - 50n > balanceOwnerAfter).to.be.true;171 expect(balanceReceiverBefore === balanceReceiverAfter - 50n).to.be.true;172173 await expect(contract.methods.transferFromCross(receiver, receiver, 50).call({from: owner.eth})).to.be.rejectedWith('no permission');174 });175});tests/src/util/playgrounds/unique.tsdiffbeforeafterboth--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -498,7 +498,7 @@
if (xcmChains.indexOf(spec.specName) > -1) return spec.specName;
- if (['quartz', 'unique'].indexOf(spec.specName) > -1) return spec.specName;
+ if (['quartz', 'unique', 'sapphire'].indexOf(spec.specName) > -1) return spec.specName;
return 'opal';
}