mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-02-18 18:26:50 +00:00
convert example tests to use await
This commit is contained in:
parent
1415ce0d62
commit
424c7afc70
@ -10,20 +10,15 @@
|
|||||||
// EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
// EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
||||||
// });
|
// });
|
||||||
//
|
//
|
||||||
// it("should set constructor value", function(done) {
|
// it("should set constructor value", async function() {
|
||||||
// SimpleStorage.methods.storedData().call().then(function(result) {
|
// let result = await SimpleStorage.methods.storedData().call();
|
||||||
// assert.equal(result, 100);
|
// assert.equal(result, 100);
|
||||||
// done();
|
|
||||||
// });
|
|
||||||
// });
|
// });
|
||||||
//
|
//
|
||||||
// it("set storage value", function(done) {
|
// it("set storage value", async function() {
|
||||||
// SimpleStorage.methods.set(150).send().then(function() {
|
// await SimpleStorage.methods.set(150).send();
|
||||||
// SimpleStorage.methods.get().call().then(function(result) {
|
// let result = await SimpleStorage.methods.get().call();
|
||||||
// assert.equal(result, 150);
|
// assert.equal(result, 150);
|
||||||
// done();
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// });
|
// });
|
||||||
//
|
//
|
||||||
//});
|
//});
|
||||||
|
@ -10,20 +10,15 @@ describe("SimpleStorage", function() {
|
|||||||
EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should set constructor value", function(done) {
|
it("should set constructor value", async function() {
|
||||||
SimpleStorage.methods.storedData().call().then(function(result) {
|
let result = await SimpleStorage.methods.storedData().call();
|
||||||
assert.equal(result, 100);
|
assert.equal(result, 100);
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("set storage value", function(done) {
|
it("set storage value", async function() {
|
||||||
SimpleStorage.methods.set(150).send().then(function() {
|
await SimpleStorage.methods.set(150).send();
|
||||||
SimpleStorage.methods.get().call().then(function(result) {
|
let result = SimpleStorage.methods.get().call();
|
||||||
assert.equal(result, 150);
|
assert.equal(result, 150);
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -10,20 +10,15 @@
|
|||||||
// EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
// EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
||||||
// });
|
// });
|
||||||
//
|
//
|
||||||
// it("should set constructor value", function(done) {
|
// it("should set constructor value", async function() {
|
||||||
// SimpleStorage.methods.storedData().call().then(function(result) {
|
// let result = await SimpleStorage.methods.storedData().call();
|
||||||
// assert.equal(result, 100);
|
// assert.equal(result, 100);
|
||||||
// done();
|
|
||||||
// });
|
|
||||||
// });
|
// });
|
||||||
//
|
//
|
||||||
// it("set storage value", function(done) {
|
// it("set storage value", async function() {
|
||||||
// SimpleStorage.methods.set(150).send().then(function() {
|
// await SimpleStorage.methods.set(150).send();
|
||||||
// SimpleStorage.methods.get().call().then(function(result) {
|
// let result = await SimpleStorage.methods.get().call();
|
||||||
// assert.equal(result, 150);
|
// assert.equal(result, 150);
|
||||||
// done();
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// });
|
// });
|
||||||
//
|
//
|
||||||
//});
|
//});
|
||||||
|
@ -13,11 +13,9 @@ contract("AnotherStorage", function() {
|
|||||||
EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("set SimpleStorage address", function(done) {
|
it("set SimpleStorage address", async function() {
|
||||||
AnotherStorage.methods.simpleStorageAddress().call().then(function(result) {
|
let result = await AnotherStorage.methods.simpleStorageAddress().call();
|
||||||
assert.equal(result.toString(), SimpleStorage.options.address);
|
assert.equal(result.toString(), SimpleStorage.options.address);
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -24,18 +24,14 @@ contract("SomeContract", function() {
|
|||||||
EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("set MyToken2 address", function(done) {
|
it("set MyToken2 address", async function() {
|
||||||
SomeContract.methods.addr_1().call().then(function(address) {
|
let address = await SomeContract.methods.addr_1().call();
|
||||||
assert.equal(address, MyToken2.options.address);
|
assert.equal(address, MyToken2.options.address);
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("set SimpleStorage address", function(done) {
|
it("set SimpleStorage address", async function() {
|
||||||
SomeContract.methods.addr_2().call().then(function(address) {
|
let address = await SomeContract.methods.addr_2().call();
|
||||||
assert.equal(address, SimpleStorage.options.address);
|
assert.equal(address, SimpleStorage.options.address);
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -14,11 +14,9 @@ contract("Test", function() {
|
|||||||
EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should call library correctly", function(done) {
|
it("should call library correctly", async function() {
|
||||||
Test2.methods.testAdd().call().then(function(result) {
|
let result = await Test2.methods.testAdd().call();
|
||||||
assert.equal(result, 3);
|
assert.equal(result, 3);
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -17,20 +17,15 @@ contract("SimpleStorage", function() {
|
|||||||
EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should set constructor value", function(done) {
|
it("should set constructor value", async function() {
|
||||||
SimpleStorage.methods.storedData().call().then(function(result) {
|
let result = await SimpleStorage.methods.storedData().call();
|
||||||
assert.equal(result, 100);
|
assert.equal(result, 100);
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("set storage value", function(done) {
|
it("set storage value", async function() {
|
||||||
SimpleStorage.methods.set(150).send().then(function() {
|
await SimpleStorage.methods.set(150).send();
|
||||||
SimpleStorage.methods.get().call().then(function(result) {
|
let result = await SimpleStorage.methods.get().call();
|
||||||
assert.equal(result, 499650);
|
assert.equal(result, 499650);
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -56,41 +56,32 @@ describe("Token", function() {
|
|||||||
EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("not deploy Token", function(done) {
|
it("not deploy Token", function() {
|
||||||
assert.equal(Token.address, "");
|
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(MyToken.address, "");
|
||||||
assert.notEqual(MyToken2.address, "");
|
assert.notEqual(MyToken2.address, "");
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("set MyToken Balance correctly", function(done) {
|
it("set MyToken Balance correctly", async function() {
|
||||||
MyToken.methods._supply().call().then(function(result) {
|
let result = await MyToken.methods._supply().call();
|
||||||
assert.equal(result, 1000);
|
assert.equal(result, 1000);
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("set MyToken2 Balance correctly", function(done) {
|
it("set MyToken2 Balance correctly", async function() {
|
||||||
MyToken2.methods._supply().call().then(function(result) {
|
let result = await MyToken2.methods._supply().call();
|
||||||
assert.equal(result, 2000);
|
assert.equal(result, 2000);
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("get right address", function(done) {
|
it("get right address", function() {
|
||||||
assert.equal(AlreadyDeployedToken.address, "0xCAFECAFECAFECAFECAFECAFECAFECAFECAFECAFE");
|
assert.equal(AlreadyDeployedToken.address, "0xCAFECAFECAFECAFECAFECAFECAFECAFECAFECAFE");
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should use onDeploy", function(done) {
|
it("should use onDeploy", async function() {
|
||||||
Test.methods.addr().call().then(function(result) {
|
let result = await Test.methods.addr().call();
|
||||||
assert.equal(result, MyToken.address)
|
assert.equal(result, MyToken.address)
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
"buildDir": "dist/",
|
"buildDir": "dist/",
|
||||||
"config": "config/",
|
"config": "config/",
|
||||||
"versions": {
|
"versions": {
|
||||||
"web3.js": "1.0.0-beta.27",
|
|
||||||
"solc": "0.4.18",
|
"solc": "0.4.18",
|
||||||
"ipfs-api": "17.2.6"
|
"ipfs-api": "17.2.6"
|
||||||
},
|
},
|
||||||
|
@ -13,11 +13,9 @@ contract("AnotherStorage", function() {
|
|||||||
EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("set SimpleStorage address", function(done) {
|
it("set SimpleStorage address", async function() {
|
||||||
AnotherStorage.methods.simpleStorageAddress().call().then(function(result) {
|
let result = await AnotherStorage.methods.simpleStorageAddress().call();
|
||||||
assert.equal(result.toString(), SimpleStorage.options.address);
|
assert.equal(result.toString(), SimpleStorage.options.address);
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -24,18 +24,14 @@ contract("SomeContract", function() {
|
|||||||
EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("set MyToken2 address", function(done) {
|
it("set MyToken2 address", async function() {
|
||||||
SomeContract.methods.addr_1().call().then(function(address) {
|
let address = await SomeContract.methods.addr_1().call();
|
||||||
assert.equal(address, MyToken2.options.address);
|
assert.equal(address, MyToken2.options.address);
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("set SimpleStorage address", function(done) {
|
it("set SimpleStorage address", async function() {
|
||||||
SomeContract.methods.addr_2().call().then(function(address) {
|
let address = await SomeContract.methods.addr_2().call();
|
||||||
assert.equal(address, SimpleStorage.options.address);
|
assert.equal(address, SimpleStorage.options.address);
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -14,11 +14,9 @@ contract("Test", function() {
|
|||||||
EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should call library correctly", function(done) {
|
it("should call library correctly", async function() {
|
||||||
Test2.methods.testAdd().call().then(function(result) {
|
let result = await Test2.methods.testAdd().call();
|
||||||
assert.equal(result, 3);
|
assert.equal(result, 3);
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -17,20 +17,15 @@ contract("SimpleStorage", function() {
|
|||||||
EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should set constructor value", function(done) {
|
it("should set constructor value", async function() {
|
||||||
SimpleStorage.methods.storedData().call().then(function(result) {
|
let result = await SimpleStorage.methods.storedData().call();
|
||||||
assert.equal(result, 100);
|
assert.equal(result, 100);
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("set storage value", function(done) {
|
it("set storage value", async function() {
|
||||||
SimpleStorage.methods.set(150).send().then(function() {
|
await SimpleStorage.methods.set(150).send();
|
||||||
SimpleStorage.methods.get().call().then(function(result) {
|
let result = await SimpleStorage.methods.get().call();
|
||||||
assert.equal(result, 499650);
|
assert.equal(result, 499650);
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -56,41 +56,32 @@ describe("Token", function() {
|
|||||||
EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("not deploy Token", function(done) {
|
it("not deploy Token", function() {
|
||||||
assert.equal(Token.address, "");
|
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(MyToken.address, "");
|
||||||
assert.notEqual(MyToken2.address, "");
|
assert.notEqual(MyToken2.address, "");
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("set MyToken Balance correctly", function(done) {
|
it("set MyToken Balance correctly", async function() {
|
||||||
MyToken.methods._supply().call().then(function(result) {
|
let result = await MyToken.methods._supply().call();
|
||||||
assert.equal(result, 1000);
|
assert.equal(result, 1000);
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("set MyToken2 Balance correctly", function(done) {
|
it("set MyToken2 Balance correctly", async function() {
|
||||||
MyToken2.methods._supply().call().then(function(result) {
|
let result = await MyToken2.methods._supply().call();
|
||||||
assert.equal(result, 2000);
|
assert.equal(result, 2000);
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("get right address", function(done) {
|
it("get right address", function() {
|
||||||
assert.equal(AlreadyDeployedToken.address, "0xCAFECAFECAFECAFECAFECAFECAFECAFECAFECAFE");
|
assert.equal(AlreadyDeployedToken.address, "0xCAFECAFECAFECAFECAFECAFECAFECAFECAFECAFE");
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should use onDeploy", function(done) {
|
it("should use onDeploy", async function() {
|
||||||
Test.methods.addr().call().then(function(result) {
|
let result = await Test.methods.addr().call();
|
||||||
assert.equal(result, MyToken.address)
|
assert.equal(result, MyToken.address)
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user