git.delta.rocks / unique-network / refs/commits / fced7659a53c

difftreelog

Tests can build

Greg Zaitsev2021-06-25parent: #90fcef9.patch.diff
in: master

8 files changed

modifiedCargo.lockdiffbeforeafterboth
5993 "sp-std",5993 "sp-std",
5994]5994]
5995
5996[[package]]
5997name = "pallet-scheduler"
5998version = "3.0.0"
5999dependencies = [
6000 "frame-benchmarking",
6001 "frame-support",
6002 "frame-system",
6003 "log",
6004 "parity-scale-codec 2.1.3",
6005 "serde",
6006 "sp-core",
6007 "sp-io",
6008 "sp-runtime",
6009 "sp-std",
6010 "substrate-test-utils",
6011 "up-sponsorship",
6012]
60135995
6014[[package]]5996[[package]]
6015name = "pallet-scheduler"5997name = "pallet-scheduler"
6026 "sp-std",6008 "sp-std",
6027]6009]
6010
6011[[package]]
6012name = "pallet-scheduler"
6013version = "3.0.0"
6014dependencies = [
6015 "frame-benchmarking",
6016 "frame-support",
6017 "frame-system",
6018 "log",
6019 "parity-scale-codec 2.1.3",
6020 "serde",
6021 "sp-core",
6022 "sp-io",
6023 "sp-runtime",
6024 "sp-std",
6025 "substrate-test-utils",
6026 "up-sponsorship",
6027]
60286028
6029[[package]]6029[[package]]
6030name = "pallet-session"6030name = "pallet-session"
modifiedlaunch-config.jsondiffbeforeafterboth
--- a/launch-config.json
+++ b/launch-config.json
@@ -45,8 +45,15 @@
                     "nodes": [
                             {
                                     "port": 31200,
+                                    "wsPort": "9944",
                                     "name": "alice",
                                     "flags": []
+                            },
+                            {
+                                    "port": 31201,
+                                    "wsPort": "9945",
+                                    "name": "bob",
+                                    "flags": []
                             }
                     ]
             }
modifiedruntime/src/lib.rsdiffbeforeafterboth
--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -216,7 +216,7 @@
 /// by  Operational  extrinsics.
 const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
 /// We allow for 2 seconds of compute with a 6 second average block time.
-const MAXIMUM_BLOCK_WEIGHT: Weight = 2 * WEIGHT_PER_SECOND;
+const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND / 2;
 
 parameter_types! {
 	pub const BlockHashCount: BlockNumber = 2400;
modifiedtests/src/config.tsdiffbeforeafterboth
--- a/tests/src/config.ts
+++ b/tests/src/config.ts
@@ -6,7 +6,7 @@
 import process from 'process';
 
 const config = {
-  substrateUrl: process.env.substrateUrl || 'ws://127.0.0.1:9844'
+  substrateUrl: process.env.substrateUrl || 'ws://127.0.0.1:9944'
 }
 
 export default config;
\ No newline at end of file
modifiedtests/src/contracts.test.tsdiffbeforeafterboth
--- a/tests/src/contracts.test.ts
+++ b/tests/src/contracts.test.ts
@@ -177,7 +177,7 @@
       const result = getGenericResult(events);
       expect(result.success).to.be.true;
 
-      await transferFromExpectSuccess(collectionId, tokenId, bob, contract.address.toString(), charlie, 1, 'NFT');
+      await transferFromExpectSuccess(collectionId, tokenId, bob, normalizeAccountId(contract.address.toString()), charlie, 1, 'NFT');
     });
   });
 
modifiedtests/src/removeFromWhiteList.test.tsdiffbeforeafterboth
--- a/tests/src/removeFromWhiteList.test.ts
+++ b/tests/src/removeFromWhiteList.test.ts
@@ -16,6 +16,7 @@
   findNotExistingCollection,
   removeFromWhiteListExpectFailure,
   disableWhiteListExpectSuccess,
+  normalizeAccountId
 } from './util/helpers';
 import { IKeyringPair } from '@polkadot/types/types';
 import privateKey from './substrate/privateKey';
@@ -40,7 +41,7 @@
       await enableWhiteListExpectSuccess(alice, collectionId);
       await addToWhiteListExpectSuccess(alice, collectionId, bob.address);
 
-      await removeFromWhiteListExpectSuccess(alice, collectionId, bob.address);
+      await removeFromWhiteListExpectSuccess(alice, collectionId, normalizeAccountId(bob.address));
       expect(await isWhitelisted(collectionId, bob.address)).to.be.false;
     });
   });
@@ -52,7 +53,7 @@
       await addToWhiteListExpectSuccess(alice, collectionWithoutWhitelistId, bob.address);
       await disableWhiteListExpectSuccess(alice, collectionWithoutWhitelistId);
 
-      await removeFromWhiteListExpectSuccess(alice, collectionWithoutWhitelistId, bob.address);
+      await removeFromWhiteListExpectSuccess(alice, collectionWithoutWhitelistId, normalizeAccountId(bob.address));
     });
   });
 });
@@ -72,7 +73,7 @@
     await usingApi(async (api) => {
       const collectionId = await findNotExistingCollection(api);
 
-      await removeFromWhiteListExpectFailure(alice, collectionId, bob.address);
+      await removeFromWhiteListExpectFailure(alice, collectionId, normalizeAccountId(bob.address));
     });
   });
 
@@ -83,7 +84,7 @@
       await addToWhiteListExpectSuccess(alice, collectionId, bob.address);
       await destroyCollectionExpectSuccess(collectionId);
 
-      await removeFromWhiteListExpectFailure(alice, collectionId, bob.address);
+      await removeFromWhiteListExpectFailure(alice, collectionId, normalizeAccountId(bob.address));
     });
   });
 });
modifiedtests/src/toggleContractWhiteList.test.tsdiffbeforeafterboth
--- a/tests/src/toggleContractWhiteList.test.ts
+++ b/tests/src/toggleContractWhiteList.test.ts
@@ -45,14 +45,14 @@
       const [contract, deployer] = await deployFlipper(api);
 
       let flipValueBefore = await getFlipValue(contract, deployer);
-      const flip = contract.exec('flip', value, gasLimit);
+      const flip = contract.tx.flip(value, gasLimit);
       await submitTransactionAsync(bob, flip);
       const flipValueAfter = await getFlipValue(contract,deployer);
       expect(flipValueAfter).to.be.eq(!flipValueBefore, `Anyone can call new contract.`);
 
       const deployerCanFlip = async () => {
         let flipValueBefore = await getFlipValue(contract, deployer);
-        const deployerFlip = contract.exec('flip', value, gasLimit);
+        const deployerFlip = contract.tx.flip(value, gasLimit);
         await submitTransactionAsync(deployer, deployerFlip);
         const aliceFlip1Response = await getFlipValue(contract, deployer);
         expect(aliceFlip1Response).to.be.eq(!flipValueBefore, `Deployer always can flip.`);
@@ -62,7 +62,7 @@
       flipValueBefore = await getFlipValue(contract, deployer);
       const enableWhiteListTx = api.tx.nft.toggleContractWhiteList(contract.address, true);
       const enableResult = await submitTransactionAsync(deployer, enableWhiteListTx);
-      const flipWithEnabledWhiteList = contract.exec('flip', value, gasLimit);
+      const flipWithEnabledWhiteList = contract.tx.flip(value, gasLimit);
       await expect(submitTransactionExpectFailAsync(bob, flipWithEnabledWhiteList)).to.be.rejected;
       const flipValueAfterEnableWhiteList = await getFlipValue(contract, deployer);
       expect(flipValueAfterEnableWhiteList).to.be.eq(flipValueBefore, `Enabling whitelist doesn't make it possible to call contract for everyone.`);
@@ -72,7 +72,7 @@
       flipValueBefore = await getFlipValue(contract, deployer);
       const addBobToWhiteListTx = api.tx.nft.addToContractWhiteList(contract.address, bob.address);
       const addBobResult = await submitTransactionAsync(deployer, addBobToWhiteListTx);
-      const flipWithWhitelistedBob = contract.exec('flip', value, gasLimit);
+      const flipWithWhitelistedBob = contract.tx.flip(value, gasLimit);
       await submitTransactionAsync(bob, flipWithWhitelistedBob);
       const flipAfterWhiteListed = await getFlipValue(contract,deployer);
       expect(flipAfterWhiteListed).to.be.eq(!flipValueBefore, `Bob was whitelisted, now he can flip.`);
@@ -82,7 +82,7 @@
       flipValueBefore = await getFlipValue(contract, deployer);
       const removeBobFromWhiteListTx = api.tx.nft.removeFromContractWhiteList(contract.address, bob.address);
       const removeBobResult = await submitTransactionAsync(deployer, removeBobFromWhiteListTx);
-      const bobRemoved = contract.exec('flip', value, gasLimit);
+      const bobRemoved = contract.tx.flip(value, gasLimit);
       await expect(submitTransactionExpectFailAsync(bob, bobRemoved)).to.be.rejected;
       const afterBobRemoved = await getFlipValue(contract, deployer);
       expect(afterBobRemoved).to.be.eq(flipValueBefore, `Bob can't call contract, now when he is removeed from white list.`);
@@ -92,7 +92,7 @@
       flipValueBefore = await getFlipValue(contract, deployer);
       const disableWhiteListTx = api.tx.nft.toggleContractWhiteList(contract.address, false);
       const disableWhiteListResult = await submitTransactionAsync(deployer, disableWhiteListTx);
-      const whiteListDisabledFlip = contract.exec('flip', value, gasLimit);
+      const whiteListDisabledFlip = contract.tx.flip(value, gasLimit);
       await submitTransactionAsync(bob, whiteListDisabledFlip);
       const afterWhiteListDisabled = await getFlipValue(contract,deployer);
       expect(afterWhiteListDisabled).to.be.eq(!flipValueBefore, `Anyone can call contract with disabled whitelist.`);
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -29,7 +29,7 @@
 } | {
   ethereum: string,
 };
-export function normalizeAccountId(input: string | CrossAccountId | IKeyringPair): CrossAccountId {
+export function normalizeAccountId(input: string | AccountId | CrossAccountId | IKeyringPair): CrossAccountId {
   if (typeof input === 'string')
     return { substrate: input };
   if ('address' in input) {
@@ -37,8 +37,11 @@
   }
   if ('ethereum' in input) {
     input.ethereum = input.ethereum.toLowerCase();
+    return input;
   }
-  return input;
+
+  // AccountId
+  return {substrate: input.toString()}
 }
 export function toSubstrateAddress(input: string | CrossAccountId | IKeyringPair): string {
   input = normalizeAccountId(input);