mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-26 00:25:26 +02:00
[test] updates to unbroadcast test
- add () to function to actually disconnect from p2pconn - extract max interval into a constant - disconnect at the end of a subtest rather than start of next
This commit is contained in:
parent
dab298d9ab
commit
bd093ca15d
@ -16,6 +16,7 @@ from test_framework.util import (
|
||||
disconnect_nodes,
|
||||
)
|
||||
|
||||
MAX_INITIAL_BROADCAST_DELAY = 15 * 60 # 15 minutes in seconds
|
||||
|
||||
class MempoolUnbroadcastTest(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
@ -72,7 +73,7 @@ class MempoolUnbroadcastTest(BitcoinTestFramework):
|
||||
connect_nodes(node, 1)
|
||||
|
||||
# fast forward into the future & ensure that the second node has the txns
|
||||
node.mockscheduler(15 * 60) # 15 min in seconds
|
||||
node.mockscheduler(MAX_INITIAL_BROADCAST_DELAY)
|
||||
self.sync_mempools(timeout=30)
|
||||
mempool = self.nodes[1].getrawmempool()
|
||||
assert rpc_tx_hsh in mempool
|
||||
@ -86,15 +87,16 @@ class MempoolUnbroadcastTest(BitcoinTestFramework):
|
||||
self.log.info("Add another connection & ensure transactions aren't broadcast again")
|
||||
|
||||
conn = node.add_p2p_connection(P2PTxInvStore())
|
||||
node.mockscheduler(15 * 60)
|
||||
time.sleep(5)
|
||||
node.mockscheduler(MAX_INITIAL_BROADCAST_DELAY)
|
||||
time.sleep(2) # allow sufficient time for possibility of broadcast
|
||||
assert_equal(len(conn.get_invs()), 0)
|
||||
|
||||
disconnect_nodes(node, 1)
|
||||
node.disconnect_p2ps()
|
||||
|
||||
def test_txn_removal(self):
|
||||
self.log.info("Test that transactions removed from mempool are removed from unbroadcast set")
|
||||
node = self.nodes[0]
|
||||
disconnect_nodes(node, 1)
|
||||
node.disconnect_p2ps
|
||||
|
||||
# since the node doesn't have any connections, it will not receive
|
||||
# any GETDATAs & thus the transaction will remain in the unbroadcast set.
|
||||
|
Loading…
x
Reference in New Issue
Block a user