예제 #1
0
        public async Task AddMempoolEntriesToMempool_WithNull_ThrowsNoExceptionAsync()
        {
            MempoolManager manager = this.TxExpiryManager;

            Assert.NotNull(manager);

            await manager.AddMempoolEntriesToMempoolAsync(null);
        }
예제 #2
0
        public async Task AddMempoolEntriesToMempool_WithExpiredTx_PurgesTxAsync()
        {
            MempoolManager manager = this.TxExpiryManager;

            Assert.NotNull(manager);

            long expiryInSeconds = MempoolValidator.DefaultMempoolExpiry * 60 * 60;

            // tx with expiry twice as long as default expiry
            var txs = new List <MempoolPersistenceEntry>
            {
                new MempoolPersistenceEntry
                {
                    Tx   = new Transaction(),
                    Time = manager.DateTimeProvider.GetTime() - expiryInSeconds * 2
                }
            };
            await manager.AddMempoolEntriesToMempoolAsync(txs);

            long entries = await manager.MempoolSize();

            // Should not add it because it's expired
            Assert.Equal(0L, entries);
        }
예제 #3
0
        public async Task AddMempoolEntriesToMempool_WithUnexpiredTx_AddsTxAsync()
        {
            MempoolManager manager = this.TxExpiryManager;

            Assert.NotNull(manager);

            long expiryInSeconds = MempoolValidator.DefaultMempoolExpiry * 60 * 60;

            // tx with expiry half as long as default expiry
            var txs = new List <MempoolPersistenceEntry>
            {
                new MempoolPersistenceEntry
                {
                    Tx   = new Transaction(),
                    Time = manager.DateTimeProvider.GetTime() - expiryInSeconds / 2
                }
            };
            await manager.AddMempoolEntriesToMempoolAsync(txs);

            long entries = await manager.MempoolSize();

            // Not expired so should have been added
            Assert.Equal(1L, entries);
        }