Beispiel #1
0
 public async Task SsAsync()
 {
     var rpc                = new MockRpcClient();
     var roundConfig        = new CoordinatorRoundConfig();
     var utxoReferee        = new UtxoReferee(Network.Main, "./", rpc, roundConfig);
     var confirmationTarget = 12;
     var round              = new CoordinatorRound(rpc, utxoReferee, roundConfig, adjustedConfirmationTarget: confirmationTarget, confirmationTarget, roundConfig.ConfirmationTargetReductionRate, TimeSpan.FromSeconds(roundConfig.InputRegistrationTimeout));
        public async Task RpcNotEnoughEstimationsAsync()
        {
            var rpc = new MockRpcClient();

            rpc.OnGetBlockchainInfoAsync = async() =>
                                           await Task.FromResult(new BlockchainInfo
            {
                Blocks  = 100,
                Headers = 100
            });

            rpc.OnGetPeersInfoAsync = async() =>
                                      await Task.FromResult(Array.Empty <PeerInfo>());

            rpc.OnGetMempoolInfoAsync = async() =>
                                        await Task.FromResult(new MemPoolInfo
            {
                MemPoolMinFee = 0.00001000                         // 1 s/b (default value)
            });

            rpc.OnEstimateSmartFeeAsync = (target, _) =>
                                          throw new NoEstimationException(target);

            await Assert.ThrowsAsync <NoEstimationException>(async() => await rpc.EstimateAllFeeAsync(EstimateSmartFeeMode.Conservative));
        }
        private BlockNotifier CreateNotifier(ConcurrentChain chain)
        {
            var rpc = new MockRpcClient();

            rpc.OnGetBestBlockHashAsync = () => Task.FromResult(chain.Tip.HashBlock);
            rpc.OnGetBlockAsync         = (blockHash) => Task.FromResult(Block.CreateBlock(chain.GetBlock(blockHash).Header, rpc.Network));
            rpc.OnGetBlockHeaderAsync   = (blockHash) => Task.FromResult(chain.GetBlock(blockHash).Header);

            var notifier = new BlockNotifier(TimeSpan.FromMilliseconds(100), rpc);

            return(notifier);
        }
Beispiel #4
0
        public async Task TryOptimizeFeesTestAsync()
        {
            var rpc = new MockRpcClient();

            rpc.Network = Network.Main;
            rpc.OnEstimateSmartFeeAsync = (confTarget, estMode) => Task.FromResult(new EstimateSmartFeeResponse
            {
                Blocks  = 1,
                FeeRate = new FeeRate(10m)
            });

            var roundConfig        = new CoordinatorRoundConfig();
            var utxoReferee        = new UtxoReferee(Network.Main, "./", rpc, roundConfig);
            var confirmationTarget = 12;
            var round = new CoordinatorRound(rpc, utxoReferee, roundConfig, adjustedConfirmationTarget: confirmationTarget, confirmationTarget, roundConfig.ConfirmationTargetReductionRate, TimeSpan.FromSeconds(roundConfig.InputRegistrationTimeout));
        public async Task RpcFailuresAsync()
        {
            var rpc = new MockRpcClient();

            rpc.OnGetBlockchainInfoAsync = () =>
                                           throw new RPCException(RPCErrorCode.RPC_CLIENT_NOT_CONNECTED, "Error-GetBlockchainInfo", null);

            rpc.OnEstimateSmartFeeAsync = (target, _) =>
                                          throw new RPCException(RPCErrorCode.RPC_CLIENT_NOT_CONNECTED, "Error-EstimateSmartFee", null);

            rpc.OnGetMempoolInfoAsync = async() =>
                                        await Task.FromResult(new MemPoolInfo
            {
                MemPoolMinFee = 0.00001000                         // 1 s/b (default value)
            });

            var ex = await Assert.ThrowsAsync <RPCException>(async() => await rpc.EstimateAllFeeAsync(EstimateSmartFeeMode.Conservative));

            Assert.Equal(RPCErrorCode.RPC_CLIENT_NOT_CONNECTED, ex.RPCCode);
            Assert.Equal("Error-EstimateSmartFee", ex.Message);
        }