mirror of https://github.com/embarklabs/embark.git
use object assign to assign new values to contract
This commit is contained in:
parent
8664570d7c
commit
4040c1eec9
|
@ -88,12 +88,6 @@ class Test {
|
||||||
next();
|
next();
|
||||||
},
|
},
|
||||||
function deploy(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.deployManager.gasLimit = 6000000;
|
||||||
self.engine.contractsManager.gasLimit = 6000000;
|
self.engine.contractsManager.gasLimit = 6000000;
|
||||||
self.engine.deployManager.fatalErrors = true;
|
self.engine.deployManager.fatalErrors = true;
|
||||||
|
@ -118,8 +112,8 @@ class Test {
|
||||||
function createContractObject(next) {
|
function createContractObject(next) {
|
||||||
async.each(Object.keys(self.contracts), (contractName, eachCb) => {
|
async.each(Object.keys(self.contracts), (contractName, eachCb) => {
|
||||||
const contract = self.engine.contractsManager.contracts[contractName];
|
const contract = self.engine.contractsManager.contracts[contractName];
|
||||||
self.contracts[contractName].contract = new self.web3.eth.Contract(contract.abiDefinition, contract.address,
|
Object.assign(self.contracts[contractName], new self.web3.eth.Contract(contract.abiDefinition, contract.address,
|
||||||
{from: self.web3.defaultAccount, gas: 6000000});
|
{from: self.web3.defaultAccount, gas: 6000000}));
|
||||||
eachCb();
|
eachCb();
|
||||||
}, next);
|
}, next);
|
||||||
}
|
}
|
||||||
|
@ -142,9 +136,7 @@ class Test {
|
||||||
return this.contracts[contractName];
|
return this.contracts[contractName];
|
||||||
}
|
}
|
||||||
const contract = this.engine.contractsManager.contracts[contractName];
|
const contract = this.engine.contractsManager.contracts[contractName];
|
||||||
this.contracts[contractName] = {};
|
this.contracts[contractName] = new this.web3.eth.Contract(contract.abiDefinition, contract.address);
|
||||||
// TODO find better way to update contract
|
|
||||||
this.contracts[contractName].contract = new this.web3.eth.Contract(contract.abiDefinition, contract.address);
|
|
||||||
return this.contracts[contractName];
|
return this.contracts[contractName];
|
||||||
}
|
}
|
||||||
throw new Error(__('Unknown module %s', module));
|
throw new Error(__('Unknown module %s', module));
|
||||||
|
|
|
@ -19,14 +19,14 @@ contract("SimpleStorage", function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should set constructor value", async 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);
|
assert.strictEqual(parseInt(result, 10), 100);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("set storage value", async function () {
|
it("set storage value", async function () {
|
||||||
// TODO Solve from
|
// TODO Solve from
|
||||||
await SimpleStorage.contract.methods.set(150).send({from: web3.eth.defaultAccount});
|
await SimpleStorage.methods.set(150).send({from: web3.eth.defaultAccount});
|
||||||
let result = await SimpleStorage.contract.methods.get().call();
|
let result = await SimpleStorage.methods.get().call();
|
||||||
assert.strictEqual(parseInt(result, 10), 499650);
|
assert.strictEqual(parseInt(result, 10), 499650);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue