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

difftreelog

Update tests to pass on updated substrate (a7fd1e5d59b12)

Greg Zaitsev2021-01-26parent: #13bdc4a.patch.diff
in: master

6 files changed

modifiedtests/package.jsondiffbeforeafterboth
--- 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",
modifiedtests/src/addToContractWhiteList.test.tsdiffbeforeafterboth
3import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from "./substrate/substrate-api";3import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from "./substrate/substrate-api";
4import privateKey from "./substrate/privateKey";4import privateKey from "./substrate/privateKey";
5import {5import {
6 deployFlipper,6 deployFlipper
7 getFlipValue
8} from "./util/contracthelpers";7} from "./util/contracthelpers";
9import {8import {
10 getGenericResult9 getGenericResult
13chai.use(chaiAsPromised);12chai.use(chaiAsPromised);
14const expect = chai.expect;13const expect = chai.expect;
15
16const value = 0;
17const gasLimit = 3000n * 1000000n;
1814
19describe('Integration Test addToContractWhiteList', () => {15describe('Integration Test addToContractWhiteList', () => {
2016
modifiedtests/src/flipper/flipper.wasmdiffbeforeafterboth

binary blob — no preview

modifiedtests/src/flipper/metadata.jsondiffbeforeafterboth
--- 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 <admin@parity.io>"
+      "[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": [
modifiedtests/src/substrate/substrate-api.tsdiffbeforeafterboth
--- 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;
   }
 }
 
modifiedtests/src/util/contracthelpers.tsdiffbeforeafterboth
--- 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;
 }