public void CanCreateIndexByStringArgs() { using (NodeBuilder builder = NodeBuilder.Create()) { CoreNode nodeA = builder.CreateStratisPowNode(false, fullNodeBuilder => { fullNodeBuilder .UseConsensus() .UseIndexStore() .UseMempool() .AddRPC(); }); builder.StartAll(); RPCClient rpc = nodeA.CreateRPCClient(); using (Node nodeB = nodeA.CreateNodeClient()) { nodeB.VersionHandshake(); var args = new List <string>(); args.Add("testindex"); args.Add("false"); args.Add("(t,b,n) => t.Inputs.Select((i, N) => new object[] { new object[] { i.PrevOut.Hash, i.PrevOut.N }, t.GetHash() })"); var resp = rpc.SendCommand("createindex", args.ToArray()).ResultString; Assert.Equal("True", resp); } } }
public void CanGetGeneralInfoViaAPI() { using (NodeBuilder builder = NodeBuilder.Create()) { CoreNode nodeA = builder.CreateStratisPowNode(false, fullNodeBuilder => { fullNodeBuilder .UseConsensus() .UseBlockStore() .UseMempool() .AddMining() .UseWallet() .UseApi() .AddRPC(); }); builder.StartAll(); var fullNode = nodeA.FullNode; var ApiURI = fullNode.Settings.ApiUri; using (Node nodeB = nodeA.CreateNodeClient()) { nodeB.VersionHandshake(); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = client.GetStringAsync(ApiURI + "api/wallet/general-info?name=test").GetAwaiter().GetResult(); Assert.StartsWith("{\"walletFilePath\":null,\"network\":\"RegTest\",\"creationTime\":\"", response); } } }
public void CanStartStakingViaAPI() { try { using (NodeBuilder builder = NodeBuilder.Create()) { CoreNode nodeA = builder.CreateStratisPosNode(false, fullNodeBuilder => { fullNodeBuilder .UseStratisConsensus() .UseBlockStore() .UseMempool() .UseWallet() .AddPowPosMining() .UseApi() .AddRPC(); }); builder.StartAll(); var fullNode = nodeA.FullNode; var ApiURI = fullNode.Settings.ApiUri; Assert.NotNull(fullNode.NodeService <PosMinting>(true)); using (Node nodeB = nodeA.CreateNodeClient()) { WalletManager walletManager = fullNode.NodeService <IWalletManager>() as WalletManager; // create the wallet var model = new StartStakingRequest { Name = "apitest", Password = "******" }; var mnemonic = walletManager.CreateWallet(model.Password, model.Name); var content = new StringContent(model.ToString(), Encoding.UTF8, "application/json"); var response = client.PostAsync(ApiURI + "api/miner/startstaking", content).GetAwaiter().GetResult(); Assert.Equal(System.Net.HttpStatusCode.OK, response.StatusCode); var responseText = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); Assert.Equal("", responseText); MiningRPCController controller = fullNode.NodeService <MiningRPCController>(); GetStakingInfoModel info = controller.GetStakingInfo(); Assert.NotNull(info); Assert.True(info.Enabled); Assert.False(info.Staking); } } } finally { // Revert global side-effects of StratisBitcoinPosRunner.InitStratisRegTest() Block.BlockSignature = false; Transaction.TimeStamp = false; } }
public void CanGenerateByStringArgs() { using (NodeBuilder builder = NodeBuilder.Create()) { CoreNode nodeA = builder.CreateStratisPowNode(); builder.StartAll(); RPCClient rpc = nodeA.CreateRPCClient(); using (Node nodeB = nodeA.CreateNodeClient()) { nodeB.VersionHandshake(); var resp = rpc.SendCommand("generate", "1").ResultString; Assert.StartsWith("[" + Environment.NewLine + " \"", resp); } } }
public void CanGetBlockHashByStringArgs() { using (NodeBuilder builder = NodeBuilder.Create()) { CoreNode nodeA = builder.CreateStratisPowNode(); builder.StartAll(); RPCClient rpc = nodeA.CreateRPCClient(); using (Node nodeB = nodeA.CreateNodeClient()) { nodeB.VersionHandshake(); var resp = rpc.SendCommand("getblockhash", "0").ResultString; Assert.Equal("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206", resp); } } }
public void CanGetPeersInfo() { using (NodeBuilder builder = NodeBuilder.Create()) { CoreNode nodeA = builder.CreateStratisPowNode(); builder.StartAll(); RPCClient rpc = nodeA.CreateRPCClient(); using (Node nodeB = nodeA.CreateNodeClient()) { nodeB.VersionHandshake(); PeerInfo[] peers = rpc.GetPeersInfo(); Assert.NotEmpty(peers); } } }