git.delta.rocks / unique-network / refs/commits / 313d9317ef02

difftreelog

test fix integration

Yaroslav Bolyukin2023-05-31parent: #8545aff.patch.diff
in: master

6 files changed

modifiedtests/src/eth/contractSponsoring.test.tsdiffbeforeafterboth
--- a/tests/src/eth/contractSponsoring.test.ts
+++ b/tests/src/eth/contractSponsoring.test.ts
@@ -516,7 +516,7 @@
     const owner = await helper.eth.createAccountWithBalance(donor);
     const sponsor = await helper.eth.createAccountWithBalance(donor);
     const user = await helper.eth.createAccountWithBalance(donor);
-    const helpers = await helper.ethNativeContract.contractHelpers(owner);
+    const helpers = helper.ethNativeContract.contractHelpers(owner);
 
     const testContract = await deployTestContract(helper, owner);
 
@@ -531,10 +531,10 @@
     await helpers.methods.setSponsoringFeeLimit(testContract.options.address, 2_000_000n * gasPrice).send();
 
     const originalUserBalance = await helper.balance.getEthereum(user);
-    await testContract.methods.test(100).send({from: user, gas: 2_000_000});
+    await testContract.methods.test(100).send({from: user, gas: 2_000_000, maxFeePerGas: gasPrice.toString()});
     expect(await helper.balance.getEthereum(user)).to.be.equal(originalUserBalance);
 
-    await testContract.methods.test(100).send({from: user, gas: 2_100_000});
+    await testContract.methods.test(100).send({from: user, gas: 2_100_000, maxFeePerGas: gasPrice.toString()});
     expect(await helper.balance.getEthereum(user)).to.not.be.equal(originalUserBalance);
   });
 
modifiedtests/src/eth/ethFeesAreCorrect.test.tsdiffbeforeafterboth
--- a/tests/src/eth/ethFeesAreCorrect.test.ts
+++ b/tests/src/eth/ethFeesAreCorrect.test.ts
@@ -41,10 +41,10 @@
     const {tokenId: tokenB} = await collection.mintToken(minter, {Ethereum: aliceEth});
 
     const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
-    const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
+    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
 
     const balanceBeforeWeb3Transfer = await helper.balance.getEthereum(owner);
-    await contract.methods.transfer(receiver, tokenA).send({from: owner});
+    await contract.methods.transfer(receiver, tokenA).send({from: owner, maxFeePerGas: (await helper.eth.getGasPrice()).toString()});
     const balanceAfterWeb3Transfer = await helper.balance.getEthereum(owner);
     const web3Diff = balanceBeforeWeb3Transfer - balanceAfterWeb3Transfer;
 
modifiedtests/src/eth/reFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/reFungible.test.ts
+++ b/tests/src/eth/reFungible.test.ts
@@ -674,7 +674,7 @@
       requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
 
       donor = await privateKey({url: import.meta.url});
-      [alice] = await helper.arrange.createAccounts([20n], donor);
+      [alice] = await helper.arrange.createAccounts([1000n], donor);
     });
   });
 
@@ -699,7 +699,7 @@
       },
     );
 
-    const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'rft', caller);
+    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'rft', caller);
     const name = await contract.methods.name().call();
     expect(name).to.equal('Leviathan');
   });
modifiedtests/src/maintenance.seqtest.tsdiffbeforeafterboth
--- a/tests/src/maintenance.seqtest.ts
+++ b/tests/src/maintenance.seqtest.ts
@@ -342,19 +342,19 @@
     itSub('Does not allow preimage execution with non-root', async ({helper}) => {
       await expect(helper.executeExtrinsic(bob, 'api.tx.maintenance.executePreimage', [
         preimageHashes[0], {refTime: 10000000000, proofSize: 10000},
-      ])).to.be.rejectedWith(/BadOrigin/);
+      ])).to.be.rejectedWith(/^Misc: BadOrigin$/);
     });
 
     itSub('Does not allow execution of non-existent preimages', async ({helper}) => {
       await expect(helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.executePreimage', [
         '0x1010101010101010101010101010101010101010101010101010101010101010', {refTime: 10000000000, proofSize: 10000},
-      ])).to.be.rejectedWith(/Unavailable/);
+      ])).to.be.rejectedWith(/^Misc: Unavailable$/);
     });
 
     itSub('Does not allow preimage execution with less than minimum weights', async ({helper}) => {
       await expect(helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.executePreimage', [
         preimageHashes[0], {refTime: 1000, proofSize: 100},
-      ])).to.be.rejectedWith(/Exhausted/);
+      ])).to.be.rejectedWith(/^Misc: Exhausted$/);
     });
 
     after(async function() {
modifiedtests/src/pallet-presence.test.tsdiffbeforeafterboth
before · tests/src/pallet-presence.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 {itSub, usingPlaygrounds, expect} from './util';1819// Pallets that must always be present20const requiredPallets = [21  'balances',22  'balancesadapter',23  'common',24  'timestamp',25  'transactionpayment',26  'treasury',27  'structure',28  'system',29  'vesting',30  'parachainsystem',31  'parachaininfo',32  'evm',33  'evmcodersubstrate',34  'evmcontracthelpers',35  'evmmigration',36  'evmtransactionpayment',37  'ethereum',38  'fungible',39  'xcmpqueue',40  'polkadotxcm',41  'cumulusxcm',42  'dmpqueue',43  'inflation',44  'unique',45  'nonfungible',46  'charging',47  'configuration',48  'tokens',49  'xtokens',50  'maintenance',51];5253// Pallets that depend on consensus and governance configuration54const consensusPallets = [55  'sudo',56  'aura',57  'auraext',58];5960describe('Pallet presence', () => {61  before(async () => {62    await usingPlaygrounds(async helper => {63      const chain = await helper.callRpc('api.rpc.system.chain', []);6465      const refungible = 'refungible';66      const foreignAssets = 'foreignassets';67      const appPromotion = 'apppromotion';68      const collatorSelection = ['authorship', 'session', 'collatorselection', 'identity'];69      const preimage = ['preimage'];70      const testUtils = 'testutils';7172      if (chain.eq('OPAL by UNIQUE')) {73        requiredPallets.push(74          refungible,75          foreignAssets,76          appPromotion,77          testUtils,78          ...collatorSelection,79          ...preimage,80        );81      } else if (chain.eq('QUARTZ by UNIQUE') || chain.eq('SAPPHIRE by UNIQUE')) {82        requiredPallets.push(83          refungible,84          appPromotion,85          foreignAssets,86          ...collatorSelection,87          ...preimage,88        );89      } else if (chain.eq('UNIQUE')) {90        // Insert Unique additional pallets here91        requiredPallets.push(92          refungible,93          foreignAssets,94          appPromotion,95        );96      }97    });98  });99100  itSub('Required pallets are present', ({helper}) => {101    expect(helper.fetchAllPalletNames()).to.contain.members([...requiredPallets].sort());102  });103104  itSub('Governance and consensus pallets are present', ({helper}) => {105    expect(helper.fetchAllPalletNames()).to.contain.members([...consensusPallets].sort());106  });107108  itSub('No extra pallets are included', ({helper}) => {109    expect(helper.fetchAllPalletNames().sort()).to.be.deep.equal([...requiredPallets, ...consensusPallets].sort());110  });111});
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -591,8 +591,11 @@
                   const errorMeta = dispatchError.registry.findMetaError(modErr);
 
                   moduleError = `${errorMeta.section}.${errorMeta.name}`;
+                } else if (dispatchError.isToken) {
+                  moduleError = `Token: ${dispatchError.asToken}`;
                 } else {
-                  moduleError = dispatchError.toHuman();
+                  // May be [object Object] in case of unhandled non-unit enum
+                  moduleError = `Misc: ${dispatchError.toHuman()}`;
                 }
               } else {
                 this.logger.log(result, this.logger.level.ERROR);
@@ -3480,6 +3483,8 @@
         } else if (data.asErr.isToken) {
           throw new Error(`Token: ${data.asErr.asToken}`);
         }
+        // May be [object Object] in case of unhandled non-unit enum
+        throw new Error(`Misc: ${data.asErr.toHuman()}`);
       }
       return result;
     }