MCPcopy Create free account
hub / github.com/ElementsProject/elements / run_test

Method run_test

test/functional/mempool_persist.py:57–171  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

55 self.extra_args = [[], ["-persistmempool=0"], []]
56
57 def run_test(self):
58 self.mini_wallet = MiniWallet(self.nodes[2])
59 self.mini_wallet.rescan_utxos()
60 if self.is_sqlite_compiled():
61 self.nodes[2].createwallet(
62 wallet_name="watch",
63 descriptors=True,
64 disable_private_keys=True,
65 load_on_startup=False,
66 )
67 wallet_watch = self.nodes[2].get_wallet_rpc("watch")
68 assert_equal([{'success': True}], wallet_watch.importdescriptors([{'desc': self.mini_wallet.get_descriptor(), 'timestamp': 0}]))
69
70 self.log.debug("Send 5 transactions from node2 (to its own address)")
71 tx_creation_time_lower = int(time.time())
72 for _ in range(5):
73 last_txid = self.mini_wallet.send_self_transfer(from_node=self.nodes[2])["txid"]
74 if self.is_sqlite_compiled():
75 self.nodes[2].syncwithvalidationinterfacequeue() # Flush mempool to wallet
76 node2_balance = wallet_watch.getbalance()
77 self.sync_all()
78 tx_creation_time_higher = int(time.time())
79
80 self.log.debug("Verify that node0 and node1 have 5 transactions in their mempools")
81 assert_equal(len(self.nodes[0].getrawmempool()), 5)
82 assert_equal(len(self.nodes[1].getrawmempool()), 5)
83
84 total_fee_old = self.nodes[0].getmempoolinfo()['total_fee']
85
86 self.log.debug("Prioritize a transaction on node0")
87 fees = self.nodes[0].getmempoolentry(txid=last_txid)['fees']
88 assert_equal(fees['base'], fees['modified'])
89 self.nodes[0].prioritisetransaction(txid=last_txid, fee_delta=1000)
90 fees = self.nodes[0].getmempoolentry(txid=last_txid)['fees']
91 assert_equal(fees['base'] + Decimal('0.00001000'), fees['modified'])
92
93 self.log.info('Check the total base fee is unchanged after prioritisetransaction')
94 assert_equal(total_fee_old, self.nodes[0].getmempoolinfo()['total_fee'])
95 assert_equal(total_fee_old, sum(v['fees']['base'] for k, v in self.nodes[0].getrawmempool(verbose=True).items()))
96
97 last_entry = self.nodes[0].getmempoolentry(txid=last_txid)
98 tx_creation_time = last_entry['time']
99 assert_greater_than_or_equal(tx_creation_time, tx_creation_time_lower)
100 assert_greater_than_or_equal(tx_creation_time_higher, tx_creation_time)
101
102 # disconnect nodes & make a txn that remains in the unbroadcast set.
103 self.disconnect_nodes(0, 1)
104 assert_equal(len(self.nodes[0].getpeerinfo()), 0)
105 assert_equal(len(self.nodes[0].p2ps), 0)
106 self.mini_wallet.send_self_transfer(from_node=self.nodes[0])
107
108 self.log.debug("Stop-start the nodes. Verify that node0 has the transactions in its mempool and node1 does not. Verify that node2 calculates its balance correctly after loading wallet transactions.")
109 self.stop_nodes()
110 # Give this node a head-start, so we can be "extra-sure" that it didn't load anything later
111 # Also don't store the mempool, to keep the datadir clean
112 self.start_node(1, extra_args=["-persistmempool=0"])
113 self.start_node(0)
114 self.start_node(2)

Callers

nothing calls this directly

Calls 15

MiniWalletClass · 0.90
assert_equalFunction · 0.90
assert_raises_rpc_errorFunction · 0.90
rescan_utxosMethod · 0.80
is_sqlite_compiledMethod · 0.80
createwalletMethod · 0.80
get_descriptorMethod · 0.80
send_self_transferMethod · 0.80
infoMethod · 0.80
disconnect_nodesMethod · 0.80

Tested by

no test coverage detected