Exemplo n.º 1
0
 public void SetupRunAlicesPayBob()
 {
     Tester = Tester.Create();
     Alice  = Tester.CreateActor("Alice");
     Bob    = Tester.CreateActor("Bob");
     Tester.Start();
     Tester.CreateChannels(new[] { Alice }, new[] { Bob }).GetAwaiter().GetResult();
 }
Exemplo n.º 2
0
        public ActorTester CreateActor(string name)
        {
            var actor = new ActorTester(_Directory, name, port);

            actors.Add(actor);
            port++;
            return(actor);
        }
Exemplo n.º 3
0
        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();
        }
Exemplo n.º 4
0
        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());
        }
Exemplo n.º 5
0
        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");
        }