2019-11-07 15:59:26 +00:00
|
|
|
/*global describe, config, it, web3*/
|
2018-06-01 14:48:29 +00:00
|
|
|
const assert = require('assert');
|
2018-06-07 20:14:42 +00:00
|
|
|
const Token = require('Embark/contracts/Token');
|
|
|
|
const MyToken = require('Embark/contracts/MyToken');
|
|
|
|
const MyToken2 = require('Embark/contracts/MyToken2');
|
|
|
|
const AlreadyDeployedToken = require('Embark/contracts/AlreadyDeployedToken');
|
|
|
|
const Test = require('Embark/contracts/Test');
|
2018-08-24 13:12:31 +00:00
|
|
|
const SomeContract = require('Embark/contracts/SomeContract');
|
2018-01-15 14:51:45 +00:00
|
|
|
|
2018-06-01 14:48:29 +00:00
|
|
|
config({
|
2020-01-16 15:39:01 +00:00
|
|
|
namesystem: {
|
|
|
|
enabled: true,
|
|
|
|
register: {
|
|
|
|
rootDomain: "embark.eth"
|
|
|
|
}
|
|
|
|
},
|
2018-06-01 14:48:29 +00:00
|
|
|
contracts: {
|
2019-08-30 20:50:20 +00:00
|
|
|
deploy: {
|
|
|
|
ZAMyLib: {},
|
|
|
|
SimpleStorage: {
|
|
|
|
args: [100]
|
|
|
|
},
|
|
|
|
AnotherStorage: {
|
|
|
|
args: ["$SimpleStorage"]
|
|
|
|
},
|
|
|
|
Token: {
|
|
|
|
deploy: false,
|
|
|
|
args: [1000]
|
|
|
|
},
|
|
|
|
MyToken: {
|
|
|
|
instanceOf: "Token"
|
|
|
|
},
|
|
|
|
MyToken2: {
|
|
|
|
instanceOf: "Token",
|
|
|
|
args: [2000]
|
|
|
|
},
|
|
|
|
AlreadyDeployedToken: {
|
|
|
|
address: "0xCAFECAFECAFECAFECAFECAFECAFECAFECAFECAFE",
|
|
|
|
instanceOf: "Token"
|
|
|
|
},
|
|
|
|
Test: {
|
|
|
|
onDeploy: ["Test.methods.changeAddress('$MyToken').send()", "Test.methods.changeENS('embark.eth').send()"]
|
|
|
|
},
|
|
|
|
ContractArgs: {
|
|
|
|
args: {
|
|
|
|
initialValue: 123,
|
|
|
|
_addresses: ["$MyToken2", "$SimpleStorage"]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
SomeContract: {
|
2019-10-23 18:58:40 +00:00
|
|
|
deployIf: (dependencies) => {
|
2019-10-29 15:50:32 +00:00
|
|
|
return dependencies.contracts.MyToken.methods.isAvailable().call();
|
2019-10-23 18:58:40 +00:00
|
|
|
},
|
2019-08-30 20:50:20 +00:00
|
|
|
args: [
|
|
|
|
["$MyToken2", "$SimpleStorage"],
|
|
|
|
100
|
|
|
|
]
|
2018-06-01 14:48:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2018-01-15 14:51:45 +00:00
|
|
|
|
2019-07-17 16:32:53 +00:00
|
|
|
describe("Token", function() {
|
2018-01-05 20:10:47 +00:00
|
|
|
this.timeout(0);
|
2018-01-15 14:51:45 +00:00
|
|
|
|
2019-07-17 16:32:53 +00:00
|
|
|
describe('Token Contract', function() {
|
|
|
|
it("not deploy Token", function() {
|
|
|
|
assert.strictEqual(Token.address, undefined);
|
|
|
|
});
|
2017-02-10 02:05:45 +00:00
|
|
|
});
|
|
|
|
|
2019-07-17 16:32:53 +00:00
|
|
|
describe('MyToken Contracts', function() {
|
|
|
|
it("should deploy MyToken and MyToken2", function() {
|
|
|
|
assert.ok(MyToken.options.address);
|
|
|
|
assert.ok(MyToken2.options.address);
|
|
|
|
});
|
2017-02-10 02:05:45 +00:00
|
|
|
|
2019-07-17 16:32:53 +00:00
|
|
|
it("set MyToken Balance correctly", async function() {
|
2019-10-22 13:27:22 +00:00
|
|
|
const result = await MyToken.methods._supply().call();
|
2019-07-17 16:32:53 +00:00
|
|
|
assert.strictEqual(parseInt(result, 10), 1000);
|
|
|
|
});
|
2017-02-10 02:05:45 +00:00
|
|
|
|
2019-07-17 16:32:53 +00:00
|
|
|
it("set MyToken2 Balance correctly", async function() {
|
2019-10-22 13:27:22 +00:00
|
|
|
const result = await MyToken2.methods._supply().call();
|
2019-07-17 16:32:53 +00:00
|
|
|
assert.strictEqual(parseInt(result, 10), 2000);
|
|
|
|
});
|
2017-02-10 02:05:45 +00:00
|
|
|
});
|
|
|
|
|
2019-10-22 13:27:22 +00:00
|
|
|
describe('Other Contracts', function() {
|
2019-07-17 16:32:53 +00:00
|
|
|
it("get right address", function() {
|
|
|
|
assert.strictEqual(AlreadyDeployedToken.options.address.toLowerCase(),
|
|
|
|
"0xCAFECAFECAFECAFECAFECAFECAFECAFECAFECAFE".toLowerCase());
|
|
|
|
});
|
2017-02-10 02:05:45 +00:00
|
|
|
|
2019-07-17 16:32:53 +00:00
|
|
|
it("should use onDeploy", async function() {
|
2019-10-22 13:27:22 +00:00
|
|
|
const result = await Test.methods.addr().call();
|
2019-07-17 16:32:53 +00:00
|
|
|
assert.strictEqual(result, MyToken.options.address);
|
|
|
|
});
|
2018-08-24 13:12:31 +00:00
|
|
|
|
2019-10-29 15:50:32 +00:00
|
|
|
it("should not deploy if deployIf returns false", function() {
|
2019-07-17 16:32:53 +00:00
|
|
|
assert.ok(!SomeContract.options.address);
|
|
|
|
});
|
2018-10-18 14:59:12 +00:00
|
|
|
|
2019-11-07 15:59:26 +00:00
|
|
|
it("should set the ens attr to the address of embark.eth", async function() {
|
2019-10-22 13:27:22 +00:00
|
|
|
const result = await Test.methods.ens().call();
|
2019-07-17 16:32:53 +00:00
|
|
|
// Testing that it is an address as we don't really know the address
|
|
|
|
assert.strictEqual(web3.utils.isAddress(result), true);
|
|
|
|
assert.notStrictEqual(result, '0x0000000000000000000000000000000000000000');
|
|
|
|
});
|
2018-10-18 14:59:12 +00:00
|
|
|
});
|
2017-02-10 02:05:45 +00:00
|
|
|
});
|