Skip to content

Instantly share code, notes, and snippets.

@ValeryDubrava
Created February 15, 2018 13:46
Show Gist options
  • Save ValeryDubrava/dce46f01589518eeb5614bb9bfa84cc6 to your computer and use it in GitHub Desktop.
Save ValeryDubrava/dce46f01589518eeb5614bb9bfa84cc6 to your computer and use it in GitHub Desktop.
it('#24 invoke with gas to invoke returned by top', async () => {
const joule = await createJoule();
const contract100k = await Contract100kGas.new();
const contract300k = await Contract300kGas.new();
const price = await joule.getPrice(gasLimit1, gasPrice1);
await joule.register(contract100k.address, nowPlus3minutes, gasLimit1, gasPrice1, {value: price});
// await joule.unregister(0, contract100k.address, nowPlus3minutes, gasLimit1, gasPrice1);
let count = await joule.getCount();
count.should.be.bignumber.equals(1, "contract must be registered");
await increaseTime(3 * MINUTE + 1);
const top = await joule.getTopOnce();
const invokeGas = top[4];
await joule.invoke({gas: invokeGas});
count = await joule.getCount();
count.should.be.bignumber.equals(0, "contract100 must be invoked!");
const price3 = await joule.getPrice(gasLimit3, gasPrice3);
await joule.register(contract300k.address, nowPlus5minutes, gasLimit3, gasPrice3, {value: price3});
count = await joule.getCount();
count.should.be.bignumber.equals(1, "contract must be registered");
await increaseTime(2 * MINUTE);
const top3 = await joule.getTopOnce();
const invokeGas3 = top3[4];
await joule.invoke({gas: invokeGas3});
count = await joule.getCount();
count.should.be.bignumber.equals(0, "contract300 must be invoked!");
const gasLimit3m = 4000000;
const price3m = await joule.getPrice(gasLimit3m, gasPrice3);
await joule.register(contract300k.address, nowPlus7minutes, gasLimit3m, gasPrice3, {value: price3m});
count = await joule.getCount();
count.should.be.bignumber.equals(1, "contract must be registered");
await increaseTime(2 * MINUTE);
const top3m = await joule.getTopOnce();
const invokeGas3m = top3m[4];
await joule.invoke({gas: invokeGas3m.add(80000)});
count = await joule.getCount();
count.should.be.bignumber.equals(0, "contract3m must be invoked!");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment