示例#1
0
        public void When_no_transactions_returns_empty_list()
        {
            ITxSource txSource = Substitute.For <ITxSource>();
            SinglePendingTxSelector selector = new SinglePendingTxSelector(txSource);

            selector.GetTransactions(_anyParent, 1000000).Should().HaveCount(0);
        }
示例#2
0
        public void When_many_transactions_returns_one_with_lowest_nonce_and_highest_timestamp()
        {
            ITxSource txSource = Substitute.For <ITxSource>();

            txSource.GetTransactions(_anyParent, 1000000).ReturnsForAnyArgs(new []
            {
                Build.A.Transaction.WithNonce(6).TestObject,
                Build.A.Transaction.WithNonce(1).WithTimestamp(7).TestObject,
                Build.A.Transaction.WithNonce(9).TestObject,
                Build.A.Transaction.WithNonce(1).WithTimestamp(8).TestObject,
            });

            SinglePendingTxSelector selector = new SinglePendingTxSelector(txSource);
            var result = selector.GetTransactions(_anyParent, 1000000).ToArray();

            result.Should().HaveCount(1);
            result[0].Timestamp.Should().Be(8);
            result[0].Nonce.Should().Be(1);
        }