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});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';
}