diff options
Diffstat (limited to 'RPCTests/scripts/tests/MineBlocks2')
-rw-r--r-- | RPCTests/scripts/tests/MineBlocks2/step00_node02_mineBlocks.js | 31 | ||||
-rw-r--r-- | RPCTests/scripts/tests/MineBlocks2/step01_node01_getBlockHash.js | 13 |
2 files changed, 44 insertions, 0 deletions
diff --git a/RPCTests/scripts/tests/MineBlocks2/step00_node02_mineBlocks.js b/RPCTests/scripts/tests/MineBlocks2/step00_node02_mineBlocks.js new file mode 100644 index 000000000..70936cc41 --- /dev/null +++ b/RPCTests/scripts/tests/MineBlocks2/step00_node02_mineBlocks.js @@ -0,0 +1,31 @@ +process.stdout.write("TEST_mineBlockOnNode2 "); + +var latestBlock; +web3.eth.getBlockNumber(function(err, res){ onGetBlockNumber1(err, res); }) +onGetBlockNumber1 = function (err, res) +{ + latestBlock = res; + web3.test.mineBlocks(1, function(err, res){ onResult(err, res); }) +} + + +onResult = function (err,res) +{ + function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + + //wait for block being mined and propagated + sleep(1000).then(() => { + web3.eth.getBlockNumber(function(err, res){ onGetBlockNumber(err, res); }) + }); +} + +onGetBlockNumber = function (err, res) +{ + if (res == latestBlock + 1) + console.log("OK"); + else + console.log("FAILED"); + callback(err, res); +} diff --git a/RPCTests/scripts/tests/MineBlocks2/step01_node01_getBlockHash.js b/RPCTests/scripts/tests/MineBlocks2/step01_node01_getBlockHash.js new file mode 100644 index 000000000..d3a3b0bbf --- /dev/null +++ b/RPCTests/scripts/tests/MineBlocks2/step01_node01_getBlockHash.js @@ -0,0 +1,13 @@ +process.stdout.write("TEST_getBlockHashOnNode1 "); + +var onResult = {}; +web3.eth.getBlock("latest", function(err, res){ onResult(err, res); }) + +onResult = function (err,res) +{ + if (res.hash == args["node2_lastblock"].hash) + console.log("OK"); + else + console.log("FAILED "); + callback(err, res); +} |