mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-27 14:30:24 +01: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:
@@ -16,6 +16,7 @@ from test_framework.util import (
|
|||||||
disconnect_nodes,
|
disconnect_nodes,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
MAX_INITIAL_BROADCAST_DELAY = 15 * 60 # 15 minutes in seconds
|
||||||
|
|
||||||
class MempoolUnbroadcastTest(BitcoinTestFramework):
|
class MempoolUnbroadcastTest(BitcoinTestFramework):
|
||||||
def set_test_params(self):
|
def set_test_params(self):
|
||||||
@@ -72,7 +73,7 @@ class MempoolUnbroadcastTest(BitcoinTestFramework):
|
|||||||
connect_nodes(node, 1)
|
connect_nodes(node, 1)
|
||||||
|
|
||||||
# fast forward into the future & ensure that the second node has the txns
|
# 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)
|
self.sync_mempools(timeout=30)
|
||||||
mempool = self.nodes[1].getrawmempool()
|
mempool = self.nodes[1].getrawmempool()
|
||||||
assert rpc_tx_hsh in mempool
|
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")
|
self.log.info("Add another connection & ensure transactions aren't broadcast again")
|
||||||
|
|
||||||
conn = node.add_p2p_connection(P2PTxInvStore())
|
conn = node.add_p2p_connection(P2PTxInvStore())
|
||||||
node.mockscheduler(15 * 60)
|
node.mockscheduler(MAX_INITIAL_BROADCAST_DELAY)
|
||||||
time.sleep(5)
|
time.sleep(2) # allow sufficient time for possibility of broadcast
|
||||||
assert_equal(len(conn.get_invs()), 0)
|
assert_equal(len(conn.get_invs()), 0)
|
||||||
|
|
||||||
|
disconnect_nodes(node, 1)
|
||||||
|
node.disconnect_p2ps()
|
||||||
|
|
||||||
def test_txn_removal(self):
|
def test_txn_removal(self):
|
||||||
self.log.info("Test that transactions removed from mempool are removed from unbroadcast set")
|
self.log.info("Test that transactions removed from mempool are removed from unbroadcast set")
|
||||||
node = self.nodes[0]
|
node = self.nodes[0]
|
||||||
disconnect_nodes(node, 1)
|
|
||||||
node.disconnect_p2ps
|
|
||||||
|
|
||||||
# since the node doesn't have any connections, it will not receive
|
# since the node doesn't have any connections, it will not receive
|
||||||
# any GETDATAs & thus the transaction will remain in the unbroadcast set.
|
# any GETDATAs & thus the transaction will remain in the unbroadcast set.
|
||||||
|
|||||||
Reference in New Issue
Block a user