コード例 #1
0
        public void RPCSendRPCException()
        {
            if (noClient)
            {
                return;
            }

            using (var builder = NodeBuilderStratis.Create())
            {
                CoreNodeStratis 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");
                    }
                }
            }
        }
コード例 #2
0
        public void CanUseAsyncRPC()
        {
            if (noClient)
            {
                return;
            }

            using (var builder = NodeBuilderStratis.Create())
            {
                CoreNodeStratis node = builder.CreateNode();
                RPCClient       rpc  = node.CreateRPCClient();
                builder.StartAll();
                ////node.Generate(10);
                var blkCount = rpc.GetBlockCountAsync().Result;
                Assert.True(blkCount > 10);
            }
        }
コード例 #3
0
        public CoreNodeStratis CreateNode(bool start = false)
        {
            var child = Path.Combine(_Root, last.ToString());

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

            Nodes.Add(node);
            return(node);
        }
コード例 #4
0
        public void CanGetRawMemPool()
        {
            if (noClient)
            {
                return;
            }

            using (var builder = NodeBuilderStratis.Create())
            {
                CoreNodeStratis 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]);
            }
        }
コード例 #5
0
        public void RawTransactionIsConformsToRPC()
        {
            if (noClient)
            {
                return;
            }

            using (var builder = NodeBuilderStratis.Create())
            {
                CoreNodeStratis node = builder.CreateNode();
                builder.StartAll();

                RPCClient rpc = node.CreateRPCClient();
                var       tx  = Transaction.Parse("01000000ac55a957010000000000000000000000000000000000000000000000000000000000000000ffffffff0401320103ffffffff010084d717000000001976a9143ac0dad2ad42e35fcd745d7511d47c24ad6580b588ac00000000");

                Transaction tx2 = rpc.GetRawTransaction(uint256.Parse("a6783a0933942d37dcb5fb923ddd343522036de23fbc658f2ad2a9f1428ca19d"));
                Assert.Equal(tx.GetHash(), tx2.GetHash());
            }
        }
コード例 #6
0
        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());
            }
        }