From af54ef4128eef685166c7aed0ac3f494b7e102c9 Mon Sep 17 00:00:00 2001 From: Greg Zaitsev Date: Tue, 26 Jan 2021 14:30:00 +0000 Subject: [PATCH] Update tests to pass on updated substrate (a7fd1e5d59b12) --- --- a/tests/package.json +++ b/tests/package.json @@ -35,7 +35,7 @@ "testBurnItem": "mocha --timeout 9999999 -r ts-node/register ./**/burnItem.test.ts" }, "author": "", - "license": "Apache 2.0", + "license": "SEE LICENSE IN ../LICENSE", "homepage": "", "dependencies": { "@polkadot/api": "^3.6.3", --- a/tests/src/addToContractWhiteList.test.ts +++ b/tests/src/addToContractWhiteList.test.ts @@ -3,8 +3,7 @@ import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from "./substrate/substrate-api"; import privateKey from "./substrate/privateKey"; import { - deployFlipper, - getFlipValue + deployFlipper } from "./util/contracthelpers"; import { getGenericResult @@ -12,9 +11,6 @@ chai.use(chaiAsPromised); const expect = chai.expect; - -const value = 0; -const gasLimit = 3000n * 1000000n; describe('Integration Test addToContractWhiteList', () => { --- a/tests/src/flipper/metadata.json +++ b/tests/src/flipper/metadata.json @@ -1,15 +1,15 @@ { "metadataVersion": "0.1.0", "source": { - "hash": "0x36431d9da78a6bb099474e49c9e35a9c3a04272b58815634082626109826cac6", - "language": "ink! 3.0.0-rc1", - "compiler": "rustc 1.49.0-nightly" + "hash": "0x5b02ceadaacee8408d3c6496394847092c099bcb897221dbe8d22c16d372fa17", + "language": "ink! 3.0.0-rc2", + "compiler": "rustc 1.51.0-nightly" }, "contract": { "name": "flipper", - "version": "3.0.0-rc1", + "version": "0.1.0", "authors": [ - "Parity Technologies " + "[your_name] <[your_email]>" ] }, "spec": { @@ -27,7 +27,7 @@ } ], "docs": [ - " Creates a new flipper smart contract initialized with the given value." + " Constructor that initializes the `bool` value to the given `init_value`." ], "name": [ "new" @@ -37,7 +37,9 @@ { "args": [], "docs": [ - " Creates a new flipper smart contract initialized to `false`." + " Constructor that initializes the `bool` value to `false`.", + "", + " Constructors can delegate to other constructors." ], "name": [ "default" @@ -51,7 +53,9 @@ { "args": [], "docs": [ - " Flips the current value of the Flipper's bool." + " A message that can be called on instantiated contracts.", + " This one flips the value of the stored `bool` from `true`", + " to `false` and vice versa." ], "mutates": true, "name": [ @@ -64,7 +68,7 @@ { "args": [], "docs": [ - " Returns the current value of the Flipper's bool." + " Simply returns the current value of our `bool`." ], "mutates": false, "name": [ --- a/tests/src/substrate/substrate-api.ts +++ b/tests/src/substrate/substrate-api.ts @@ -21,6 +21,15 @@ settings = settings || defaultApiOptions(); let api: ApiPromise = new ApiPromise(settings); + // TODO: Remove, this is temporary: Filter unneeded API output + // (Jaco promised it will be removed in the next version) + const consoleLog = console.log; + console.log = (message: string) => { + if (!(message.includes("API/INIT: Capabilities detected") || message.includes("2021-"))) { + consoleLog(message); + } + }; + try { await promisifySubstrate(api, async () => { if(api) { @@ -30,6 +39,7 @@ })(); } finally { await api.disconnect(); + console.log = consoleLog; } } --- a/tests/src/util/contracthelpers.ts +++ b/tests/src/util/contracthelpers.ts @@ -86,11 +86,9 @@ export async function getFlipValue(contract: Contract, deployer: IKeyringPair) { const result = await contract.query.get(deployer.address, value, gasLimit); - console.log(result); -// if(!result.result.isSuccess) { -// throw `Failed to get flipper value`; -// } -// return (result.result.asSuccess.data[0] == 0x00) ? false : true; - return false; + if(!result.result.isOk) { + throw `Failed to get flipper value`; + } + return (result.result.asOk.data[0] == 0x00) ? false : true; } -- gitstuff