Exemple #1
0
        public void RPCSendRPCException()
        {
            if (noClient)
            {
                return;
            }

            using (var builder = NodeBuilderPurple.Create())
            {
                CoreNodePurple node = builder.CreateNode();
                builder.StartAll();
                RPCClient rpcClient = node.CreateRPCClient();
                try
                {
                    rpcClient.SendCommand("whatever");
                    Assert.False(true, "Should have thrown");
                }
                catch (RPCException ex)
                {
                    if (ex.RPCCode != RPCErrorCode.RPC_METHOD_NOT_FOUND)
                    {
                        Assert.False(true, "Should have thrown RPC_METHOD_NOT_FOUND");
                    }
                }
            }
        }
        public CoreNodePurple CreateNode(bool start = false)
        {
            var child = Path.Combine(_Root, last.ToString());

            last++;
            //try
            //{
            //    Directory.Delete(child, true);
            //}
            //catch(DirectoryNotFoundException)
            //{
            //}
            var node = new CoreNodePurple(child, this);

            Nodes.Add(node);
            return(node);
        }
Exemple #3
0
        public void CanUseAsyncRPC()
        {
            if (noClient)
            {
                return;
            }

            using (var builder = NodeBuilderPurple.Create())
            {
                CoreNodePurple node = builder.CreateNode();
                RPCClient      rpc  = node.CreateRPCClient();
                builder.StartAll();
                ////node.Generate(10);
                var blkCount = rpc.GetBlockCountAsync().Result;
                Assert.True(blkCount > 10);
            }
        }
Exemple #4
0
        public void CanGetRawMemPool()
        {
            if (noClient)
            {
                return;
            }

            using (var builder = NodeBuilderPurple.Create())
            {
                CoreNodePurple node = builder.CreateNode();
                RPCClient      rpc  = node.CreateRPCClient();
                builder.StartAll();
                ////node.Generate(101);
                //var txid = rpc.SendToAddress(new Key().PubKey.GetAddress(rpc.Network), Money.Coins(1.0m), "hello", "world");
                uint256[] ids = rpc.GetRawMempool();
                Assert.NotNull(ids);
                //Assert.Equal(txid, ids[0]);
            }
        }
Exemple #5
0
        public void CanAddNodes()
        {
            if (noClient)
            {
                return;
            }

            using (var builder = NodeBuilderPurple.Create())
            {
                CoreNodePurple nodeA = builder.CreateNode();
                CoreNodePurple 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());
            }
        }