Exemple #1
0
        public async Task reserve_own_transaction_nonce_should_invoke_tx_pool_reserve_own_transaction_nonce()
        {
            UInt256 nonce   = 1;
            var     address = TestItem.AddressA;

            _txPool.ReserveOwnTransactionNonce(address).Returns(nonce);
            var result = await _ndmBridge.ReserveOwnTransactionNonceAsync(address);

            _txPool.Received().ReserveOwnTransactionNonce(address);
            result.Should().Be(nonce);
        }
Exemple #2
0
        public async Task <Keccak> ClaimRefundAsync(Address onBehalfOf, RefundClaim refundClaim, UInt256 gasPrice)
        {
            byte[]      txData      = _abiEncoder.Encode(AbiEncodingStyle.IncludeSignature, ContractData.ClaimRefundSig, refundClaim.AssetId.Bytes, refundClaim.Units, refundClaim.Value, refundClaim.ExpiryTime, refundClaim.Pepper, refundClaim.Provider, onBehalfOf);
            Transaction transaction = new Transaction();

            transaction.Value         = 0;
            transaction.Data          = txData;
            transaction.To            = _contractAddress;
            transaction.SenderAddress = onBehalfOf;
            transaction.GasLimit      = (long)GasLimit;
            transaction.GasPrice      = gasPrice;
            transaction.Nonce         = await _blockchainBridge.ReserveOwnTransactionNonceAsync(onBehalfOf);

            _wallet.Sign(transaction, await _blockchainBridge.GetNetworkIdAsync());

            if (_logger.IsInfo)
            {
                _logger.Info($"Sending a refund claim transaction for {refundClaim.DepositId} to be refunded to {refundClaim.RefundTo}");
            }

            return(await _blockchainBridge.SendOwnTransactionAsync(transaction));
        }
        public async Task reserve_own_transaction_nonce_should_invoke_proxy_eth_getTransactionCount_with_address_and_pending_arguments()
        {
            UInt256 nonce   = 1;
            var     address = TestItem.AddressA;

            _proxy.eth_getTransactionCount(address,
                                           Arg.Is <BlockParameterModel>(x => x.Type == BlockParameterModel.Pending.Type))
            .Returns(RpcResult <UInt256?> .Ok(nonce));
            var result = await _ndmBridge.ReserveOwnTransactionNonceAsync(address);

            await _proxy.Received()
            .eth_getTransactionCount(address,
                                     Arg.Is <BlockParameterModel>(x => x.Type == BlockParameterModel.Pending.Type));

            result.Should().Be(nonce);
        }
        public async Task <Keccak> MakeDepositAsync(Address onBehalfOf, Deposit deposit)
        {
            var         txData      = _abiEncoder.Encode(AbiEncodingStyle.IncludeSignature, ContractData.DepositAbiSig, deposit.Id.Bytes, deposit.Units, deposit.ExpiryTime);
            Transaction transaction = new Transaction
            {
                Value         = deposit.Value,
                Data          = txData,
                To            = _contractAddress,
                SenderAddress = onBehalfOf,
                GasLimit      = 70000,
                GasPrice      = 20.GWei(),
                Nonce         = await _blockchainBridge.ReserveOwnTransactionNonceAsync(onBehalfOf)
            };

            // check
            _wallet.Sign(transaction, await _blockchainBridge.GetNetworkIdAsync());

            return(await _blockchainBridge.SendOwnTransactionAsync(transaction));
        }