From eb599a479df72a4dbbcfd1de75249c1f97014469 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 17 Apr 2018 14:48:08 -0400 Subject: [PATCH 1/3] remove testing node 6 from travis (no longer supported) --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c6aaf9a68..1019d91d8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: node_js node_js: - "7" - - "6" addons: code_climate: repo_token: 7454b1a666015e244c384d19f48c34e35d1ae58c3aa428ec542f10bbcb848358 From 1415ce0d62d3844453b62a3704b3b4aad2b967cd Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 17 Apr 2018 14:48:17 -0400 Subject: [PATCH 2/3] upgrade to latest web3.js --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a09577bed..ff6c94ef6 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "underscore.string": "^3.3.4", "url-loader": "^0.6.2", "viz.js": "^1.8.1", - "web3": "1.0.0-beta.27", + "web3": "1.0.0-beta.34", "webpack": "^3.10.0", "window-size": "^1.1.0" }, From 424c7afc7059369f3cc63a0e586e5e20806a77c4 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 17 Apr 2018 14:48:31 -0400 Subject: [PATCH 3/3] convert example tests to use await --- templates/boilerplate/test/contract_spec.js | 19 ++++------- templates/demo/test/simple_storage_spec.js | 19 ++++------- templates/simple/test/contract_spec.js | 19 ++++------- .../test/another_storage_spec.js | 8 ++--- .../test/array_references_spec.js | 16 ++++----- test_apps/contracts_app/test/lib_test_spec.js | 8 ++--- .../contracts_app/test/simple_storage_spec.js | 19 ++++------- test_apps/contracts_app/test/token_spec.js | 33 +++++++------------ test_apps/test_app/embark.json | 1 - .../test_app/test/another_storage_spec.js | 8 ++--- .../test_app/test/array_references_spec.js | 16 ++++----- test_apps/test_app/test/lib_test_spec.js | 8 ++--- .../test_app/test/simple_storage_spec.js | 19 ++++------- test_apps/test_app/test/token_spec.js | 33 +++++++------------ 14 files changed, 83 insertions(+), 143 deletions(-) diff --git a/templates/boilerplate/test/contract_spec.js b/templates/boilerplate/test/contract_spec.js index 8c5ed27f9..5fa719de5 100644 --- a/templates/boilerplate/test/contract_spec.js +++ b/templates/boilerplate/test/contract_spec.js @@ -10,20 +10,15 @@ // EmbarkSpec.deployAll(contractsConfig, () => { done() }); // }); // -// it("should set constructor value", function(done) { -// SimpleStorage.methods.storedData().call().then(function(result) { -// assert.equal(result, 100); -// done(); -// }); +// it("should set constructor value", async function() { +// let result = await SimpleStorage.methods.storedData().call(); +// assert.equal(result, 100); // }); // -// it("set storage value", function(done) { -// SimpleStorage.methods.set(150).send().then(function() { -// SimpleStorage.methods.get().call().then(function(result) { -// assert.equal(result, 150); -// done(); -// }); -// }); +// it("set storage value", async function() { +// await SimpleStorage.methods.set(150).send(); +// let result = await SimpleStorage.methods.get().call(); +// assert.equal(result, 150); // }); // //}); diff --git a/templates/demo/test/simple_storage_spec.js b/templates/demo/test/simple_storage_spec.js index 1fe561089..53476a5bf 100644 --- a/templates/demo/test/simple_storage_spec.js +++ b/templates/demo/test/simple_storage_spec.js @@ -10,20 +10,15 @@ describe("SimpleStorage", function() { EmbarkSpec.deployAll(contractsConfig, () => { done() }); }); - it("should set constructor value", function(done) { - SimpleStorage.methods.storedData().call().then(function(result) { - assert.equal(result, 100); - done(); - }); + it("should set constructor value", async function() { + let result = await SimpleStorage.methods.storedData().call(); + assert.equal(result, 100); }); - it("set storage value", function(done) { - SimpleStorage.methods.set(150).send().then(function() { - SimpleStorage.methods.get().call().then(function(result) { - assert.equal(result, 150); - done(); - }); - }); + it("set storage value", async function() { + await SimpleStorage.methods.set(150).send(); + let result = SimpleStorage.methods.get().call(); + assert.equal(result, 150); }); }); diff --git a/templates/simple/test/contract_spec.js b/templates/simple/test/contract_spec.js index 8c5ed27f9..5fa719de5 100644 --- a/templates/simple/test/contract_spec.js +++ b/templates/simple/test/contract_spec.js @@ -10,20 +10,15 @@ // EmbarkSpec.deployAll(contractsConfig, () => { done() }); // }); // -// it("should set constructor value", function(done) { -// SimpleStorage.methods.storedData().call().then(function(result) { -// assert.equal(result, 100); -// done(); -// }); +// it("should set constructor value", async function() { +// let result = await SimpleStorage.methods.storedData().call(); +// assert.equal(result, 100); // }); // -// it("set storage value", function(done) { -// SimpleStorage.methods.set(150).send().then(function() { -// SimpleStorage.methods.get().call().then(function(result) { -// assert.equal(result, 150); -// done(); -// }); -// }); +// it("set storage value", async function() { +// await SimpleStorage.methods.set(150).send(); +// let result = await SimpleStorage.methods.get().call(); +// assert.equal(result, 150); // }); // //}); diff --git a/test_apps/contracts_app/test/another_storage_spec.js b/test_apps/contracts_app/test/another_storage_spec.js index d34c3e720..255a5d4b8 100644 --- a/test_apps/contracts_app/test/another_storage_spec.js +++ b/test_apps/contracts_app/test/another_storage_spec.js @@ -13,11 +13,9 @@ contract("AnotherStorage", function() { EmbarkSpec.deployAll(contractsConfig, () => { done() }); }); - it("set SimpleStorage address", function(done) { - AnotherStorage.methods.simpleStorageAddress().call().then(function(result) { - assert.equal(result.toString(), SimpleStorage.options.address); - done(); - }); + it("set SimpleStorage address", async function() { + let result = await AnotherStorage.methods.simpleStorageAddress().call(); + assert.equal(result.toString(), SimpleStorage.options.address); }); }); diff --git a/test_apps/contracts_app/test/array_references_spec.js b/test_apps/contracts_app/test/array_references_spec.js index 1492009b2..99cf37da9 100644 --- a/test_apps/contracts_app/test/array_references_spec.js +++ b/test_apps/contracts_app/test/array_references_spec.js @@ -24,18 +24,14 @@ contract("SomeContract", function() { EmbarkSpec.deployAll(contractsConfig, () => { done() }); }); - it("set MyToken2 address", function(done) { - SomeContract.methods.addr_1().call().then(function(address) { - assert.equal(address, MyToken2.options.address); - done(); - }); + it("set MyToken2 address", async function() { + let address = await SomeContract.methods.addr_1().call(); + assert.equal(address, MyToken2.options.address); }); - it("set SimpleStorage address", function(done) { - SomeContract.methods.addr_2().call().then(function(address) { - assert.equal(address, SimpleStorage.options.address); - done(); - }); + it("set SimpleStorage address", async function() { + let address = await SomeContract.methods.addr_2().call(); + assert.equal(address, SimpleStorage.options.address); }); }); diff --git a/test_apps/contracts_app/test/lib_test_spec.js b/test_apps/contracts_app/test/lib_test_spec.js index e039dc621..18aef2c9f 100644 --- a/test_apps/contracts_app/test/lib_test_spec.js +++ b/test_apps/contracts_app/test/lib_test_spec.js @@ -14,11 +14,9 @@ contract("Test", function() { EmbarkSpec.deployAll(contractsConfig, () => { done() }); }); - it("should call library correctly", function(done) { - Test2.methods.testAdd().call().then(function(result) { - assert.equal(result, 3); - done(); - }); + it("should call library correctly", async function() { + let result = await Test2.methods.testAdd().call(); + assert.equal(result, 3); }); }); diff --git a/test_apps/contracts_app/test/simple_storage_spec.js b/test_apps/contracts_app/test/simple_storage_spec.js index 6d16e7b8d..b43e0b354 100644 --- a/test_apps/contracts_app/test/simple_storage_spec.js +++ b/test_apps/contracts_app/test/simple_storage_spec.js @@ -17,20 +17,15 @@ contract("SimpleStorage", function() { EmbarkSpec.deployAll(contractsConfig, () => { done() }); }); - it("should set constructor value", function(done) { - SimpleStorage.methods.storedData().call().then(function(result) { - assert.equal(result, 100); - done(); - }); + it("should set constructor value", async function() { + let result = await SimpleStorage.methods.storedData().call(); + assert.equal(result, 100); }); - it("set storage value", function(done) { - SimpleStorage.methods.set(150).send().then(function() { - SimpleStorage.methods.get().call().then(function(result) { - assert.equal(result, 499650); - done(); - }); - }); + it("set storage value", async function() { + await SimpleStorage.methods.set(150).send(); + let result = await SimpleStorage.methods.get().call(); + assert.equal(result, 499650); }); }); diff --git a/test_apps/contracts_app/test/token_spec.js b/test_apps/contracts_app/test/token_spec.js index a8184ac2f..f101a7898 100644 --- a/test_apps/contracts_app/test/token_spec.js +++ b/test_apps/contracts_app/test/token_spec.js @@ -56,41 +56,32 @@ describe("Token", function() { EmbarkSpec.deployAll(contractsConfig, () => { done() }); }); - it("not deploy Token", function(done) { + it("not deploy Token", function() { assert.equal(Token.address, ""); - done(); }); - it("not deploy MyToken and MyToken2", function(done) { + it("not deploy MyToken and MyToken2", function() { assert.notEqual(MyToken.address, ""); assert.notEqual(MyToken2.address, ""); - done(); }); - it("set MyToken Balance correctly", function(done) { - MyToken.methods._supply().call().then(function(result) { - assert.equal(result, 1000); - done(); - }); + it("set MyToken Balance correctly", async function() { + let result = await MyToken.methods._supply().call(); + assert.equal(result, 1000); }); - it("set MyToken2 Balance correctly", function(done) { - MyToken2.methods._supply().call().then(function(result) { - assert.equal(result, 2000); - done(); - }); + it("set MyToken2 Balance correctly", async function() { + let result = await MyToken2.methods._supply().call(); + assert.equal(result, 2000); }); - it("get right address", function(done) { + it("get right address", function() { assert.equal(AlreadyDeployedToken.address, "0xCAFECAFECAFECAFECAFECAFECAFECAFECAFECAFE"); - done(); }); - it("should use onDeploy", function(done) { - Test.methods.addr().call().then(function(result) { - assert.equal(result, MyToken.address) - done(); - }); + it("should use onDeploy", async function() { + let result = await Test.methods.addr().call(); + assert.equal(result, MyToken.address) }); }); diff --git a/test_apps/test_app/embark.json b/test_apps/test_app/embark.json index 8459e8afc..0d56876bb 100644 --- a/test_apps/test_app/embark.json +++ b/test_apps/test_app/embark.json @@ -15,7 +15,6 @@ "buildDir": "dist/", "config": "config/", "versions": { - "web3.js": "1.0.0-beta.27", "solc": "0.4.18", "ipfs-api": "17.2.6" }, diff --git a/test_apps/test_app/test/another_storage_spec.js b/test_apps/test_app/test/another_storage_spec.js index d34c3e720..255a5d4b8 100644 --- a/test_apps/test_app/test/another_storage_spec.js +++ b/test_apps/test_app/test/another_storage_spec.js @@ -13,11 +13,9 @@ contract("AnotherStorage", function() { EmbarkSpec.deployAll(contractsConfig, () => { done() }); }); - it("set SimpleStorage address", function(done) { - AnotherStorage.methods.simpleStorageAddress().call().then(function(result) { - assert.equal(result.toString(), SimpleStorage.options.address); - done(); - }); + it("set SimpleStorage address", async function() { + let result = await AnotherStorage.methods.simpleStorageAddress().call(); + assert.equal(result.toString(), SimpleStorage.options.address); }); }); diff --git a/test_apps/test_app/test/array_references_spec.js b/test_apps/test_app/test/array_references_spec.js index 1492009b2..99cf37da9 100644 --- a/test_apps/test_app/test/array_references_spec.js +++ b/test_apps/test_app/test/array_references_spec.js @@ -24,18 +24,14 @@ contract("SomeContract", function() { EmbarkSpec.deployAll(contractsConfig, () => { done() }); }); - it("set MyToken2 address", function(done) { - SomeContract.methods.addr_1().call().then(function(address) { - assert.equal(address, MyToken2.options.address); - done(); - }); + it("set MyToken2 address", async function() { + let address = await SomeContract.methods.addr_1().call(); + assert.equal(address, MyToken2.options.address); }); - it("set SimpleStorage address", function(done) { - SomeContract.methods.addr_2().call().then(function(address) { - assert.equal(address, SimpleStorage.options.address); - done(); - }); + it("set SimpleStorage address", async function() { + let address = await SomeContract.methods.addr_2().call(); + assert.equal(address, SimpleStorage.options.address); }); }); diff --git a/test_apps/test_app/test/lib_test_spec.js b/test_apps/test_app/test/lib_test_spec.js index e039dc621..18aef2c9f 100644 --- a/test_apps/test_app/test/lib_test_spec.js +++ b/test_apps/test_app/test/lib_test_spec.js @@ -14,11 +14,9 @@ contract("Test", function() { EmbarkSpec.deployAll(contractsConfig, () => { done() }); }); - it("should call library correctly", function(done) { - Test2.methods.testAdd().call().then(function(result) { - assert.equal(result, 3); - done(); - }); + it("should call library correctly", async function() { + let result = await Test2.methods.testAdd().call(); + assert.equal(result, 3); }); }); diff --git a/test_apps/test_app/test/simple_storage_spec.js b/test_apps/test_app/test/simple_storage_spec.js index 6d16e7b8d..b43e0b354 100644 --- a/test_apps/test_app/test/simple_storage_spec.js +++ b/test_apps/test_app/test/simple_storage_spec.js @@ -17,20 +17,15 @@ contract("SimpleStorage", function() { EmbarkSpec.deployAll(contractsConfig, () => { done() }); }); - it("should set constructor value", function(done) { - SimpleStorage.methods.storedData().call().then(function(result) { - assert.equal(result, 100); - done(); - }); + it("should set constructor value", async function() { + let result = await SimpleStorage.methods.storedData().call(); + assert.equal(result, 100); }); - it("set storage value", function(done) { - SimpleStorage.methods.set(150).send().then(function() { - SimpleStorage.methods.get().call().then(function(result) { - assert.equal(result, 499650); - done(); - }); - }); + it("set storage value", async function() { + await SimpleStorage.methods.set(150).send(); + let result = await SimpleStorage.methods.get().call(); + assert.equal(result, 499650); }); }); diff --git a/test_apps/test_app/test/token_spec.js b/test_apps/test_app/test/token_spec.js index a8184ac2f..f101a7898 100644 --- a/test_apps/test_app/test/token_spec.js +++ b/test_apps/test_app/test/token_spec.js @@ -56,41 +56,32 @@ describe("Token", function() { EmbarkSpec.deployAll(contractsConfig, () => { done() }); }); - it("not deploy Token", function(done) { + it("not deploy Token", function() { assert.equal(Token.address, ""); - done(); }); - it("not deploy MyToken and MyToken2", function(done) { + it("not deploy MyToken and MyToken2", function() { assert.notEqual(MyToken.address, ""); assert.notEqual(MyToken2.address, ""); - done(); }); - it("set MyToken Balance correctly", function(done) { - MyToken.methods._supply().call().then(function(result) { - assert.equal(result, 1000); - done(); - }); + it("set MyToken Balance correctly", async function() { + let result = await MyToken.methods._supply().call(); + assert.equal(result, 1000); }); - it("set MyToken2 Balance correctly", function(done) { - MyToken2.methods._supply().call().then(function(result) { - assert.equal(result, 2000); - done(); - }); + it("set MyToken2 Balance correctly", async function() { + let result = await MyToken2.methods._supply().call(); + assert.equal(result, 2000); }); - it("get right address", function(done) { + it("get right address", function() { assert.equal(AlreadyDeployedToken.address, "0xCAFECAFECAFECAFECAFECAFECAFECAFECAFECAFE"); - done(); }); - it("should use onDeploy", function(done) { - Test.methods.addr().call().then(function(result) { - assert.equal(result, MyToken.address) - done(); - }); + it("should use onDeploy", async function() { + let result = await Test.methods.addr().call(); + assert.equal(result, MyToken.address) }); });