aboutsummaryrefslogblamecommitdiffstats
path: root/RPCTests/scripts/test00_node02_AddPeer.js
blob: 233648dc3e3e5558b24b68704ecac58f7f4ca507 (plain) (tree)

























                                                                                                                                 
process.stdout.write("TEST_addPeerOnNode2 ");
var onResult = {};
web3.admin.addPeer("enode://" + args["node1_ID"] + "@127.0.0.1:" + args["node1_port"], function(err, res){ onResult(err, res); })

function sleep(ms) {
   return new Promise(resolve => setTimeout(resolve, ms));
}

var onGetPeerCount = {};
onResult = function (err,res) 
{
   //wait for peer being added
   sleep(1000).then(() => {
    web3.net.getPeerCount(function(err, res){ onGetPeerCount(err, res); })
   });
}

onGetPeerCount = function (err, res)
{
   if (res == 1)
    console.log("OK");
   else
    console.log("FAILED");
   callback(err, res);
}