git.delta.rocks / unique-network / refs/commits / 5721d4c0d16e

difftreelog

Fix tests for quartz and unique runtimes and skip scheduling

Maksandre2022-10-05parent: #878b12b.patch.diff
in: master

2 files changed

modifiedtests/src/eth/collectionSponsoring.test.tsdiffbeforeafterboth
--- a/tests/src/eth/collectionSponsoring.test.ts
+++ b/tests/src/eth/collectionSponsoring.test.ts
@@ -93,7 +93,7 @@
     expect(sponsorTuple.field_0).to.be.eq('0x0000000000000000000000000000000000000000');
   });
 
-  itEth('Sponsoring collection from evm address via access list', async ({helper, privateKey}) => {
+  itEth('Sponsoring collection from evm address via access list', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
     const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);
 
@@ -106,13 +106,12 @@
 
     result = await collectionEvm.methods.setCollectionSponsor(sponsor).send({from: owner});
     let collectionData = (await collection.getData())!;
-    const ss58Format = helper.chain.getChainProperties().ss58Format;
-    expect(collectionData.raw.sponsorship.Unconfirmed).to.be.eq(helper.address.ethToSubstrate(sponsor));
+    expect(collectionData.raw.sponsorship.Unconfirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));
     await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');
 
     await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});
     collectionData = (await collection.getData())!;
-    expect(collectionData.raw.sponsorship.Confirmed).to.be.eq(helper.address.ethToSubstrate(sponsor));
+    expect(collectionData.raw.sponsorship.Confirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));
 
     const user = helper.eth.createAccount();
     const nextTokenId = await collectionEvm.methods.nextTokenId().call();
@@ -220,7 +219,7 @@
   //   }
   // });
 
-  itEth('Check that transaction via EVM spend money from sponsor address', async ({helper, privateKey}) => {
+  itEth('Check that transaction via EVM spend money from sponsor address', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
     const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);
 
@@ -233,13 +232,13 @@
 
     result = await collectionEvm.methods.setCollectionSponsor(sponsor).send();
     let collectionData = (await collection.getData())!;
-    expect(collectionData.raw.sponsorship.Unconfirmed).to.be.eq(helper.address.ethToSubstrate(sponsor));
+    expect(collectionData.raw.sponsorship.Unconfirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));
     await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');
 
     const sponsorCollection = helper.ethNativeContract.collection(collectionIdAddress, 'nft', sponsor);
     await sponsorCollection.methods.confirmCollectionSponsorship().send();
     collectionData = (await collection.getData())!;
-    expect(collectionData.raw.sponsorship.Confirmed).to.be.eq(helper.address.ethToSubstrate(sponsor));
+    expect(collectionData.raw.sponsorship.Confirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));
 
     const user = helper.eth.createAccount();
     await collectionEvm.methods.addCollectionAdmin(user).send();
@@ -272,9 +271,9 @@
     ]);
     expect(await userCollectionEvm.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');
   
-    const ownerBalanceAfter = await helper.balance.getSubstrate(await helper.address.ethToSubstrate(owner));
+    const ownerBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));
     expect(ownerBalanceAfter).to.be.eq(ownerBalanceBefore);
-    const sponsorBalanceAfter = await helper.balance.getSubstrate(await helper.address.ethToSubstrate(sponsor));
+    const sponsorBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsor));
     expect(sponsorBalanceAfter < sponsorBalanceBefore).to.be.true;
   });
 });
modifiedtests/src/eth/scheduling.test.tsdiffbeforeafterboth
before · tests/src/eth/scheduling.test.ts
1// Copyright 2019-2022 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 {expect} from 'chai';18import {createEthAccountWithBalance, deployFlipper, GAS_ARGS, itWeb3, subToEth, transferBalanceToEth} from './util/helpers';19import {scheduleExpectSuccess, waitNewBlocks, requirePallets, Pallets} from '../util/helpers';2021describe('Scheduing EVM smart contracts', () => {22  before(async function() {23    await requirePallets(this, [Pallets.Scheduler]);24  });2526  itWeb3('Successfully schedules and periodically executes an EVM contract', async ({api, web3, privateKeyWrapper}) => {27    const deployer = await createEthAccountWithBalance(api, web3, privateKeyWrapper);28    const flipper = await deployFlipper(web3, deployer);29    const initialValue = await flipper.methods.getValue().call();30    const alice = privateKeyWrapper('//Alice');31    await transferBalanceToEth(api, alice, subToEth(alice.address));3233    {34      const tx = api.tx.evm.call(35        subToEth(alice.address),36        flipper.options.address,37        flipper.methods.flip().encodeABI(),38        '0',39        GAS_ARGS.gas,40        await web3.eth.getGasPrice(),41        null,42        null,43        [],44      );45      const waitForBlocks = 4;46      const periodBlocks = 2;4748      await scheduleExpectSuccess(tx, alice, waitForBlocks, '0x' + '0'.repeat(32), periodBlocks, 2);49      expect(await flipper.methods.getValue().call()).to.be.equal(initialValue);50      51      await waitNewBlocks(waitForBlocks - 1);52      expect(await flipper.methods.getValue().call()).to.be.not.equal(initialValue);53  54      await waitNewBlocks(periodBlocks);55      expect(await flipper.methods.getValue().call()).to.be.equal(initialValue);56    }57  });58});
after · tests/src/eth/scheduling.test.ts
1// Copyright 2019-2022 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 {expect} from 'chai';18import {createEthAccountWithBalance, deployFlipper, GAS_ARGS, itWeb3, subToEth, transferBalanceToEth} from './util/helpers';19import {scheduleExpectSuccess, waitNewBlocks, requirePallets, Pallets} from '../util/helpers';2021// TODO mrshiposha update this test in #58122describe.skip('Scheduing EVM smart contracts', () => {23  before(async function() {24    await requirePallets(this, [Pallets.Scheduler]);25  });2627  itWeb3('Successfully schedules and periodically executes an EVM contract', async ({api, web3, privateKeyWrapper}) => {28    const deployer = await createEthAccountWithBalance(api, web3, privateKeyWrapper);29    const flipper = await deployFlipper(web3, deployer);30    const initialValue = await flipper.methods.getValue().call();31    const alice = privateKeyWrapper('//Alice');32    await transferBalanceToEth(api, alice, subToEth(alice.address));3334    {35      const tx = api.tx.evm.call(36        subToEth(alice.address),37        flipper.options.address,38        flipper.methods.flip().encodeABI(),39        '0',40        GAS_ARGS.gas,41        await web3.eth.getGasPrice(),42        null,43        null,44        [],45      );46      const waitForBlocks = 4;47      const periodBlocks = 2;4849      await scheduleExpectSuccess(tx, alice, waitForBlocks, '0x' + '0'.repeat(32), periodBlocks, 2);50      expect(await flipper.methods.getValue().call()).to.be.equal(initialValue);51      52      await waitNewBlocks(waitForBlocks - 1);53      expect(await flipper.methods.getValue().call()).to.be.not.equal(initialValue);54  55      await waitNewBlocks(periodBlocks);56      expect(await flipper.methods.getValue().call()).to.be.equal(initialValue);57    }58  });59});