public void LoadPoolTest_WithBadTransactions() { int numTx = 5; string fileName = "mempool.dat"; NodeSettings settings = this.CreateSettings("LoadPoolTest_WithBadTransactions"); IEnumerable <MempoolPersistenceEntry> toSave = this.CreateTestEntries(numTx); MempoolManager mempoolManager = CreateTestMempool(settings, out TxMempool unused); MemPoolSaveResult result = (new MempoolPersistence(settings, new LoggerFactory())).Save(settings.Network, toSave, fileName); mempoolManager.LoadPoolAsync(fileName).GetAwaiter().GetResult(); long actualSize = mempoolManager.MempoolSize().GetAwaiter().GetResult(); Assert.Equal(0, actualSize); }
public async Task LoadPoolTest_WithGoodTransactionsAsync() { string fileName = "mempool.dat"; var tx1_parent = Transaction.Load("0100000001c4fadb806f9679c27c30c11b694523f6ac9614f7a69076b8940082ce636040fb000000006b4830450221009ad4b969a40b95017d133b13f7d465031829731f3b0ae4bcdcb5e393f5e919f902207f33aad2c3af48d6d65aaf5dd15a85a1f588ee3d6f477b2236cda1d81d88c43b012102eb184a906e082db44a95347de64110952b5821c42068a2054947aec4bc60db2fffffffff02685e3e00000000001976a9149ed35c9c42543ec67f9e6d1033e2ac1ac76f86ba88acd33e4500000000001976a9143c88fada9101f660d77feec1dd8db4ee9ea01d6788ac00000000", Network.Main); var tx1 = Transaction.Load("0100000001055c4c42511f9d05f2fa817c7f023df567f3d501bebec14ddce7c05a9d5fda52000000006b483045022100de552f011768887141b9a767ae184f61aa3743a32aad394ac1e1ec35345415420220070b3d0afd28414f188c966e334e9f7b65e7440538d93bc1d61f82067fcfd3fa012103b47b6ffce08f54be286620a29f45407fedb7b33acfec938551938ec96a1e1b0bffffffff019f053e000000000017a91493e31884769545a237f164aa07b3caef6b62f6b68700000000", Network.Main); NodeSettings settings = this.CreateSettings("LoadPoolTest_WithGoodTransactions"); TxMempool txMemPool; MempoolManager mempoolManager = CreateTestMempool(settings, out txMemPool); var fee = Money.Satoshis(0.00001m); txMemPool.AddUnchecked(tx1_parent.GetHash(), new TxMempoolEntry(tx1_parent, fee, 0, 0.0, 0, tx1_parent.TotalOut + fee, false, 0, null, new PowConsensusOptions())); long expectedTx1FeeDelta = 123; // age of tx = 5 hours long txAge = 5 * 60 * 60; List <MempoolPersistenceEntry> toSave = new List <MempoolPersistenceEntry> { new MempoolPersistenceEntry { Tx = tx1, Time = mempoolManager.DateTimeProvider.GetTime() - txAge, FeeDelta = expectedTx1FeeDelta }, }; MemPoolSaveResult result = (new MempoolPersistence(settings, new LoggerFactory())).Save(settings.Network, toSave, fileName); long expectedSize = 2; await mempoolManager.LoadPoolAsync(fileName); long actualSize = await mempoolManager.MempoolSize(); TxMempoolEntry actualEntry = txMemPool.MapTx.TryGet(tx1.GetHash()); long? actualTx1FeedDelta = actualEntry?.feeDelta; Assert.Equal(expectedSize, actualSize); Assert.Equal(expectedTx1FeeDelta, actualTx1FeedDelta); }