Пример #1
0
 /// <summary>
 /// Sets ups a new chain, get some coins and store them in availableCoins, so that they can be consumed by test
 /// </summary>
 /// <param name="rpcClient"></param>
 public void SetupChain(IRpcClient rpcClient)
 {
     loggerTest.LogInformation("Setting up test chain");
     _ = rpcClient.GenerateAsync(150).Result;
     foreach (var coin in GetCoins(rpcClient, 10))
     {
         availableCoins.Enqueue(coin);
     }
 }
Пример #2
0
        protected static Coin[] GetCoins(IRpcClient rpcClient, int number)
        {
            var coins = new List <Coin>();

            for (int i = 0; i < number; i++)
            {
                coins.Add(GetCoin(rpcClient));
            }

            // Mine coins into  a block
            _ = rpcClient.GenerateAsync(1).Result;

            return(coins.ToArray());
        }
Пример #3
0
        public async Task <uint256> GenerateBlockAndWaitForItTobeInsertedInDBAsync()
        {
            WaitUntilEventBusIsIdle(); // make sure that all old events (such activating ZMQ subscriptions) are processed
            var subscription = eventBus.Subscribe <NewBlockAvailableInDB>();

            try
            {
                loggerTest.LogInformation("Generating a block and waiting for it to be inserted in DB");
                // generate a new block
                var blockToWaitFor = new uint256((await rpcClient0.GenerateAsync(1))[0]);
                await WaitForEventBusEventAsync(subscription,
                                                $"Waiting for block {blockToWaitFor} to be inserted in DB",
                                                (evt) => new uint256(evt.BlockHash) == blockToWaitFor
                                                );

                return(blockToWaitFor);
            }
            finally
            {
                eventBus.TryUnsubscribe(subscription);
            }
        }