embark/test_apps/contracts_app/test/token_spec.js

88 lines
1.9 KiB
JavaScript
Raw Normal View History

2018-01-15 14:51:45 +00:00
2017-02-10 02:05:45 +00:00
describe("Token", function() {
2018-01-15 14:51:45 +00:00
2018-01-05 20:10:47 +00:00
this.timeout(0);
2017-02-10 02:05:45 +00:00
before(function(done) {
this.timeout(0);
2018-01-15 14:51:45 +00:00
//config({
// node: "http://localhost:8545"
//});
2017-02-10 02:05:45 +00:00
var contractsConfig = {
"ZAMyLib": {
},
"Token": {
},
2017-02-10 02:05:45 +00:00
"SimpleStorage": {
args: [100]
},
"AnotherStorage": {
args: ["$SimpleStorage"]
},
"Token": {
deploy: false,
args: [1000]
},
"MyToken": {
instanceOf: "Token"
},
"MyToken2": {
instanceOf: "Token",
args: [2000]
},
"AlreadyDeployedToken": {
2018-01-05 20:10:47 +00:00
"address": "0xCAFECAFECAFECAFECAFECAFECAFECAFECAFECAFE",
2017-02-10 02:05:45 +00:00
instanceOf: "Token"
2017-12-20 19:09:35 +00:00
},
"Test": {
onDeploy: [
2018-01-12 23:08:44 +00:00
"Test.methods.changeAddress('$MyToken').send()"
2017-12-20 19:09:35 +00:00
]
},
2018-03-10 17:52:37 +00:00
"ContractArgs": {
"args": {
"initialValue": 123,
"_addresses": ["$MyToken2", "$SimpleStorage"]
}
},
"SomeContract": {
"args": [
["$MyToken2", "$SimpleStorage"],
100
]
2017-02-10 02:05:45 +00:00
}
};
2017-12-22 18:07:43 +00:00
EmbarkSpec.deployAll(contractsConfig, () => { done() });
2017-02-10 02:05:45 +00:00
});
2018-04-17 18:48:31 +00:00
it("not deploy Token", function() {
assert.equal(Token.address, "");
2017-02-10 02:05:45 +00:00
});
2018-04-17 18:48:31 +00:00
it("not deploy MyToken and MyToken2", function() {
2018-01-05 20:10:47 +00:00
assert.notEqual(MyToken.address, "");
assert.notEqual(MyToken2.address, "");
2017-02-10 02:05:45 +00:00
});
2018-04-17 18:48:31 +00:00
it("set MyToken Balance correctly", async function() {
let result = await MyToken.methods._supply().call();
assert.equal(result, 1000);
2017-02-10 02:05:45 +00:00
});
2018-04-17 18:48:31 +00:00
it("set MyToken2 Balance correctly", async function() {
let result = await MyToken2.methods._supply().call();
assert.equal(result, 2000);
2017-02-10 02:05:45 +00:00
});
2018-04-17 18:48:31 +00:00
it("get right address", function() {
2018-01-05 20:10:47 +00:00
assert.equal(AlreadyDeployedToken.address, "0xCAFECAFECAFECAFECAFECAFECAFECAFECAFECAFE");
2017-02-10 02:05:45 +00:00
});
2018-04-17 18:48:31 +00:00
it("should use onDeploy", async function() {
let result = await Test.methods.addr().call();
assert.equal(result, MyToken.address)
2017-12-20 19:09:35 +00:00
});
2017-02-10 02:05:45 +00:00
});