difftreelog
Tests can build
in: master
8 files changed
Cargo.lockdiffbeforeafterboth5993 "sp-std",5993 "sp-std",5994]5994]59955996[[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]601359956014[[package]]5996[[package]]6015name = "pallet-scheduler"5997name = "pallet-scheduler"6026 "sp-std",6008 "sp-std",6027]6009]60106011[[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]602860286029[[package]]6029[[package]]6030name = "pallet-session"6030name = "pallet-session"launch-config.jsondiffbeforeafterboth45 "nodes": [45 "nodes": [46 {46 {47 "port": 31200,47 "port": 31200,48 "wsPort": "9944",48 "name": "alice",49 "name": "alice",49 "flags": []50 "flags": []50 }51 },52 {53 "port": 31201,54 "wsPort": "9945",55 "name": "bob",56 "flags": []57 }51 ]58 ]52 }59 }53 ],60 ],runtime/src/lib.rsdiffbeforeafterboth216/// by Operational extrinsics.216/// by Operational extrinsics.217const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);217const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);218/// We allow for 2 seconds of compute with a 6 second average block time.218/// We allow for 2 seconds of compute with a 6 second average block time.219const MAXIMUM_BLOCK_WEIGHT: Weight = 2 * WEIGHT_PER_SECOND;219const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND / 2;220220221parameter_types! {221parameter_types! {222 pub const BlockHashCount: BlockNumber = 2400;222 pub const BlockHashCount: BlockNumber = 2400;tests/src/config.tsdiffbeforeafterboth6import process from 'process';6import process from 'process';778const config = {8const config = {9 substrateUrl: process.env.substrateUrl || 'ws://127.0.0.1:9844'9 substrateUrl: process.env.substrateUrl || 'ws://127.0.0.1:9944'10}10}111112export default config;12export default config;tests/src/contracts.test.tsdiffbeforeafterboth177 const result = getGenericResult(events);177 const result = getGenericResult(events);178 expect(result.success).to.be.true;178 expect(result.success).to.be.true;179179180 await transferFromExpectSuccess(collectionId, tokenId, bob, contract.address.toString(), charlie, 1, 'NFT');180 await transferFromExpectSuccess(collectionId, tokenId, bob, normalizeAccountId(contract.address.toString()), charlie, 1, 'NFT');181 });181 });182 });182 });183183tests/src/removeFromWhiteList.test.tsdiffbeforeafterboth16 findNotExistingCollection,16 findNotExistingCollection,17 removeFromWhiteListExpectFailure,17 removeFromWhiteListExpectFailure,18 disableWhiteListExpectSuccess,18 disableWhiteListExpectSuccess,19 normalizeAccountId19} from './util/helpers';20} from './util/helpers';20import { IKeyringPair } from '@polkadot/types/types';21import { IKeyringPair } from '@polkadot/types/types';21import privateKey from './substrate/privateKey';22import privateKey from './substrate/privateKey';40 await enableWhiteListExpectSuccess(alice, collectionId);41 await enableWhiteListExpectSuccess(alice, collectionId);41 await addToWhiteListExpectSuccess(alice, collectionId, bob.address);42 await addToWhiteListExpectSuccess(alice, collectionId, bob.address);424343 await removeFromWhiteListExpectSuccess(alice, collectionId, bob.address);44 await removeFromWhiteListExpectSuccess(alice, collectionId, normalizeAccountId(bob.address));44 expect(await isWhitelisted(collectionId, bob.address)).to.be.false;45 expect(await isWhitelisted(collectionId, bob.address)).to.be.false;45 });46 });46 });47 });52 await addToWhiteListExpectSuccess(alice, collectionWithoutWhitelistId, bob.address);53 await addToWhiteListExpectSuccess(alice, collectionWithoutWhitelistId, bob.address);53 await disableWhiteListExpectSuccess(alice, collectionWithoutWhitelistId);54 await disableWhiteListExpectSuccess(alice, collectionWithoutWhitelistId);545555 await removeFromWhiteListExpectSuccess(alice, collectionWithoutWhitelistId, bob.address);56 await removeFromWhiteListExpectSuccess(alice, collectionWithoutWhitelistId, normalizeAccountId(bob.address));56 });57 });57 });58 });58});59});72 await usingApi(async (api) => {73 await usingApi(async (api) => {73 const collectionId = await findNotExistingCollection(api);74 const collectionId = await findNotExistingCollection(api);747575 await removeFromWhiteListExpectFailure(alice, collectionId, bob.address);76 await removeFromWhiteListExpectFailure(alice, collectionId, normalizeAccountId(bob.address));76 });77 });77 });78 });787983 await addToWhiteListExpectSuccess(alice, collectionId, bob.address);84 await addToWhiteListExpectSuccess(alice, collectionId, bob.address);84 await destroyCollectionExpectSuccess(collectionId);85 await destroyCollectionExpectSuccess(collectionId);858686 await removeFromWhiteListExpectFailure(alice, collectionId, bob.address);87 await removeFromWhiteListExpectFailure(alice, collectionId, normalizeAccountId(bob.address));87 });88 });88 });89 });89});90});tests/src/toggleContractWhiteList.test.tsdiffbeforeafterboth45 const [contract, deployer] = await deployFlipper(api);45 const [contract, deployer] = await deployFlipper(api);464647 let flipValueBefore = await getFlipValue(contract, deployer);47 let flipValueBefore = await getFlipValue(contract, deployer);48 const flip = contract.exec('flip', value, gasLimit);48 const flip = contract.tx.flip(value, gasLimit);49 await submitTransactionAsync(bob, flip);49 await submitTransactionAsync(bob, flip);50 const flipValueAfter = await getFlipValue(contract,deployer);50 const flipValueAfter = await getFlipValue(contract,deployer);51 expect(flipValueAfter).to.be.eq(!flipValueBefore, `Anyone can call new contract.`);51 expect(flipValueAfter).to.be.eq(!flipValueBefore, `Anyone can call new contract.`);525253 const deployerCanFlip = async () => {53 const deployerCanFlip = async () => {54 let flipValueBefore = await getFlipValue(contract, deployer);54 let flipValueBefore = await getFlipValue(contract, deployer);55 const deployerFlip = contract.exec('flip', value, gasLimit);55 const deployerFlip = contract.tx.flip(value, gasLimit);56 await submitTransactionAsync(deployer, deployerFlip);56 await submitTransactionAsync(deployer, deployerFlip);57 const aliceFlip1Response = await getFlipValue(contract, deployer);57 const aliceFlip1Response = await getFlipValue(contract, deployer);58 expect(aliceFlip1Response).to.be.eq(!flipValueBefore, `Deployer always can flip.`);58 expect(aliceFlip1Response).to.be.eq(!flipValueBefore, `Deployer always can flip.`);62 flipValueBefore = await getFlipValue(contract, deployer);62 flipValueBefore = await getFlipValue(contract, deployer);63 const enableWhiteListTx = api.tx.nft.toggleContractWhiteList(contract.address, true);63 const enableWhiteListTx = api.tx.nft.toggleContractWhiteList(contract.address, true);64 const enableResult = await submitTransactionAsync(deployer, enableWhiteListTx);64 const enableResult = await submitTransactionAsync(deployer, enableWhiteListTx);65 const flipWithEnabledWhiteList = contract.exec('flip', value, gasLimit);65 const flipWithEnabledWhiteList = contract.tx.flip(value, gasLimit);66 await expect(submitTransactionExpectFailAsync(bob, flipWithEnabledWhiteList)).to.be.rejected;66 await expect(submitTransactionExpectFailAsync(bob, flipWithEnabledWhiteList)).to.be.rejected;67 const flipValueAfterEnableWhiteList = await getFlipValue(contract, deployer);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.`);68 expect(flipValueAfterEnableWhiteList).to.be.eq(flipValueBefore, `Enabling whitelist doesn't make it possible to call contract for everyone.`);72 flipValueBefore = await getFlipValue(contract, deployer);72 flipValueBefore = await getFlipValue(contract, deployer);73 const addBobToWhiteListTx = api.tx.nft.addToContractWhiteList(contract.address, bob.address);73 const addBobToWhiteListTx = api.tx.nft.addToContractWhiteList(contract.address, bob.address);74 const addBobResult = await submitTransactionAsync(deployer, addBobToWhiteListTx);74 const addBobResult = await submitTransactionAsync(deployer, addBobToWhiteListTx);75 const flipWithWhitelistedBob = contract.exec('flip', value, gasLimit);75 const flipWithWhitelistedBob = contract.tx.flip(value, gasLimit);76 await submitTransactionAsync(bob, flipWithWhitelistedBob);76 await submitTransactionAsync(bob, flipWithWhitelistedBob);77 const flipAfterWhiteListed = await getFlipValue(contract,deployer);77 const flipAfterWhiteListed = await getFlipValue(contract,deployer);78 expect(flipAfterWhiteListed).to.be.eq(!flipValueBefore, `Bob was whitelisted, now he can flip.`);78 expect(flipAfterWhiteListed).to.be.eq(!flipValueBefore, `Bob was whitelisted, now he can flip.`);82 flipValueBefore = await getFlipValue(contract, deployer);82 flipValueBefore = await getFlipValue(contract, deployer);83 const removeBobFromWhiteListTx = api.tx.nft.removeFromContractWhiteList(contract.address, bob.address);83 const removeBobFromWhiteListTx = api.tx.nft.removeFromContractWhiteList(contract.address, bob.address);84 const removeBobResult = await submitTransactionAsync(deployer, removeBobFromWhiteListTx);84 const removeBobResult = await submitTransactionAsync(deployer, removeBobFromWhiteListTx);85 const bobRemoved = contract.exec('flip', value, gasLimit);85 const bobRemoved = contract.tx.flip(value, gasLimit);86 await expect(submitTransactionExpectFailAsync(bob, bobRemoved)).to.be.rejected;86 await expect(submitTransactionExpectFailAsync(bob, bobRemoved)).to.be.rejected;87 const afterBobRemoved = await getFlipValue(contract, deployer);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.`);88 expect(afterBobRemoved).to.be.eq(flipValueBefore, `Bob can't call contract, now when he is removeed from white list.`);92 flipValueBefore = await getFlipValue(contract, deployer);92 flipValueBefore = await getFlipValue(contract, deployer);93 const disableWhiteListTx = api.tx.nft.toggleContractWhiteList(contract.address, false);93 const disableWhiteListTx = api.tx.nft.toggleContractWhiteList(contract.address, false);94 const disableWhiteListResult = await submitTransactionAsync(deployer, disableWhiteListTx);94 const disableWhiteListResult = await submitTransactionAsync(deployer, disableWhiteListTx);95 const whiteListDisabledFlip = contract.exec('flip', value, gasLimit);95 const whiteListDisabledFlip = contract.tx.flip(value, gasLimit);96 await submitTransactionAsync(bob, whiteListDisabledFlip);96 await submitTransactionAsync(bob, whiteListDisabledFlip);97 const afterWhiteListDisabled = await getFlipValue(contract,deployer);97 const afterWhiteListDisabled = await getFlipValue(contract,deployer);98 expect(afterWhiteListDisabled).to.be.eq(!flipValueBefore, `Anyone can call contract with disabled whitelist.`);98 expect(afterWhiteListDisabled).to.be.eq(!flipValueBefore, `Anyone can call contract with disabled whitelist.`);tests/src/util/helpers.tsdiffbeforeafterboth29} | {29} | {30 ethereum: string,30 ethereum: string,31};31};32export function normalizeAccountId(input: string | CrossAccountId | IKeyringPair): CrossAccountId {32export function normalizeAccountId(input: string | AccountId | CrossAccountId | IKeyringPair): CrossAccountId {33 if (typeof input === 'string')33 if (typeof input === 'string')34 return { substrate: input };34 return { substrate: input };35 if ('address' in input) {35 if ('address' in input) {36 return { substrate: input.address };36 return { substrate: input.address };37 }37 }38 if ('ethereum' in input) {38 if ('ethereum' in input) {39 input.ethereum = input.ethereum.toLowerCase();39 input.ethereum = input.ethereum.toLowerCase();40 return input;40 }41 }4243 // AccountId41 return input;44 return {substrate: input.toString()}42}45}43export function toSubstrateAddress(input: string | CrossAccountId | IKeyringPair): string {46export function toSubstrateAddress(input: string | CrossAccountId | IKeyringPair): string {44 input = normalizeAccountId(input);47 input = normalizeAccountId(input);