difftreelog
tests(parallelization): fix createAccounts failing to catch up on dev node + evm events
in: master
6 files changed
tests/src/eth/contractSponsoring.test.tsdiffbeforeafterboth378 // Balance should be taken from flipper instead of caller378 // Balance should be taken from flipper instead of caller379 // FIXME the comment is wrong! What check should be here?379 // FIXME the comment is wrong! What check should be here?380 const balanceAfter = await helper.balance.getEthereum(flipper.options.address);380 const balanceAfter = await helper.balance.getEthereum(flipper.options.address);381 expect(balanceAfter).to.be.equals(originalFlipperBalance);381 expect(balanceAfter).to.be.equal(originalFlipperBalance);382 });382 });383383384 itEth('Sponsoring is set, an address that has UNQ can send a transaction and it works. User balance should not change', async ({helper}) => {384 itEth('Sponsoring is set, an address that has UNQ can send a transaction and it works. User balance should not change', async ({helper}) => {406 const sponsorBalanceAfter = await helper.balance.getSubstrate(await helper.address.ethToSubstrate(sponsor));406 const sponsorBalanceAfter = await helper.balance.getSubstrate(await helper.address.ethToSubstrate(sponsor));407 const callerBalanceAfter = await helper.balance.getSubstrate(await helper.address.ethToSubstrate(caller));407 const callerBalanceAfter = await helper.balance.getSubstrate(await helper.address.ethToSubstrate(caller));408 expect(sponsorBalanceAfter < sponsorBalanceBefore).to.be.true;408 expect(sponsorBalanceAfter < sponsorBalanceBefore).to.be.true;409 expect(callerBalanceAfter).to.be.equals(callerBalanceBefore);409 expect(callerBalanceAfter).to.be.equal(callerBalanceBefore);410 });410 });411411412 itEth('Sponsoring is limited, with setContractRateLimit. The limitation is working if transactions are sent more often, the sender pays the commission.', async ({helper}) => {412 itEth('Sponsoring is limited, with setContractRateLimit. The limitation is working if transactions are sent more often, the sender pays the commission.', async ({helper}) => {431431432 await flipper.methods.flip().send({from: caller});432 await flipper.methods.flip().send({from: caller});433 expect(await flipper.methods.getValue().call()).to.be.true;433 expect(await flipper.methods.getValue().call()).to.be.true;434 expect(await helper.balance.getEthereum(caller)).to.be.equals(originalCallerBalance);434 expect(await helper.balance.getEthereum(caller)).to.be.equal(originalCallerBalance);435435436 const newFlipperBalance = await helper.balance.getEthereum(sponsor);436 const newFlipperBalance = await helper.balance.getEthereum(sponsor);437 expect(newFlipperBalance).to.be.not.equals(originalFlipperBalance);437 expect(newFlipperBalance).to.be.not.equal(originalFlipperBalance);438438439 await flipper.methods.flip().send({from: caller});439 await flipper.methods.flip().send({from: caller});440 // todo:playgrounds fails rarely (expected 99893341659775672580n to equal 99912598679356033129n) (again, 99893341659775672580n)440 expect(await helper.balance.getEthereum(sponsor)).to.be.equal(newFlipperBalance);441 expect(await helper.balance.getEthereum(sponsor)).to.be.equal(newFlipperBalance);441 expect(await helper.balance.getEthereum(caller)).to.be.not.equals(originalCallerBalance);442 expect(await helper.balance.getEthereum(caller)).to.be.not.equal(originalCallerBalance);442 });443 });443444444 // TODO: Find a way to calculate default rate limit445 // TODO: Find a way to calculate default rate limit445 itEth('Default rate limit equals 7200', async ({helper}) => {446 itEth('Default rate limit equal 7200', async ({helper}) => {446 const owner = await helper.eth.createAccountWithBalance(donor);447 const owner = await helper.eth.createAccountWithBalance(donor);447 const helpers = helper.ethNativeContract.contractHelpers(owner);448 const helpers = helper.ethNativeContract.contractHelpers(owner);448 const flipper = await helper.eth.deployFlipper(owner);449 const flipper = await helper.eth.deployFlipper(owner);449450450 expect(await helpers.methods.sponsoringRateLimit(flipper.options.address).call()).to.be.equals('7200');451 expect(await helpers.methods.sponsoringRateLimit(flipper.options.address).call()).to.be.equal('7200');451 });452 });452});453});453454501 const helpers = helper.ethNativeContract.contractHelpers(owner);502 const helpers = helper.ethNativeContract.contractHelpers(owner);502 const flipper = await helper.eth.deployFlipper(owner);503 const flipper = await helper.eth.deployFlipper(owner);503504504 expect(await helpers.methods.sponsoringFeeLimit(flipper.options.address).call()).to.be.equals('115792089237316195423570985008687907853269984665640564039457584007913129639935');505 expect(await helpers.methods.sponsoringFeeLimit(flipper.options.address).call()).to.be.equal('115792089237316195423570985008687907853269984665640564039457584007913129639935');505 });506 });506507507 itEth('Set fee limit', async ({helper}) => {508 itEth('Set fee limit', async ({helper}) => {510 const flipper = await helper.eth.deployFlipper(owner);511 const flipper = await helper.eth.deployFlipper(owner);511512512 await helpers.methods.setSponsoringFeeLimit(flipper.options.address, 100).send();513 await helpers.methods.setSponsoringFeeLimit(flipper.options.address, 100).send();513 expect(await helpers.methods.sponsoringFeeLimit(flipper.options.address).call()).to.be.equals('100');514 expect(await helpers.methods.sponsoringFeeLimit(flipper.options.address).call()).to.be.equal('100');514 });515 });515516516 itEth('Negative test - set fee limit by non-owner', async ({helper}) => {517 itEth('Negative test - set fee limit by non-owner', async ({helper}) => {tests/src/eth/fungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/fungible.test.ts
+++ b/tests/src/eth/fungible.test.ts
@@ -294,9 +294,11 @@
contract.events.allEvents((_: any, event: any) => {
events.push(event);
});
+
await collection.approveTokens(alice, {Ethereum: receiver}, 100n);
+ if (events.length == 0) await helper.wait.newBlocks(1);
+ const event = events[0];
- const event = events[0];
expect(event.event).to.be.equal('Approval');
expect(event.address).to.be.equal(collectionAddress);
expect(event.returnValues.owner).to.be.equal(helper.address.substrateToEth(alice.address));
@@ -318,9 +320,11 @@
contract.events.allEvents((_: any, event: any) => {
events.push(event);
});
+
await collection.transferFrom(bob, {Substrate: alice.address}, {Ethereum: receiver}, 51n);
+ if (events.length == 0) await helper.wait.newBlocks(1);
+ let event = events[0];
- let event = events[0];
expect(event.event).to.be.equal('Transfer');
expect(event.address).to.be.equal(collectionAddress);
expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));
@@ -347,9 +351,11 @@
contract.events.allEvents((_: any, event: any) => {
events.push(event);
});
+
await collection.transfer(alice, {Ethereum:receiver}, 51n);
-
+ if (events.length == 0) await helper.wait.newBlocks(1);
const event = events[0];
+
expect(event.event).to.be.equal('Transfer');
expect(event.address).to.be.equal(collectionAddress);
expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));
tests/src/eth/nonFungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -385,9 +385,11 @@
contract.events.allEvents((_: any, event: any) => {
events.push(event);
});
+
const {tokenId} = await collection.mintToken(alice);
+ if (events.length == 0) await helper.wait.newBlocks(1);
+ const event = events[0];
- const event = events[0];
expect(event.event).to.be.equal('Transfer');
expect(event.address).to.be.equal(collectionAddress);
expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');
@@ -408,8 +410,9 @@
});
await token.burn(alice);
+ if (events.length == 0) await helper.wait.newBlocks(1);
+ const event = events[0];
- const event = events[0];
expect(event.event).to.be.equal('Transfer');
expect(event.address).to.be.equal(collectionAddress);
expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));
@@ -432,8 +435,9 @@
});
await token.approve(alice, {Ethereum: receiver});
+ if (events.length == 0) await helper.wait.newBlocks(1);
+ const event = events[0];
- const event = events[0];
expect(event.event).to.be.equal('Approval');
expect(event.address).to.be.equal(collectionAddress);
expect(event.returnValues.owner).to.be.equal(helper.address.substrateToEth(alice.address));
@@ -458,8 +462,9 @@
});
await token.transferFrom(bob, {Substrate: alice.address}, {Ethereum: receiver});
-
+ if (events.length == 0) await helper.wait.newBlocks(1);
const event = events[0];
+
expect(event.address).to.be.equal(collectionAddress);
expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));
expect(event.returnValues.to).to.be.equal(receiver);
@@ -481,8 +486,9 @@
});
await token.transfer(alice, {Ethereum: receiver});
-
+ if (events.length == 0) await helper.wait.newBlocks(1);
const event = events[0];
+
expect(event.address).to.be.equal(collectionAddress);
expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));
expect(event.returnValues.to).to.be.equal(receiver);
tests/src/eth/reFungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/reFungible.test.ts
+++ b/tests/src/eth/reFungible.test.ts
@@ -286,9 +286,11 @@
contract.events.allEvents((_: any, event: any) => {
events.push(event);
});
+
await tokenContract.methods.transfer(receiver, 1).send();
+ if (events.length == 0) await helper.wait.newBlocks(1);
+ const event = events[0];
- const event = events[0];
expect(event.address).to.equal(collectionAddress);
expect(event.returnValues.from).to.equal('0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF');
expect(event.returnValues.to).to.equal(receiver);
@@ -312,9 +314,11 @@
contract.events.allEvents((_: any, event: any) => {
events.push(event);
});
+
await tokenContract.methods.transfer(receiver, 1).send();
+ if (events.length == 0) await helper.wait.newBlocks(1);
+ const event = events[0];
- const event = events[0];
expect(event.address).to.equal(collectionAddress);
expect(event.returnValues.from).to.equal(caller);
expect(event.returnValues.to).to.equal('0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF');
tests/src/eth/reFungibleToken.test.tsdiffbeforeafterboth--- a/tests/src/eth/reFungibleToken.test.ts
+++ b/tests/src/eth/reFungibleToken.test.ts
@@ -311,6 +311,7 @@
});
await tokenContract.methods.burnFrom(caller, 1).send();
+ if (events.length == 0) await helper.wait.newBlocks(1);
const event = events[0];
expect(event.address).to.be.equal(collectionAddress);
expect(event.returnValues.from).to.be.equal('0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF');
@@ -399,9 +400,11 @@
contract.events.allEvents((_: any, event: any) => {
events.push(event);
});
- expect(await token.approve(alice, {Ethereum: receiver}, 100n)).to.be.true;
+ expect(await token.approve(alice, {Ethereum: receiver}, 100n)).to.be.true;
+ if (events.length == 0) await helper.wait.newBlocks(1);
const event = events[0];
+
expect(event.event).to.be.equal('Approval');
expect(event.address).to.be.equal(tokenAddress);
expect(event.returnValues.owner).to.be.equal(helper.address.substrateToEth(alice.address));
@@ -425,6 +428,7 @@
});
expect(await token.transferFrom(bob, {Substrate: alice.address}, {Ethereum: receiver}, 51n)).to.be.true;
+ if (events.length == 0) await helper.wait.newBlocks(1);
let event = events[0];
expect(event.event).to.be.equal('Transfer');
@@ -455,8 +459,9 @@
});
expect(await token.transfer(alice, {Ethereum: receiver}, 51n)).to.be.true;
+ if (events.length == 0) await helper.wait.newBlocks(1);
+ const event = events[0];
- const event = events[0];
expect(event.event).to.be.equal('Transfer');
expect(event.address).to.be.equal(tokenAddress);
expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));
tests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth--- a/tests/src/util/playgrounds/unique.dev.ts
+++ b/tests/src/util/playgrounds/unique.dev.ts
@@ -156,8 +156,9 @@
};
let accountsCreated = false;
- // checkBalances retry up to 5 blocks
- for (let index = 0; index < 5; index++) {
+ const maxBlocksChecked = await this.helper.arrange.isDevNode() ? 50 : 5;
+ // checkBalances retry up to 5-50 blocks
+ for (let index = 0; index < maxBlocksChecked; index++) {
accountsCreated = await checkBalances();
if(accountsCreated) break;
await wait.newBlocks(1);