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
--- 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', () => {
 
modifiedtests/src/flipper/flipper.wasmdiffbeforeafterboth

binary blob — no preview

modifiedtests/src/flipper/metadata.jsondiffbeforeafterboth
1{1{
2 "metadataVersion": "0.1.0",2 "metadataVersion": "0.1.0",
3 "source": {3 "source": {
4 "hash": "0x36431d9da78a6bb099474e49c9e35a9c3a04272b58815634082626109826cac6",4 "hash": "0x5b02ceadaacee8408d3c6496394847092c099bcb897221dbe8d22c16d372fa17",
5 "language": "ink! 3.0.0-rc1",5 "language": "ink! 3.0.0-rc2",
6 "compiler": "rustc 1.49.0-nightly"6 "compiler": "rustc 1.51.0-nightly"
7 },7 },
8 "contract": {8 "contract": {
9 "name": "flipper",9 "name": "flipper",
10 "version": "3.0.0-rc1",10 "version": "0.1.0",
11 "authors": [11 "authors": [
12 "Parity Technologies <admin@parity.io>"12 "[your_name] <[your_email]>"
13 ]13 ]
14 },14 },
15 "spec": {15 "spec": {
27 }27 }
28 ],28 ],
29 "docs": [29 "docs": [
30 " Creates a new flipper smart contract initialized with the given value."30 " Constructor that initializes the `bool` value to the given `init_value`."
31 ],31 ],
32 "name": [32 "name": [
33 "new"33 "new"
37 {37 {
38 "args": [],38 "args": [],
39 "docs": [39 "docs": [
40 " Creates a new flipper smart contract initialized to `false`."40 " Constructor that initializes the `bool` value to `false`.",
41 "",
42 " Constructors can delegate to other constructors."
41 ],43 ],
42 "name": [44 "name": [
43 "default"45 "default"
51 {53 {
52 "args": [],54 "args": [],
53 "docs": [55 "docs": [
54 " Flips the current value of the Flipper's bool."56 " A message that can be called on instantiated contracts.",
57 " This one flips the value of the stored `bool` from `true`",
58 " to `false` and vice versa."
55 ],59 ],
56 "mutates": true,60 "mutates": true,
57 "name": [61 "name": [
64 {68 {
65 "args": [],69 "args": [],
66 "docs": [70 "docs": [
67 " Returns the current value of the Flipper's bool."71 " Simply returns the current value of our `bool`."
68 ],72 ],
69 "mutates": false,73 "mutates": false,
70 "name": [74 "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;
 }