public void should_add_valid_transactions() { _txPool = CreatePool(_noTxStorage); Transaction tx = Build.A.Transaction.SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeyA, RopstenSpecProvider.ByzantiumBlockNumber).TestObject; AddTxResult result = _txPool.AddTransaction(tx, 1); _txPool.GetPendingTransactions().Length.Should().Be(1); result.Should().Be(AddTxResult.Added); }
public void should_add_valid_transactions() { _txPool = CreatePool(_noTxStorage); Transaction tx = Build.A.Transaction.SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeyA).TestObject; AddTxResult result = _txPool.AddTransaction(tx, TxHandlingOptions.PersistentBroadcast); _txPool.GetPendingTransactions().Length.Should().Be(1); result.Should().Be(AddTxResult.Added); }
public void should_ignore_old_scheme_signatures() { _txPool = CreatePool(_noTxStorage); Transaction tx = Build.A.Transaction.SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeyA, 1).TestObject; AddTxResult result = _txPool.AddTransaction(tx, 1); _txPool.GetPendingTransactions().Length.Should().Be(0); result.Should().Be(AddTxResult.OldScheme); }
public void should_ignore_transactions_with_different_chain_id() { _txPool = CreatePool(_noTxStorage); EthereumEcdsa ecdsa = new EthereumEcdsa(ChainId.Mainnet, _logManager); Transaction tx = Build.A.Transaction.SignedAndResolved(ecdsa, TestItem.PrivateKeyA).TestObject; AddTxResult result = _txPool.AddTransaction(tx, TxHandlingOptions.PersistentBroadcast); _txPool.GetPendingTransactions().Length.Should().Be(0); result.Should().Be(AddTxResult.InvalidChainId); }
public void should_ignore_transactions_with_different_chain_id() { _txPool = CreatePool(_noTxStorage); EthereumEcdsa ecdsa = new EthereumEcdsa(MainNetSpecProvider.Instance, _logManager); Transaction tx = Build.A.Transaction.SignedAndResolved(ecdsa, TestItem.PrivateKeyA, MainNetSpecProvider.ByzantiumBlockNumber).TestObject; AddTxResult result = _txPool.AddTransaction(tx, 1); _txPool.GetPendingTransactions().Length.Should().Be(0); result.Should().Be(AddTxResult.InvalidChainId); }
public void should_ignore_transactions_too_far_into_future() { _txPool = CreatePool(_noTxStorage); Transaction tx = Build.A.Transaction.WithNonce(_txPool.FutureNonceRetention + 1).SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeyA).TestObject; EnsureSenderBalance(tx); AddTxResult result = _txPool.AddTransaction(tx, TxHandlingOptions.PersistentBroadcast); _txPool.GetPendingTransactions().Length.Should().Be(0); result.Should().Be(AddTxResult.FutureNonce); }
public void should_not_ignore_old_scheme_signatures() { _txPool = CreatePool(_noTxStorage); Transaction tx = Build.A.Transaction.SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeyA, false).TestObject; EnsureSenderBalance(tx); AddTxResult result = _txPool.AddTransaction(tx, TxHandlingOptions.PersistentBroadcast); _txPool.GetPendingTransactions().Length.Should().Be(1); result.Should().Be(AddTxResult.Added); }
public void should_ignore_already_known() { _txPool = CreatePool(_noTxStorage); Transaction tx = Build.A.Transaction.SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeyA, RopstenSpecProvider.ByzantiumBlockNumber).TestObject; AddTxResult result1 = _txPool.AddTransaction(tx, 1, TxHandlingOptions.PersistentBroadcast); AddTxResult result2 = _txPool.AddTransaction(tx, 1, TxHandlingOptions.PersistentBroadcast); _txPool.GetPendingTransactions().Length.Should().Be(1); result1.Should().Be(AddTxResult.Added); result2.Should().Be(AddTxResult.AlreadyKnown); }
public void should_ignore_old_nonce_transactions() { _txPool = CreatePool(_noTxStorage); Transaction tx = Build.A.Transaction.SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeyA).TestObject; EnsureSenderBalance(tx); _stateProvider.IncrementNonce(tx.SenderAddress); AddTxResult result = _txPool.AddTransaction(tx, TxHandlingOptions.PersistentBroadcast); _txPool.GetPendingTransactions().Length.Should().Be(0); result.Should().Be(AddTxResult.OldNonce); }
public void should_ignore_tx_gas_limit_exceeded() { _txPool = CreatePool(_noTxStorage); Transaction tx = Build.A.Transaction .WithGasLimit(_txGasLimit + 1) .SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeyA).TestObject; EnsureSenderBalance(tx); AddTxResult result = _txPool.AddTransaction(tx, TxHandlingOptions.PersistentBroadcast); _txPool.GetPendingTransactions().Length.Should().Be(0); result.Should().Be(AddTxResult.GasLimitExceeded); }
public void should_ignore_overflow_transactions() { _txPool = CreatePool(_noTxStorage); Transaction tx = Build.A.Transaction.WithGasPrice(UInt256.MaxValue / Transaction.BaseTxGasCost) .WithGasLimit(Transaction.BaseTxGasCost) .WithValue(Transaction.BaseTxGasCost) .SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeyA).TestObject; EnsureSenderBalance(tx); AddTxResult result = _txPool.AddTransaction(tx, TxHandlingOptions.PersistentBroadcast); _txPool.GetPendingTransactions().Length.Should().Be(0); result.Should().Be(AddTxResult.BalanceOverflow); }
public void should_ignore_insufficient_funds_for_eip1559_transactions() { var specProvider = Substitute.For <ISpecProvider>(); specProvider.GetSpec(Arg.Any <long>()).Returns(London.Instance); var txPool = CreatePool(_noTxStorage, null, specProvider); Transaction tx = Build.A.Transaction .WithType(TxType.EIP1559).WithFeeCap(20) .WithChainId(ChainId.Mainnet) .WithValue(5).SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeyA).TestObject; EnsureSenderBalance(tx.SenderAddress, tx.FeeCap * (UInt256)tx.GasLimit); // without tx.Value so we should have InsufficientFunds AddTxResult result = txPool.AddTransaction(tx, TxHandlingOptions.PersistentBroadcast); txPool.GetPendingTransactions().Length.Should().Be(0); result.Should().Be(AddTxResult.InsufficientFunds); }
public void should_accept_access_list_transactions_only_when_eip2930_enabled([Values(false, true)] bool eip2930Enabled) { if (!eip2930Enabled) { _blockFinder.FindBestSuggestedHeader().Returns(Build.A.BlockHeader.WithNumber(RopstenSpecProvider.BerlinBlockNumber - 1).TestObject); } _txPool = CreatePool(_noTxStorage); Transaction tx = Build.A.Transaction .WithType(TxType.AccessList) .WithChainId(ChainId.Mainnet) .SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeyA).TestObject; EnsureSenderBalance(tx); AddTxResult result = _txPool.AddTransaction(tx, TxHandlingOptions.PersistentBroadcast); _txPool.GetPendingTransactions().Length.Should().Be(eip2930Enabled ? 1 : 0); result.Should().Be(eip2930Enabled ? AddTxResult.Added : AddTxResult.Invalid); }
public void should_ignore_overflow_transactions_gas_premium_and_fee_cap() { var specProvider = Substitute.For <ISpecProvider>(); specProvider.GetSpec(Arg.Any <long>()).Returns(London.Instance); var txPool = CreatePool(_noTxStorage, null, specProvider); Transaction tx = Build.A.Transaction.WithGasPrice(UInt256.MaxValue / Transaction.BaseTxGasCost) .WithGasLimit(Transaction.BaseTxGasCost) .WithValue(Transaction.BaseTxGasCost) .WithFeeCap(UInt256.MaxValue - 10) .WithGasPremium((UInt256)15) .WithType(TxType.EIP1559) .SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeyA).TestObject; EnsureSenderBalance(tx.SenderAddress, UInt256.MaxValue); AddTxResult result = txPool.AddTransaction(tx, TxHandlingOptions.PersistentBroadcast); txPool.GetPendingTransactions().Length.Should().Be(0); result.Should().Be(AddTxResult.BalanceOverflow); }
public void should_ignore_transactions_with_insufficient_intrinsic_gas() { _txPool = CreatePool(_noTxStorage); EthereumEcdsa ecdsa = new EthereumEcdsa(ChainId.Mainnet, _logManager); Transaction tx = Build.A.Transaction .WithData(new byte[] { 127, 243, 106, 181, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 145, 162, 136, 9, 81, 126, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 188, 120, 128, 96, 158, 141, 79, 126, 233, 131, 209, 47, 215, 166, 85, 190, 220, 187, 180, 115, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, 44, 207, 221, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 233, 29, 21, 62, 11, 65, 81, 138, 44, 232, 221, 61, 121, 68, 250, 134, 52, 99, 169, 125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 183, 211, 17, 226, 235, 85, 242, 246, 138, 148, 64, 218, 56, 231, 152, 146, 16, 185, 160, 94, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 22, 226, 139, 67, 163, 88, 22, 43, 150, 247, 11, 77, 225, 76, 152, 164, 70, 95, 37 }) .SignedAndResolved() .TestObject; AddTxResult result = _txPool.AddTransaction(tx, TxHandlingOptions.PersistentBroadcast); _txPool.GetPendingTransactions().Length.Should().Be(0); result.Should().Be(AddTxResult.Invalid); }
public void should_accept_1559_transactions_only_when_eip1559_enabled([Values(false, true)] bool eip1559Enabled) { ISpecProvider specProvider = null; if (eip1559Enabled) { specProvider = Substitute.For <ISpecProvider>(); specProvider.GetSpec(Arg.Any <long>()).Returns(London.Instance); } var txPool = CreatePool(_noTxStorage, null, specProvider); Transaction tx = Build.A.Transaction .WithType(TxType.EIP1559) .WithChainId(ChainId.Mainnet) .SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeyA).TestObject; EnsureSenderBalance(tx); AddTxResult result = txPool.AddTransaction(tx, TxHandlingOptions.PersistentBroadcast); txPool.GetPendingTransactions().Length.Should().Be(eip1559Enabled ? 1 : 0); result.Should().Be(eip1559Enabled ? AddTxResult.Added : AddTxResult.Invalid); }