difftreelog
Tests can build
in: master
8 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5996,34 +5996,34 @@
[[package]]
name = "pallet-scheduler"
version = "3.0.0"
+source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.3#c94e0cdfe5556680dca1996004751eeb114755d7"
dependencies = [
"frame-benchmarking",
"frame-support",
"frame-system",
"log",
"parity-scale-codec 2.1.3",
- "serde",
- "sp-core",
"sp-io",
"sp-runtime",
"sp-std",
- "substrate-test-utils",
- "up-sponsorship",
]
[[package]]
name = "pallet-scheduler"
version = "3.0.0"
-source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.3#c94e0cdfe5556680dca1996004751eeb114755d7"
dependencies = [
"frame-benchmarking",
"frame-support",
"frame-system",
"log",
"parity-scale-codec 2.1.3",
+ "serde",
+ "sp-core",
"sp-io",
"sp-runtime",
"sp-std",
+ "substrate-test-utils",
+ "up-sponsorship",
]
[[package]]
launch-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": []
}
]
}
runtime/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;
tests/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
tests/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');
});
});
tests/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));
});
});
});
tests/src/toggleContractWhiteList.test.tsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import chai from "chai";7import chaiAsPromised from 'chai-as-promised';8import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from "./substrate/substrate-api";9import privateKey from "./substrate/privateKey";10import {11 deployFlipper,12 getFlipValue13} from "./util/contracthelpers";14import {15 getGenericResult16} from "./util/helpers"1718chai.use(chaiAsPromised);19const expect = chai.expect;2021const value = 0;22const gasLimit = 3000n * 1000000n;2324describe('Integration Test toggleContractWhiteList', () => {2526 it(`Enable white list contract mode`, async () => {27 await usingApi(async api => {28 const [contract, deployer] = await deployFlipper(api);2930 const enabledBefore = (await api.query.nft.contractWhiteListEnabled(contract.address)).toJSON();31 const enableWhiteListTx = api.tx.nft.toggleContractWhiteList(contract.address, true);32 const enableEvents = await submitTransactionAsync(deployer, enableWhiteListTx);33 const enabled = (await api.query.nft.contractWhiteListEnabled(contract.address)).toJSON();3435 expect(getGenericResult(enableEvents).success).to.be.true;36 expect(enabledBefore).to.be.false;37 expect(enabled).to.be.true;38 });39 });4041 it(`Only whitelisted account can call contract`, async () => {42 await usingApi(async api => {43 const bob = privateKey("//Bob");4445 const [contract, deployer] = await deployFlipper(api);4647 let flipValueBefore = await getFlipValue(contract, deployer);48 const flip = contract.exec('flip', value, gasLimit);49 await submitTransactionAsync(bob, flip);50 const flipValueAfter = await getFlipValue(contract,deployer);51 expect(flipValueAfter).to.be.eq(!flipValueBefore, `Anyone can call new contract.`);5253 const deployerCanFlip = async () => {54 let flipValueBefore = await getFlipValue(contract, deployer);55 const deployerFlip = contract.exec('flip', value, gasLimit);56 await submitTransactionAsync(deployer, deployerFlip);57 const aliceFlip1Response = await getFlipValue(contract, deployer);58 expect(aliceFlip1Response).to.be.eq(!flipValueBefore, `Deployer always can flip.`);59 };60 await deployerCanFlip();6162 flipValueBefore = await getFlipValue(contract, deployer);63 const enableWhiteListTx = api.tx.nft.toggleContractWhiteList(contract.address, true);64 const enableResult = await submitTransactionAsync(deployer, enableWhiteListTx);65 const flipWithEnabledWhiteList = contract.exec('flip', value, gasLimit);66 await expect(submitTransactionExpectFailAsync(bob, flipWithEnabledWhiteList)).to.be.rejected;67 const flipValueAfterEnableWhiteList = await getFlipValue(contract, deployer);68 expect(flipValueAfterEnableWhiteList).to.be.eq(flipValueBefore, `Enabling whitelist doesn't make it possible to call contract for everyone.`);6970 await deployerCanFlip();7172 flipValueBefore = await getFlipValue(contract, deployer);73 const addBobToWhiteListTx = api.tx.nft.addToContractWhiteList(contract.address, bob.address);74 const addBobResult = await submitTransactionAsync(deployer, addBobToWhiteListTx);75 const flipWithWhitelistedBob = contract.exec('flip', value, gasLimit);76 await submitTransactionAsync(bob, flipWithWhitelistedBob);77 const flipAfterWhiteListed = await getFlipValue(contract,deployer);78 expect(flipAfterWhiteListed).to.be.eq(!flipValueBefore, `Bob was whitelisted, now he can flip.`);7980 await deployerCanFlip();8182 flipValueBefore = await getFlipValue(contract, deployer);83 const removeBobFromWhiteListTx = api.tx.nft.removeFromContractWhiteList(contract.address, bob.address);84 const removeBobResult = await submitTransactionAsync(deployer, removeBobFromWhiteListTx);85 const bobRemoved = contract.exec('flip', value, gasLimit);86 await expect(submitTransactionExpectFailAsync(bob, bobRemoved)).to.be.rejected;87 const afterBobRemoved = await getFlipValue(contract, deployer);88 expect(afterBobRemoved).to.be.eq(flipValueBefore, `Bob can't call contract, now when he is removeed from white list.`);8990 await deployerCanFlip();9192 flipValueBefore = await getFlipValue(contract, deployer);93 const disableWhiteListTx = api.tx.nft.toggleContractWhiteList(contract.address, false);94 const disableWhiteListResult = await submitTransactionAsync(deployer, disableWhiteListTx);95 const whiteListDisabledFlip = contract.exec('flip', value, gasLimit);96 await submitTransactionAsync(bob, whiteListDisabledFlip);97 const afterWhiteListDisabled = await getFlipValue(contract,deployer);98 expect(afterWhiteListDisabled).to.be.eq(!flipValueBefore, `Anyone can call contract with disabled whitelist.`);99100 });101 });102103 it(`Enabling white list repeatedly should not produce errors`, async () => {104 await usingApi(async api => {105 const [contract, deployer] = await deployFlipper(api);106107 const enabledBefore = (await api.query.nft.contractWhiteListEnabled(contract.address)).toJSON();108 const enableWhiteListTx = api.tx.nft.toggleContractWhiteList(contract.address, true);109 const enableEvents = await submitTransactionAsync(deployer, enableWhiteListTx);110 const enabled = (await api.query.nft.contractWhiteListEnabled(contract.address)).toJSON();111 const enableAgainEvents = await submitTransactionAsync(deployer, enableWhiteListTx);112 const enabledAgain = (await api.query.nft.contractWhiteListEnabled(contract.address)).toJSON();113114 expect(getGenericResult(enableEvents).success).to.be.true;115 expect(enabledBefore).to.be.false;116 expect(enabled).to.be.true;117 expect(getGenericResult(enableAgainEvents).success).to.be.true;118 expect(enabledAgain).to.be.true;119 });120 });121122});123124describe('Negative Integration Test toggleContractWhiteList', () => {125126 it(`Enable white list for a non-contract`, async () => {127 await usingApi(async api => {128 const alice = privateKey("//Alice");129 const bobGuineaPig = privateKey("//Bob");130131 const enabledBefore = (await api.query.nft.contractWhiteListEnabled(bobGuineaPig.address)).toJSON();132 const enableWhiteListTx = api.tx.nft.toggleContractWhiteList(bobGuineaPig.address, true);133 await expect(submitTransactionExpectFailAsync(alice, enableWhiteListTx)).to.be.rejected;134 const enabled = (await api.query.nft.contractWhiteListEnabled(bobGuineaPig.address)).toJSON();135136 expect(enabledBefore).to.be.false;137 expect(enabled).to.be.false;138 });139 });140141 it(`Enable white list using a non-owner address`, async () => {142 await usingApi(async api => {143 const bob = privateKey("//Bob");144 const [contract, deployer] = await deployFlipper(api);145146 const enabledBefore = (await api.query.nft.contractWhiteListEnabled(contract.address)).toJSON();147 const enableWhiteListTx = api.tx.nft.toggleContractWhiteList(contract.address, true);148 await expect(submitTransactionExpectFailAsync(bob, enableWhiteListTx)).to.be.rejected;149 const enabled = (await api.query.nft.contractWhiteListEnabled(contract.address)).toJSON();150151 expect(enabledBefore).to.be.false;152 expect(enabled).to.be.false;153 });154 });155156});1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import chai from "chai";7import chaiAsPromised from 'chai-as-promised';8import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from "./substrate/substrate-api";9import privateKey from "./substrate/privateKey";10import {11 deployFlipper,12 getFlipValue13} from "./util/contracthelpers";14import {15 getGenericResult16} from "./util/helpers"1718chai.use(chaiAsPromised);19const expect = chai.expect;2021const value = 0;22const gasLimit = 3000n * 1000000n;2324describe('Integration Test toggleContractWhiteList', () => {2526 it(`Enable white list contract mode`, async () => {27 await usingApi(async api => {28 const [contract, deployer] = await deployFlipper(api);2930 const enabledBefore = (await api.query.nft.contractWhiteListEnabled(contract.address)).toJSON();31 const enableWhiteListTx = api.tx.nft.toggleContractWhiteList(contract.address, true);32 const enableEvents = await submitTransactionAsync(deployer, enableWhiteListTx);33 const enabled = (await api.query.nft.contractWhiteListEnabled(contract.address)).toJSON();3435 expect(getGenericResult(enableEvents).success).to.be.true;36 expect(enabledBefore).to.be.false;37 expect(enabled).to.be.true;38 });39 });4041 it(`Only whitelisted account can call contract`, async () => {42 await usingApi(async api => {43 const bob = privateKey("//Bob");4445 const [contract, deployer] = await deployFlipper(api);4647 let flipValueBefore = await getFlipValue(contract, deployer);48 const flip = contract.tx.flip(value, gasLimit);49 await submitTransactionAsync(bob, flip);50 const flipValueAfter = await getFlipValue(contract,deployer);51 expect(flipValueAfter).to.be.eq(!flipValueBefore, `Anyone can call new contract.`);5253 const deployerCanFlip = async () => {54 let flipValueBefore = await getFlipValue(contract, deployer);55 const deployerFlip = contract.tx.flip(value, gasLimit);56 await submitTransactionAsync(deployer, deployerFlip);57 const aliceFlip1Response = await getFlipValue(contract, deployer);58 expect(aliceFlip1Response).to.be.eq(!flipValueBefore, `Deployer always can flip.`);59 };60 await deployerCanFlip();6162 flipValueBefore = await getFlipValue(contract, deployer);63 const enableWhiteListTx = api.tx.nft.toggleContractWhiteList(contract.address, true);64 const enableResult = await submitTransactionAsync(deployer, enableWhiteListTx);65 const flipWithEnabledWhiteList = contract.tx.flip(value, gasLimit);66 await expect(submitTransactionExpectFailAsync(bob, flipWithEnabledWhiteList)).to.be.rejected;67 const flipValueAfterEnableWhiteList = await getFlipValue(contract, deployer);68 expect(flipValueAfterEnableWhiteList).to.be.eq(flipValueBefore, `Enabling whitelist doesn't make it possible to call contract for everyone.`);6970 await deployerCanFlip();7172 flipValueBefore = await getFlipValue(contract, deployer);73 const addBobToWhiteListTx = api.tx.nft.addToContractWhiteList(contract.address, bob.address);74 const addBobResult = await submitTransactionAsync(deployer, addBobToWhiteListTx);75 const flipWithWhitelistedBob = contract.tx.flip(value, gasLimit);76 await submitTransactionAsync(bob, flipWithWhitelistedBob);77 const flipAfterWhiteListed = await getFlipValue(contract,deployer);78 expect(flipAfterWhiteListed).to.be.eq(!flipValueBefore, `Bob was whitelisted, now he can flip.`);7980 await deployerCanFlip();8182 flipValueBefore = await getFlipValue(contract, deployer);83 const removeBobFromWhiteListTx = api.tx.nft.removeFromContractWhiteList(contract.address, bob.address);84 const removeBobResult = await submitTransactionAsync(deployer, removeBobFromWhiteListTx);85 const bobRemoved = contract.tx.flip(value, gasLimit);86 await expect(submitTransactionExpectFailAsync(bob, bobRemoved)).to.be.rejected;87 const afterBobRemoved = await getFlipValue(contract, deployer);88 expect(afterBobRemoved).to.be.eq(flipValueBefore, `Bob can't call contract, now when he is removeed from white list.`);8990 await deployerCanFlip();9192 flipValueBefore = await getFlipValue(contract, deployer);93 const disableWhiteListTx = api.tx.nft.toggleContractWhiteList(contract.address, false);94 const disableWhiteListResult = await submitTransactionAsync(deployer, disableWhiteListTx);95 const whiteListDisabledFlip = contract.tx.flip(value, gasLimit);96 await submitTransactionAsync(bob, whiteListDisabledFlip);97 const afterWhiteListDisabled = await getFlipValue(contract,deployer);98 expect(afterWhiteListDisabled).to.be.eq(!flipValueBefore, `Anyone can call contract with disabled whitelist.`);99100 });101 });102103 it(`Enabling white list repeatedly should not produce errors`, async () => {104 await usingApi(async api => {105 const [contract, deployer] = await deployFlipper(api);106107 const enabledBefore = (await api.query.nft.contractWhiteListEnabled(contract.address)).toJSON();108 const enableWhiteListTx = api.tx.nft.toggleContractWhiteList(contract.address, true);109 const enableEvents = await submitTransactionAsync(deployer, enableWhiteListTx);110 const enabled = (await api.query.nft.contractWhiteListEnabled(contract.address)).toJSON();111 const enableAgainEvents = await submitTransactionAsync(deployer, enableWhiteListTx);112 const enabledAgain = (await api.query.nft.contractWhiteListEnabled(contract.address)).toJSON();113114 expect(getGenericResult(enableEvents).success).to.be.true;115 expect(enabledBefore).to.be.false;116 expect(enabled).to.be.true;117 expect(getGenericResult(enableAgainEvents).success).to.be.true;118 expect(enabledAgain).to.be.true;119 });120 });121122});123124describe('Negative Integration Test toggleContractWhiteList', () => {125126 it(`Enable white list for a non-contract`, async () => {127 await usingApi(async api => {128 const alice = privateKey("//Alice");129 const bobGuineaPig = privateKey("//Bob");130131 const enabledBefore = (await api.query.nft.contractWhiteListEnabled(bobGuineaPig.address)).toJSON();132 const enableWhiteListTx = api.tx.nft.toggleContractWhiteList(bobGuineaPig.address, true);133 await expect(submitTransactionExpectFailAsync(alice, enableWhiteListTx)).to.be.rejected;134 const enabled = (await api.query.nft.contractWhiteListEnabled(bobGuineaPig.address)).toJSON();135136 expect(enabledBefore).to.be.false;137 expect(enabled).to.be.false;138 });139 });140141 it(`Enable white list using a non-owner address`, async () => {142 await usingApi(async api => {143 const bob = privateKey("//Bob");144 const [contract, deployer] = await deployFlipper(api);145146 const enabledBefore = (await api.query.nft.contractWhiteListEnabled(contract.address)).toJSON();147 const enableWhiteListTx = api.tx.nft.toggleContractWhiteList(contract.address, true);148 await expect(submitTransactionExpectFailAsync(bob, enableWhiteListTx)).to.be.rejected;149 const enabled = (await api.query.nft.contractWhiteListEnabled(contract.address)).toJSON();150151 expect(enabledBefore).to.be.false;152 expect(enabled).to.be.false;153 });154 });155156});tests/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);