public void should_add_valid_transactions() { _transactionPool = CreatePool(_noTransactionStorage); Transaction tx = Build.A.Transaction.SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeyA, RopstenSpecProvider.ByzantiumBlockNumber).TestObject; AddTransactionResult result = _transactionPool.AddTransaction(tx, 1); _transactionPool.GetPendingTransactions().Length.Should().Be(1); result.Should().Be(AddTransactionResult.Added); }
public void should_ignore_old_scheme_signatures() { _transactionPool = CreatePool(_noTransactionStorage); Transaction tx = Build.A.Transaction.SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeyA, 1).TestObject; AddTransactionResult result = _transactionPool.AddTransaction(tx, 1); _transactionPool.GetPendingTransactions().Length.Should().Be(0); result.Should().Be(AddTransactionResult.OldScheme); }
public IEnumerable <IResult> Save() { yield return(Show.Busy(new BusyScreen { Message = "Saving..." })); if (IsEditMode) { // To not update date if it was not changed; // Add time of day to updated date only. DateTime date = OperationDate.Kind == DateTimeKind.Unspecified ? DateTime.SpecifyKind(OperationDate, DateTimeKind.Local) + DateTime.Now.TimeOfDay : OperationDate; var request = new EditTransactionResult( transactionId.Value, userId, ((AccountDTO)Accounts.CurrentItem).Id, date.ToUniversalTime(), decimal.Parse(Price.Trim()), decimal.Parse(Quantity.Trim()), Comment != null ? Comment.Trim() : null, CurrentCategory != null ? CurrentCategory.Id : (int?)null, IsDeposite ); Clear(); yield return(request); } else { // Add time of day to date. DateTime date = OperationDate.Kind == DateTimeKind.Unspecified ? DateTime.SpecifyKind(OperationDate, DateTimeKind.Local) + DateTime.Now.TimeOfDay : OperationDate.Date + DateTime.Now.TimeOfDay; var request = new AddTransactionResult( userId, ((AccountDTO)Accounts.CurrentItem).Id, date.ToUniversalTime(), decimal.Parse(Price.Trim()), decimal.Parse(Quantity.Trim()), Comment != null ? Comment.Trim() : null, CurrentCategory != null ? CurrentCategory.Id : (int?)null, IsDeposite ); yield return(request); } yield return(Show.NotBusy()); }
public void should_ignore_transactions_with_different_chain_id() { _transactionPool = CreatePool(_noTransactionStorage); EthereumEcdsa ecdsa = new EthereumEcdsa(MainNetSpecProvider.Instance, _logManager); Transaction tx = Build.A.Transaction.SignedAndResolved(ecdsa, TestItem.PrivateKeyA, MainNetSpecProvider.ByzantiumBlockNumber).TestObject; AddTransactionResult result = _transactionPool.AddTransaction(tx, 1); _transactionPool.GetPendingTransactions().Length.Should().Be(0); result.Should().Be(AddTransactionResult.InvalidChainId); }
public void should_ignore_already_known() { _transactionPool = CreatePool(_noTransactionStorage); Transaction tx = Build.A.Transaction.SignedAndResolved(_ethereumSigner, TestItem.PrivateKeyA, RopstenSpecProvider.ByzantiumBlockNumber).TestObject; AddTransactionResult result1 = _transactionPool.AddTransaction(tx, 1); AddTransactionResult result2 = _transactionPool.AddTransaction(tx, 1); _transactionPool.GetPendingTransactions().Length.Should().Be(1); result1.Should().Be(AddTransactionResult.Added); result2.Should().Be(AddTransactionResult.AlreadyKnown); }
private void Handle(TransactionsMessage msg) { for (int i = 0; i < msg.Transactions.Length; i++) { var transaction = msg.Transactions[i]; transaction.DeliveredBy = NodeId.PublicKey; transaction.Timestamp = _timestamp.EpochSeconds; AddTransactionResult result = _transactionPool.AddTransaction(transaction, _blockTree.Head.Number); if (result == AddTransactionResult.AlreadyKnown) { _notAcceptedTxsSinceLastCheck++; } if (Logger.IsTrace) { Logger.Trace($"{NodeId} sent {transaction.Hash} and it was {result} (chain ID = {transaction.Signature.GetChainId})"); } } }