public JsonRpcAdminTestsSetup() { var address = new Uri("http://localhost:" + this.HttpPort); var httpClient = new HttpClient(); httpClient.BaseAddress = address; RpcApi = new JsonRpcApi(httpClient); }
static async Task Main(string[] args) { // Create the network client var address = new Uri("https://s.altnet.rippletest.net:51234"); var httpClient = new HttpClient(); httpClient.BaseAddress = address; var xrplClient = new JsonRpcApi(httpClient); // Create a wallet using the testnet faucet var faucetClient = new FaucetClient(); var testSeed = await faucetClient.Generate(); Console.WriteLine(testSeed); // Create an account string from the wallet // N.B rootKeyPair will be null for ED25519 keys testSeed.GetKeyPairs(out var rootKeyPair, out var keyPair); var accountId = AccountId.FromPublicKey(keyPair.PublicKey.GetCanoncialBytes()); Console.WriteLine(accountId); // Look up info about your account, need to do this in a loop because it will take some time for the account to actually be present in a validated ledger while (true) { var infoRequest = new AccountInfoRequest() { Account = accountId, Ledger = LedgerSpecification.Validated }; try { var infoResponse = await xrplClient.AccountInfo(infoRequest); Console.WriteLine("Balance: {0}", infoResponse.AccountData.Balance); break; } catch (RippleRequestException exc) { if (exc.Error == "actNotFound") { continue; } throw; } } }
public JsonRpcAdminTests(JsonRpcAdminTestsSetup setup) : base(setup) { this.Api = setup.RpcApi; }
public AdminTestsSetup() { var configDirectory = System.IO.Directory.CreateDirectory( System.IO.Path.Combine( System.IO.Path.GetTempPath(), System.IO.Path.GetRandomFileName())); System.IO.File.WriteAllText( System.IO.Path.Combine(configDirectory.FullName, "rippled.cfg"), config); System.IO.File.WriteAllText( System.IO.Path.Combine(configDirectory.FullName, "validators.txt"), validators); Client = new DockerClientConfiguration(null, TimeSpan.FromMinutes(1.0)).CreateClient(); // Pull the latest image var imagesCreateParameters = new ImagesCreateParameters { FromImage = "xrpllabsofficial/xrpld", Tag = "latest" }; var progress = new Progress <JSONMessage>(); Client.Images.CreateImageAsync(imagesCreateParameters, null, progress).Wait(); var createParameters = new CreateContainerParameters(); createParameters.Volumes = new Dictionary <string, EmptyStruct>(new [] { KeyValuePair.Create("/config", new EmptyStruct()), }); createParameters.Image = imagesCreateParameters.FromImage + ":" + imagesCreateParameters.Tag; createParameters.HostConfig = new HostConfig { Binds = new [] { configDirectory + ":/config:ro" }, PublishAllPorts = true }; createParameters.Cmd = new[] { "-a", "--start" }; var container = Client.Containers.CreateContainerAsync(createParameters).Result; ID = container.ID; var startParameters = new ContainerStartParameters(); var started = Client.Containers.StartContainerAsync(ID, startParameters).Result; if (!started) { Dispose(); throw new Exception("Could not start rippled container"); } var inspect = Client.Containers.InspectContainerAsync(ID).Result; foreach (var port in inspect.NetworkSettings.Ports) { if (port.Key == "5005/tcp") { HttpPort = port.Value[0].HostPort; } if (port.Key == "6006/tcp") { WsPort = port.Value[0].HostPort; } } // Check we can ping the server for (int i = 0; i < 10; ++i) { var address = new Uri("http://localhost:" + this.HttpPort); var httpClient = new HttpClient(); httpClient.BaseAddress = address; var api = new JsonRpcApi(httpClient); try { api.Ping().Wait(TimeSpan.FromSeconds(5.0)); break; } catch { if (i == 9) { Dispose(); throw; } System.Threading.Thread.Sleep(500); } finally { api.DisposeAsync().AsTask().Wait(); } } }