Skip to content

Commit bd093ca

Browse files
committed
[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
1 parent dab298d commit bd093ca

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

test/functional/mempool_unbroadcast.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
disconnect_nodes,
1717
)
1818

19+
MAX_INITIAL_BROADCAST_DELAY = 15 * 60 # 15 minutes in seconds
1920

2021
class MempoolUnbroadcastTest(BitcoinTestFramework):
2122
def set_test_params(self):
@@ -72,7 +73,7 @@ def test_broadcast(self):
7273
connect_nodes(node, 1)
7374

7475
# fast forward into the future & ensure that the second node has the txns
75-
node.mockscheduler(15 * 60) # 15 min in seconds
76+
node.mockscheduler(MAX_INITIAL_BROADCAST_DELAY)
7677
self.sync_mempools(timeout=30)
7778
mempool = self.nodes[1].getrawmempool()
7879
assert rpc_tx_hsh in mempool
@@ -86,15 +87,16 @@ def test_broadcast(self):
8687
self.log.info("Add another connection & ensure transactions aren't broadcast again")
8788

8889
conn = node.add_p2p_connection(P2PTxInvStore())
89-
node.mockscheduler(15 * 60)
90-
time.sleep(5)
90+
node.mockscheduler(MAX_INITIAL_BROADCAST_DELAY)
91+
time.sleep(2) # allow sufficient time for possibility of broadcast
9192
assert_equal(len(conn.get_invs()), 0)
9293

94+
disconnect_nodes(node, 1)
95+
node.disconnect_p2ps()
96+
9397
def test_txn_removal(self):
9498
self.log.info("Test that transactions removed from mempool are removed from unbroadcast set")
9599
node = self.nodes[0]
96-
disconnect_nodes(node, 1)
97-
node.disconnect_p2ps
98100

99101
# since the node doesn't have any connections, it will not receive
100102
# any GETDATAs & thus the transaction will remain in the unbroadcast set.

0 commit comments

Comments
 (0)