add test to controlled, use "Contract" as generic name
This commit is contained in:
parent
1582881629
commit
9f97714ba5
|
@ -0,0 +1,29 @@
|
||||||
|
|
||||||
|
exports.Test = (contractsConfig, afterDeploy) => {
|
||||||
|
|
||||||
|
describe("Controlled", async function() {
|
||||||
|
this.timeout(0);
|
||||||
|
var Controlled;
|
||||||
|
var accountsArr;
|
||||||
|
before(function(done) {
|
||||||
|
EmbarkSpec.deployAll(contractsConfig, async function(accounts) {
|
||||||
|
Controlled = Contract;
|
||||||
|
accountsArr = accounts;
|
||||||
|
await afterDeploy(accounts, Contract);
|
||||||
|
done()
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it("should start with msg.sender as controller", async function() {
|
||||||
|
var controller = await Controlled.methods.controller().call();
|
||||||
|
assert(controller, accountsArr[0]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should allow controller to set new controller", async function() {
|
||||||
|
await Controlled.methods.changeController(accountsArr[1]).send({from: accountsArr[0]});
|
||||||
|
var controller = await Controlled.methods.controller().call();
|
||||||
|
assert(controller, accountsArr[1]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
|
@ -1,18 +1,18 @@
|
||||||
|
|
||||||
exports.Test = (contractsConfig, afterDeploy) => {
|
exports.Test = (contractsConfig, afterDeploy) => {
|
||||||
describe("ERC20Token", async function() {
|
describe("ERC20Token", async function() {
|
||||||
this.timeout(0);
|
this.timeout(0);
|
||||||
var ERC20Token;
|
var ERC20Token;
|
||||||
var accountsArr;
|
var accountsArr;
|
||||||
before(function(done) {
|
before(function(done) {
|
||||||
contractsConfig["ERC20Receiver"] = {};
|
contractsConfig["ERC20Receiver"] = {};
|
||||||
EmbarkSpec.deployAll(contractsConfig, async function(accounts) {
|
EmbarkSpec.deployAll(contractsConfig, async function(accounts) {
|
||||||
ERC20Token = Token;
|
ERC20Token = Contract;
|
||||||
accountsArr = accounts;
|
accountsArr = accounts;
|
||||||
await afterDeploy(accounts, Token);
|
await afterDeploy(accounts, Contract);
|
||||||
done()
|
done()
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
it("should transfer 1 token", async function() {
|
it("should transfer 1 token", async function() {
|
||||||
let initialBalance0 = await ERC20Token.methods.balanceOf(accountsArr[0]).call();
|
let initialBalance0 = await ERC20Token.methods.balanceOf(accountsArr[0]).call();
|
||||||
|
|
|
@ -29,7 +29,7 @@ describe("TestToken", async function() {
|
||||||
assert.equal(result, +initialBalance+100);
|
assert.equal(result, +initialBalance+100);
|
||||||
});
|
});
|
||||||
var erc20tokenConfig = {
|
var erc20tokenConfig = {
|
||||||
"Token": { "instanceOf" : "TestToken" }
|
"Contract": { "instanceOf" : "TestToken" }
|
||||||
}
|
}
|
||||||
ERC20Token.Test(erc20tokenConfig, async function (accounts, TestToken) {
|
ERC20Token.Test(erc20tokenConfig, async function (accounts, TestToken) {
|
||||||
for(i=0;i<accounts.length;i++){
|
for(i=0;i<accounts.length;i++){
|
||||||
|
|
Loading…
Reference in New Issue