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) {
|
2017-03-12 02:49:12 +00:00
|
|
|
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 = {
|
|
|
|
"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
|
|
|
]
|
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) {
|
2017-10-17 10:51:52 +00:00
|
|
|
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
|
|
|
});
|