embark/test_apps/contracts_app/test/token_spec.js

97 lines
2.1 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
});
it("not deploy Token", function(done) {
assert.equal(Token.address, "");
2017-02-10 02:05:45 +00:00
done();
});
it("not deploy MyToken and MyToken2", function(done) {
2018-01-05 20:10:47 +00:00
assert.notEqual(MyToken.address, "");
assert.notEqual(MyToken2.address, "");
2017-02-10 02:05:45 +00:00
done();
});
it("set MyToken Balance correctly", function(done) {
2018-01-05 20:10:47 +00:00
MyToken.methods._supply().call().then(function(result) {
assert.equal(result, 1000);
done();
});
2017-02-10 02:05:45 +00:00
});
it("set MyToken2 Balance correctly", function(done) {
2018-01-05 20:10:47 +00:00
MyToken2.methods._supply().call().then(function(result) {
assert.equal(result, 2000);
done();
});
2017-02-10 02:05:45 +00:00
});
it("get right address", function(done) {
2018-01-05 20:10:47 +00:00
assert.equal(AlreadyDeployedToken.address, "0xCAFECAFECAFECAFECAFECAFECAFECAFECAFECAFE");
2017-02-10 02:05:45 +00:00
done();
});
2017-12-20 19:09:35 +00:00
it("should use onDeploy", function(done) {
2018-01-05 20:10:47 +00:00
Test.methods.addr().call().then(function(result) {
2017-12-20 19:09:35 +00:00
assert.equal(result, MyToken.address)
done();
});
});
2017-02-10 02:05:45 +00:00
});