Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. // `evm_` ONLY works in the testrpc `development` env
  2. // `evm_mine` is not a standard web3/eth call
  3. function advanceBlock() {
  4. return new Promise(resolve => {
  5. web3.currentProvider.sendAsync({
  6. method: "evm_mine",
  7. jsonrpc: "2.0",
  8. id: new Date().getTime()
  9. }, function (error, result) {
  10. if (error) {
  11. console.log('Could not advance block :: ', error)
  12. } else {
  13. console.log('Advance to block :: ', web3.eth.blockNumber, result.id);
  14. resolve(result);
  15. }
  16. });
  17. });
  18. }
  19.  
  20.  
  21. // usage
  22. it("should have owner", function(done) {
  23. MyContract.deployed().then(function(instance) {
  24. return instance.owner.call();
  25. }).then(function(results) {
  26. assert.equal(results, accounts[0], "does not match creater etherbase/accounts[0]");
  27.  
  28. // => block 1
  29. return advanceBlock();
  30. }).then(function(results) {
  31. // check id of sendAsync
  32. // `results.id`
  33. done();
  34. }).catch(done);
  35. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement