difftreelog
Merge pull request #693 from UniqueNetwork/tests/increase_timeout
in: master
Tests up
15 files changed
tests/src/eth/createFTCollection.seqtest.tsdiffbeforeafterbothno changes
tests/src/eth/createFTCollection.test.tsdiffbeforeafterboth31 });31 });32 });32 });3333 34 itEth('Create collection', async ({helper}) => {35 const owner = await helper.eth.createAccountWithBalance(donor);36 37 const name = 'CollectionEVM';38 const description = 'Some description';39 const prefix = 'token prefix';40 41 // todo:playgrounds this might fail when in async environment.42 const collectionCountBefore = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;4344 const {collectionId} = await helper.eth.createFungibleCollection(owner, name, DECIMALS, description, prefix);45 46 const collectionCountAfter = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;47 const data = (await helper.ft.getData(collectionId))!;4849 expect(collectionCountAfter - collectionCountBefore).to.be.eq(1);50 expect(collectionId).to.be.eq(collectionCountAfter);51 expect(data.name).to.be.eq(name);52 expect(data.description).to.be.eq(description);53 expect(data.raw.tokenPrefix).to.be.eq(prefix);54 expect(data.raw.mode).to.be.deep.eq({Fungible: DECIMALS.toString()});55 });5657 // todo:playgrounds this test will fail when in async environment.58 itEth('Check collection address exist', async ({helper}) => {59 const owner = await helper.eth.createAccountWithBalance(donor);6061 const expectedCollectionId = +(await helper.callRpc('api.rpc.unique.collectionStats')).created + 1;62 const expectedCollectionAddress = helper.ethAddress.fromCollectionId(expectedCollectionId);63 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);6465 expect(await collectionHelpers.methods66 .isCollectionExist(expectedCollectionAddress)67 .call()).to.be.false;6869 70 await helper.eth.createFungibleCollection(owner, 'A', DECIMALS, 'A', 'A');7172 73 expect(await collectionHelpers.methods74 .isCollectionExist(expectedCollectionAddress)75 .call()).to.be.true;76 });77 78 itEth('Set sponsorship', async ({helper}) => {34 itEth('Set sponsorship', async ({helper}) => {79 const owner = await helper.eth.createAccountWithBalance(donor);35 const owner = await helper.eth.createAccountWithBalance(donor);tests/src/eth/createNFTCollection.seqtest.tsdiffbeforeafterbothno changes
tests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth28 });28 });29 });29 });3031 itEth('Create collection', async ({helper}) => {32 const owner = await helper.eth.createAccountWithBalance(donor);3334 const name = 'CollectionEVM';35 const description = 'Some description';36 const prefix = 'token prefix';3738 // todo:playgrounds this might fail when in async environment.39 const collectionCountBefore = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;40 const {collectionId, collectionAddress, events} = await helper.eth.createNFTCollection(owner, name, description, prefix);41 42 expect(events).to.be.deep.equal([43 {44 address: '0x6C4E9fE1AE37a41E93CEE429e8E1881aBdcbb54F',45 event: 'CollectionCreated',46 args: {47 owner: owner,48 collectionId: collectionAddress,49 },50 },51 ]);52 53 const collectionCountAfter = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;5455 const collection = helper.nft.getCollectionObject(collectionId);56 const data = (await collection.getData())!;5758 expect(collectionCountAfter - collectionCountBefore).to.be.eq(1);59 expect(collectionId).to.be.eq(collectionCountAfter);60 expect(data.name).to.be.eq(name);61 expect(data.description).to.be.eq(description);62 expect(data.raw.tokenPrefix).to.be.eq(prefix);63 expect(data.raw.mode).to.be.eq('NFT');6465 const options = await collection.getOptions();6667 expect(options.tokenPropertyPermissions).to.be.empty;68 });693070 itEth('Create collection with properties', async ({helper}) => {31 itEth('Create collection with properties', async ({helper}) => {71 const owner = await helper.eth.createAccountWithBalance(donor);32 const owner = await helper.eth.createAccountWithBalance(donor);109 ]);70 ]);110 });71 });111112 // this test will occasionally fail when in async environment.113 itEth.skip('Check collection address exist', async ({helper}) => {114 const owner = await helper.eth.createAccountWithBalance(donor);115116 const expectedCollectionId = +(await helper.callRpc('api.rpc.unique.collectionStats')).created + 1;117 const expectedCollectionAddress = helper.ethAddress.fromCollectionId(expectedCollectionId);118 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);119120 expect(await collectionHelpers.methods121 .isCollectionExist(expectedCollectionAddress)122 .call()).to.be.false;123124 await collectionHelpers.methods125 .createNFTCollection('A', 'A', 'A')126 .send({value: Number(2n * helper.balance.getOneTokenNominal())});127128 expect(await collectionHelpers.methods129 .isCollectionExist(expectedCollectionAddress)130 .call()).to.be.true;131 });13272133 itEth('Set sponsorship', async ({helper}) => {73 itEth('Set sponsorship', async ({helper}) => {134 const owner = await helper.eth.createAccountWithBalance(donor);74 const owner = await helper.eth.createAccountWithBalance(donor);tests/src/eth/fungible.test.tsdiffbeforeafterboth52describe('Fungible: Plain calls', () => {52describe('Fungible: Plain calls', () => {53 let donor: IKeyringPair;53 let donor: IKeyringPair;54 let alice: IKeyringPair;54 let alice: IKeyringPair;55 let owner: IKeyringPair;555656 before(async function() {57 before(async function() {57 await usingEthPlaygrounds(async (helper, privateKey) => {58 await usingEthPlaygrounds(async (helper, privateKey) => {58 donor = await privateKey({filename: __filename});59 donor = await privateKey({filename: __filename});59 [alice] = await helper.arrange.createAccounts([20n], donor);60 [alice, owner] = await helper.arrange.createAccounts([20n, 20n], donor);60 });61 });61 });62 });6263148 }149 }149 });150 });150151151 itEth('Can perform burnFromCross()', async ({helper, privateKey}) => {152 itEth('Can perform burnFromCross()', async ({helper}) => {152 const owner = await privateKey('//Alice');153 const sender = await helper.eth.createAccountWithBalance(donor);153 const sender = await helper.eth.createAccountWithBalance(donor, 100n);154154155 const collection = await helper.ft.mintCollection(owner, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);155 const collection = await helper.ft.mintCollection(owner, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);156156261 });261 });262262263 itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {263 itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {264 const owner = await privateKey('//Alice');265 const sender = await helper.eth.createAccountWithBalance(donor);264 const sender = await helper.eth.createAccountWithBalance(donor, 100n);266265267 const collection = await helper.ft.mintCollection(owner, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);266 const collection = await helper.ft.mintCollection(owner, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);268267365describe('Fungible: Substrate calls', () => {364describe('Fungible: Substrate calls', () => {366 let donor: IKeyringPair;365 let donor: IKeyringPair;367 let alice: IKeyringPair;366 let alice: IKeyringPair;367 let owner: IKeyringPair;368368369 before(async function() {369 before(async function() {370 await usingEthPlaygrounds(async (helper, privateKey) => {370 await usingEthPlaygrounds(async (helper, privateKey) => {371 donor = await privateKey({filename: __filename});371 donor = await privateKey({filename: __filename});372 [alice] = await helper.arrange.createAccounts([20n], donor);372 [alice, owner] = await helper.arrange.createAccounts([20n, 20n], donor);373 });373 });374 });374 });375375455 });455 });456456457 itEth('Events emitted for transferFromCross()', async ({helper, privateKey}) => {457 itEth('Events emitted for transferFromCross()', async ({helper, privateKey}) => {458 const owner = await privateKey('//Alice');459 const sender = await helper.eth.createAccountWithBalance(donor);458 const sender = await helper.eth.createAccountWithBalance(donor, 100n);460459461 const collection = await helper.ft.mintCollection(owner, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);460 const collection = await helper.ft.mintCollection(owner, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);462461tests/src/eth/migration.seqtest.tsdiffbeforeafterbothno changes
tests/src/eth/migration.test.tsdiffbeforeafterbothno changes
tests/src/eth/nonFungible.test.tsdiffbeforeafterboth138138139describe('NFT: Plain calls', () => {139describe('NFT: Plain calls', () => {140 let donor: IKeyringPair;140 let donor: IKeyringPair;141 let alice: IKeyringPair;141 let minter: IKeyringPair;142 let bob: IKeyringPair;143 let charlie: IKeyringPair;142144143 before(async function() {145 before(async function() {144 await usingEthPlaygrounds(async (helper, privateKey) => {146 await usingEthPlaygrounds(async (helper, privateKey) => {145 donor = await privateKey({filename: __filename});147 donor = await privateKey({filename: __filename});146 [alice] = await helper.arrange.createAccounts([10n], donor);148 [minter, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);147 });149 });148 });150 });149151176 const caller = await helper.eth.createAccountWithBalance(donor);178 const caller = await helper.eth.createAccountWithBalance(donor);177 const receiver = helper.eth.createAccount();179 const receiver = helper.eth.createAccount();178180179 const collection = await helper.nft.mintCollection(alice);181 const collection = await helper.nft.mintCollection(minter);180 await collection.addAdmin(alice, {Ethereum: caller});182 await collection.addAdmin(minter, {Ethereum: caller});181183182 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);184 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);183 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', caller);185 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', caller);208 itEth('Can perform burn()', async ({helper}) => {210 itEth('Can perform burn()', async ({helper}) => {209 const caller = await helper.eth.createAccountWithBalance(donor);211 const caller = await helper.eth.createAccountWithBalance(donor);210212211 const collection = await helper.nft.mintCollection(alice, {});213 const collection = await helper.nft.mintCollection(minter, {});212 const {tokenId} = await collection.mintToken(alice, {Ethereum: caller});214 const {tokenId} = await collection.mintToken(minter, {Ethereum: caller});213215214 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);216 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);215 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', caller);217 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', caller);229 const owner = await helper.eth.createAccountWithBalance(donor);231 const owner = await helper.eth.createAccountWithBalance(donor);230 const spender = helper.eth.createAccount();232 const spender = helper.eth.createAccount();231233232 const collection = await helper.nft.mintCollection(alice, {});234 const collection = await helper.nft.mintCollection(minter, {});233 const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});235 const {tokenId} = await collection.mintToken(minter, {Ethereum: owner});234236235 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);237 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);236 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);238 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);246 }248 }247 });249 });248250249 itEth('Can perform burnFromCross()', async ({helper, privateKey}) => {251 itEth('Can perform burnFromCross()', async ({helper}) => {250 const minter = await privateKey('//Alice');251 const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});252 const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});252253253 const owner = await privateKey('//Bob');254 const owner = bob;254 const spender = await helper.eth.createAccountWithBalance(donor);255 const spender = await helper.eth.createAccountWithBalance(donor, 100n);255256256 const token = await collection.mintToken(minter, {Substrate: owner.address});257 const token = await collection.mintToken(minter, {Substrate: owner.address});257258276 }277 }277 });278 });278279279 itEth('Can perform approveCross()', async ({helper, privateKey}) => {280 itEth('Can perform approveCross()', async ({helper}) => {280 const minter = await privateKey('//Alice');281 const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});281 const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});282282283 const owner = await helper.eth.createAccountWithBalance(donor);283 const owner = await helper.eth.createAccountWithBalance(donor, 100n);284 const receiver = await privateKey('//Charlie');284 const receiver = charlie;285285286 const token = await collection.mintToken(minter, {Ethereum: owner});286 const token = await collection.mintToken(minter, {Ethereum: owner});287287309 const spender = await helper.eth.createAccountWithBalance(donor);309 const spender = await helper.eth.createAccountWithBalance(donor);310 const receiver = helper.eth.createAccount();310 const receiver = helper.eth.createAccount();311311312 const collection = await helper.nft.mintCollection(alice, {});312 const collection = await helper.nft.mintCollection(minter, {});313 const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});313 const {tokenId} = await collection.mintToken(minter, {Ethereum: owner});314314315 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);315 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);316 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);316 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);373 });373 });374374375 itEth('Can perform transfer()', async ({helper}) => {375 itEth('Can perform transfer()', async ({helper}) => {376 const collection = await helper.nft.mintCollection(alice, {});376 const collection = await helper.nft.mintCollection(minter, {});377 const owner = await helper.eth.createAccountWithBalance(donor);377 const owner = await helper.eth.createAccountWithBalance(donor);378 const receiver = helper.eth.createAccount();378 const receiver = helper.eth.createAccount();379379380 const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});380 const {tokenId} = await collection.mintToken(minter, {Ethereum: owner});381381382 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);382 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);383 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);383 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);407describe('NFT: Fees', () => {407describe('NFT: Fees', () => {408 let donor: IKeyringPair;408 let donor: IKeyringPair;409 let alice: IKeyringPair;409 let alice: IKeyringPair;410 let bob: IKeyringPair;411 let charlie: IKeyringPair;410412411 before(async function() {413 before(async function() {412 await usingEthPlaygrounds(async (helper, privateKey) => {414 await usingEthPlaygrounds(async (helper, privateKey) => {413 donor = await privateKey({filename: __filename});415 donor = await privateKey({filename: __filename});414 [alice] = await helper.arrange.createAccounts([10n], donor);416 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);415 });417 });416 });418 });417419443 expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));445 expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));444 });446 });447448 itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {449 const collectionMinter = alice;450 const owner = bob;451 const receiver = charlie;452 const collection = await helper.nft.mintCollection(collectionMinter, {name: 'A', description: 'B', tokenPrefix: 'C'});453454 const spender = await helper.eth.createAccountWithBalance(donor, 100n);455456 const token = await collection.mintToken(collectionMinter, {Substrate: owner.address});457458 const address = helper.ethAddress.fromCollectionId(collection.collectionId);459 const contract = helper.ethNativeContract.collection(address, 'nft');460461 await token.approve(owner, {Ethereum: spender});462463 {464 const ownerCross = helper.ethCrossAccount.fromKeyringPair(owner);465 const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);466 const result = await contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender});467 const event = result.events.Transfer;468 expect(event).to.be.like({469 address: helper.ethAddress.fromCollectionId(collection.collectionId),470 event: 'Transfer',471 returnValues: {472 from: helper.address.substrateToEth(owner.address),473 to: helper.address.substrateToEth(receiver.address),474 tokenId: token.tokenId.toString(),475 },476 });477 }478479 expect(await token.getOwner()).to.be.like({Substrate: receiver.address});480 });445481446 itEth('transfer() call fee is less than 0.2UNQ', async ({helper}) => {482 itEth('transfer() call fee is less than 0.2UNQ', async ({helper}) => {447 const owner = await helper.eth.createAccountWithBalance(donor);483 const owner = await helper.eth.createAccountWithBalance(donor);tests/src/eth/reFungible.test.tsdiffbeforeafterboth104104105describe('Refungible: Plain calls', () => {105describe('Refungible: Plain calls', () => {106 let donor: IKeyringPair;106 let donor: IKeyringPair;107 let minter: IKeyringPair;108 let bob: IKeyringPair;109 let charlie: IKeyringPair;107110108 before(async function() {111 before(async function() {109 await usingEthPlaygrounds(async (helper, privateKey) => {112 await usingEthPlaygrounds(async (helper, privateKey) => {110 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);113 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);111114112 donor = await privateKey({filename: __filename});115 donor = await privateKey({filename: __filename});116 [minter, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);113 });117 });114 });118 });115119227 }231 }228 });232 });229233230 itEth('Can perform burnFrom()', async ({helper, privateKey}) => {234 itEth('Can perform burnFrom()', async ({helper}) => {231 const minter = await privateKey('//Alice');232 const collection = await helper.rft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});235 const collection = await helper.rft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});233236234 const owner = await helper.eth.createAccountWithBalance(donor);237 const owner = await helper.eth.createAccountWithBalance(donor, 100n);235 const spender = await helper.eth.createAccountWithBalance(donor);238 const spender = await helper.eth.createAccountWithBalance(donor, 100n);236239237 const token = await collection.mintToken(minter, 100n, {Ethereum: owner});240 const token = await collection.mintToken(minter, 100n, {Ethereum: owner});238241261 expect(await collection.getTokenBalance(token.tokenId, {Ethereum: owner})).to.be.eq(0n);264 expect(await collection.getTokenBalance(token.tokenId, {Ethereum: owner})).to.be.eq(0n);262 });265 });263266264 itEth('Can perform burnFromCross()', async ({helper, privateKey}) => {267 itEth('Can perform burnFromCross()', async ({helper}) => {265 const minter = await privateKey('//Alice');266 const collection = await helper.rft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});268 const collection = await helper.rft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});267269 268 const owner = await privateKey('//Bob');270 const owner = bob;269 const spender = await helper.eth.createAccountWithBalance(donor);271 const spender = await helper.eth.createAccountWithBalance(donor, 100n);270272271 const token = await collection.mintToken(minter, 100n, {Substrate: owner.address});273 const token = await collection.mintToken(minter, 100n, {Substrate: owner.address});272274294 expect(await collection.getTokenBalance(token.tokenId, {Substrate: owner.address})).to.be.eq(0n);296 expect(await collection.getTokenBalance(token.tokenId, {Substrate: owner.address})).to.be.eq(0n);295 });297 });296298297 itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {299 itEth('Can perform transferFromCross()', async ({helper}) => {298 const minter = await privateKey('//Alice');299 const collection = await helper.rft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});300 const collection = await helper.rft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});300301301 const owner = await privateKey('//Bob');302 const owner = bob;302 const spender = await helper.eth.createAccountWithBalance(donor);303 const spender = await helper.eth.createAccountWithBalance(donor, 100n);303 const receiver = await privateKey('//Charlie');304 const receiver = charlie;304305305 const token = await collection.mintToken(minter, 100n, {Substrate: owner.address});306 const token = await collection.mintToken(minter, 100n, {Substrate: owner.address});306307tests/src/eth/scheduling.test.tsdiffbeforeafterboth27 });27 });282829 itEth.ifWithPallets('Successfully schedules and periodically executes an EVM contract', [Pallets.Scheduler], async ({helper, privateKey}) => {29 itEth.ifWithPallets('Successfully schedules and periodically executes an EVM contract', [Pallets.Scheduler], async ({helper, privateKey}) => {30 const alice = await privateKey('//Alice');30 const donor = await privateKey({filename: __filename});31 const [alice] = await helper.arrange.createAccounts([1000n], donor);313232 const scheduledId = await helper.arrange.makeScheduledId();33 const scheduledId = await helper.arrange.makeScheduledId();3334tests/src/inflation.seqtest.tsdiffbeforeafterbothno changes
tests/src/inflation.test.tsdiffbeforeafterbothno changes
tests/src/scheduler.seqtest.tsdiffbeforeafterbothno changes
tests/src/scheduler.test.tsdiffbeforeafterbothno changes
tests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth422 return promise;422 return promise;423 }423 }424424425 async forParachainBlockNumber(blockNumber: bigint, timeout?: number) {425 async forParachainBlockNumber(blockNumber: bigint | number, timeout?: number) {426 timeout = timeout ?? 300_000;426 timeout = timeout ?? 30 * 60 * 1000;427 // eslint-disable-next-line no-async-promise-executor427 // eslint-disable-next-line no-async-promise-executor428 const promise = new Promise<void>(async (resolve) => {428 const promise = new Promise<void>(async (resolve) => {429 const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads((data: any) => {429 const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads((data: any) => {437 return promise;437 return promise;438 }438 }439 439 440 async forRelayBlockNumber(blockNumber: bigint, timeout?: number) {440 async forRelayBlockNumber(blockNumber: bigint | number, timeout?: number) {441 timeout = timeout ?? 300_000;441 timeout = timeout ?? 30 * 60 * 1000;442 // eslint-disable-next-line no-async-promise-executor442 // eslint-disable-next-line no-async-promise-executor443 const promise = new Promise<void>(async (resolve) => {443 const promise = new Promise<void>(async (resolve) => {444 const unsubscribe = await this.helper.getApi().query.parachainSystem.validationData((data: any) => {444 const unsubscribe = await this.helper.getApi().query.parachainSystem.validationData((data: any) => {