diff --git a/lib/tests/test.js b/lib/tests/test.js index 3564459b..5abc3c68 100644 --- a/lib/tests/test.js +++ b/lib/tests/test.js @@ -88,12 +88,6 @@ class Test { next(); }, function deploy(next) { - // self.engine.events.on('code-generator-ready', function () { - // self.engine.events.request('code-generator:contract:vanilla', function(vanillaABI) { - // console.log(vanillaABI); - // }); - // }); - self.engine.deployManager.gasLimit = 6000000; self.engine.contractsManager.gasLimit = 6000000; self.engine.deployManager.fatalErrors = true; @@ -106,7 +100,7 @@ class Test { }); }, function getAccounts(next) { - self.web3.eth.getAccounts(function(err, accounts) { + self.web3.eth.getAccounts(function (err, accounts) { if (err) { return next(err); } @@ -118,8 +112,8 @@ class Test { function createContractObject(next) { async.each(Object.keys(self.contracts), (contractName, eachCb) => { const contract = self.engine.contractsManager.contracts[contractName]; - self.contracts[contractName].contract = new self.web3.eth.Contract(contract.abiDefinition, contract.address, - {from: self.web3.defaultAccount, gas: 6000000}); + Object.assign(self.contracts[contractName], new self.web3.eth.Contract(contract.abiDefinition, contract.address, + {from: self.web3.defaultAccount, gas: 6000000})); eachCb(); }, next); } @@ -142,9 +136,7 @@ class Test { return this.contracts[contractName]; } const contract = this.engine.contractsManager.contracts[contractName]; - this.contracts[contractName] = {}; - // TODO find better way to update contract - this.contracts[contractName].contract = new this.web3.eth.Contract(contract.abiDefinition, contract.address); + this.contracts[contractName] = new this.web3.eth.Contract(contract.abiDefinition, contract.address); return this.contracts[contractName]; } throw new Error(__('Unknown module %s', module)); diff --git a/test_apps/contracts_app/test/simple_storage_spec.js b/test_apps/contracts_app/test/simple_storage_spec.js index 34b73f91..975853e2 100644 --- a/test_apps/contracts_app/test/simple_storage_spec.js +++ b/test_apps/contracts_app/test/simple_storage_spec.js @@ -19,14 +19,14 @@ contract("SimpleStorage", function () { }); it("should set constructor value", async function () { - let result = await SimpleStorage.contract.methods.storedData().call(); + let result = await SimpleStorage.methods.storedData().call(); assert.strictEqual(parseInt(result, 10), 100); }); it("set storage value", async function () { // TODO Solve from - await SimpleStorage.contract.methods.set(150).send({from: web3.eth.defaultAccount}); - let result = await SimpleStorage.contract.methods.get().call(); + await SimpleStorage.methods.set(150).send({from: web3.eth.defaultAccount}); + let result = await SimpleStorage.methods.get().call(); assert.strictEqual(parseInt(result, 10), 499650); });