public void VerifySortOrderAndThatHighetFeeTransactionsAreReverifiedFirst() { AddLowPriorityTransactions(50); AddHighPriorityTransactions(50); var sortedVerifiedTxs = _unit.GetSortedVerifiedTransactions().ToList(); // verify all 100 transactions are returned in sorted order sortedVerifiedTxs.Count.ShouldBeEquivalentTo(100); verifyTransactionsSortedDescending(sortedVerifiedTxs); // move all to unverified var block = new Block { Transactions = new Transaction[0] }; _unit.UpdatePoolForBlockPersisted(block, Blockchain.Singleton.GetSnapshot()); _unit.InvalidateVerifiedTransactions(); _unit.SortedHighPrioTxCount.ShouldBeEquivalentTo(0); _unit.SortedLowPrioTxCount.ShouldBeEquivalentTo(0); _unit.UnverifiedSortedHighPrioTxCount.ShouldBeEquivalentTo(50); _unit.UnverifiedSortedLowPrioTxCount.ShouldBeEquivalentTo(50); // We can verify the order they are re-verified by reverifying 2 at a time while (_unit.UnVerifiedCount > 0) { _unit.GetVerifiedAndUnverifiedTransactions(out IEnumerable <Transaction> sortedVerifiedTransactions, out IEnumerable <Transaction> sortedUnverifiedTransactions); sortedVerifiedTransactions.Count().ShouldBeEquivalentTo(0); var sortedUnverifiedArray = sortedUnverifiedTransactions.ToArray(); verifyTransactionsSortedDescending(sortedUnverifiedArray); var maxHighPriorityTransaction = sortedUnverifiedArray.First(); var maxLowPriorityTransaction = sortedUnverifiedArray.First(tx => IsLowPriority(tx)); // reverify 1 high priority and 1 low priority transaction _unit.ReVerifyTopUnverifiedTransactionsIfNeeded(2, Blockchain.Singleton.GetSnapshot()); var verifiedTxs = _unit.GetSortedVerifiedTransactions().ToArray(); verifiedTxs.Length.ShouldBeEquivalentTo(2); verifiedTxs[0].ShouldBeEquivalentTo(maxHighPriorityTransaction); verifiedTxs[1].ShouldBeEquivalentTo(maxLowPriorityTransaction); var blockWith2Tx = new Block { Transactions = new Transaction[2] { maxHighPriorityTransaction, maxLowPriorityTransaction } }; // verify and remove the 2 transactions from the verified pool _unit.UpdatePoolForBlockPersisted(blockWith2Tx, Blockchain.Singleton.GetSnapshot()); _unit.InvalidateVerifiedTransactions(); _unit.SortedHighPrioTxCount.ShouldBeEquivalentTo(0); _unit.SortedLowPrioTxCount.ShouldBeEquivalentTo(0); } _unit.UnverifiedSortedHighPrioTxCount.ShouldBeEquivalentTo(0); _unit.UnverifiedSortedLowPrioTxCount.ShouldBeEquivalentTo(0); }