use object assign to assign new values to contract
This commit is contained in:
parent
89e0d39742
commit
99fd1be986
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue