public async Task AddMempoolEntriesToMempool_WithNull_ThrowsNoExceptionAsync() { MempoolManager manager = this.TxExpiryManager; Assert.NotNull(manager); await manager.AddMempoolEntriesToMempoolAsync(null); }
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); }
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); }