public void AddNodeWithValidNodeThenExecutesSuccessfully() { using (NodeBuilder builder = NodeBuilder.Create(this)) { CoreNode nodeA = builder.CreateBitcoinCoreNode(); CoreNode nodeB = builder.CreateBitcoinCoreNode(); builder.StartAll(); RPCClient rpc = nodeA.CreateRPCClient(); rpc.RemoveNode(nodeA.Endpoint); rpc.AddNode(nodeB.Endpoint); AddedNodeInfo[] info = null; TestHelper.WaitLoop(() => { info = rpc.GetAddedNodeInfo(true); return(info != null && info.Length > 0); }); Assert.NotNull(info); Assert.NotEmpty(info); //For some reason this one does not pass anymore in 0.13.1 //Assert.Equal(nodeB.Endpoint, info.First().Addresses.First().Address); AddedNodeInfo oneInfo = rpc.GetAddedNodeInfo(true, nodeB.Endpoint); Assert.NotNull(oneInfo); Assert.Equal(nodeB.Endpoint.ToString(), oneInfo.AddedNode.ToString()); oneInfo = rpc.GetAddedNodeInfo(true, nodeA.Endpoint); Assert.Null(oneInfo); rpc.RemoveNode(nodeB.Endpoint); TestHelper.WaitLoop(() => { info = rpc.GetAddedNodeInfo(true); return(info.Length == 0); }); Assert.Empty(info); } }
public void CanAddNodes() { if (noClient) { return; } using (var builder = NodeBuilderStratis.Create()) { CoreNodeStratis nodeA = builder.CreateNode(); CoreNodeStratis nodeB = builder.CreateNode(); builder.StartAll(); RPCClient rpc = nodeA.CreateRPCClient(); rpc.RemoveNode(nodeA.Endpoint); rpc.AddNode(nodeB.Endpoint); Thread.Sleep(500); AddedNodeInfo[] info = rpc.GetAddedNodeInfo(true); Assert.NotNull(info); Assert.NotEmpty(info); //For some reason this one does not pass anymore in 0.13.1. //Assert.Equal(nodeB.Endpoint, info.First().Addresses.First().Address); AddedNodeInfo oneInfo = rpc.GetAddedNodeInfo(true, nodeB.Endpoint); Assert.NotNull(oneInfo); Assert.True(oneInfo.AddedNode.ToString() == nodeB.Endpoint.ToString()); oneInfo = rpc.GetAddedNodeInfo(true, nodeA.Endpoint); Assert.Null(oneInfo); //rpc.RemoveNode(nodeB.Endpoint); //Thread.Sleep(500); //info = rpc.GetAddedNodeInfo(true); //Assert.Equal(0, info.Count()); } }