public void SetupRunAlicesPayBob() { Tester = Tester.Create(); Alice = Tester.CreateActor("Alice"); Bob = Tester.CreateActor("Bob"); Tester.Start(); Tester.CreateChannels(new[] { Alice }, new[] { Bob }).GetAwaiter().GetResult(); }
public ActorTester CreateActor(string name) { var actor = new ActorTester(_Directory, name, port); actors.Add(actor); port++; return(actor); }
public void SetupRunAlicePaysBobViaCarol() { Tester = Tester.Create(); Alice = Tester.CreateActor("Alice"); Bob = Tester.CreateActor("Bob"); Carols = Enumerable.Range(0, CarolsCount).Select(i => Tester.CreateActor($"Carol{i}")).ToArray(); Tester.Start(); Tester.ConnectPeers(Carols.Concat(new[] { Alice, Bob }).ToArray()).GetAwaiter().GetResult(); var froms = new[] { Alice }.Concat(Carols).ToArray(); var tos = Carols.Concat(new[] { Bob }).ToArray(); Tester.CreateChannels(froms, tos).GetAwaiter().GetResult(); Alice.WaitRouteTo(Bob).GetAwaiter().GetResult(); }
public void SetupAlicesPayBob() { Tester = Tester.Create(); Bob = Tester.CreateActor("Bob"); Alices = new ActorTester[AliceCount]; for (int i = 0; i < Alices.Length; i++) { Alices[i] = Tester.CreateActor("Alice" + i); } Tester.Start(); var bobs = Enumerable.Range(0, Alices.Length).Select(_ => Bob).ToArray(); Task.WaitAll(Alices.Select(a => Tester.ConnectPeers(a, Bob)).ToArray()); Tester.CreateChannels(Alices, bobs).GetAwaiter().GetResult(); Task.WaitAll(Alices.Select(a => Tester.ConnectPeers(a, Bob)).ToArray()); Task.WaitAll(Alices.Select(a => a.WaitRouteTo(Bob)).ToArray()); }
public async Task WaitRouteTo(ActorTester destination) { var info = await destination.RPC.GetInfoAsync(); int blockToMine = 6; while (true) { var route = await RPC.GetRouteAsync(info.Id, LightMoney.Satoshis(100), 0.0); if (route != null) { break; } await Task.Delay(1000); BitcoinRPC.Generate(blockToMine); blockToMine = 1; } Console.WriteLine($"// Route from {this.P2PHost} to {destination.P2PHost} can now be used"); }