Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // `evm_` ONLY works in the testrpc `development` env
- // `evm_mine` is not a standard web3/eth call
- function advanceBlock() {
- return new Promise(resolve => {
- web3.currentProvider.sendAsync({
- method: "evm_mine",
- jsonrpc: "2.0",
- id: new Date().getTime()
- }, function (error, result) {
- if (error) {
- console.log('Could not advance block :: ', error)
- } else {
- console.log('Advance to block :: ', web3.eth.blockNumber, result.id);
- resolve(result);
- }
- });
- });
- }
- // usage
- it("should have owner", function(done) {
- MyContract.deployed().then(function(instance) {
- return instance.owner.call();
- }).then(function(results) {
- assert.equal(results, accounts[0], "does not match creater etherbase/accounts[0]");
- // => block 1
- return advanceBlock();
- }).then(function(results) {
- // check id of sendAsync
- // `results.id`
- done();
- }).catch(done);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement