aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAmiti Uttarwar <amiti@uttarwar.org>2020-04-28 10:17:42 -0700
committerAmiti Uttarwar <amiti@uttarwar.org>2020-05-25 11:27:06 -0700
commitbd093ca15de762fdaf0937a0877d17b0c2bce16e (patch)
tree83b5c449656cbaf97767bba148bdc04298e13f3b /test
parentdab298d9ab5a5a41685f437db9081fa7b395fa73 (diff)
downloadbitcoin-bd093ca15de762fdaf0937a0877d17b0c2bce16e.tar.xz
[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
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/mempool_unbroadcast.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/test/functional/mempool_unbroadcast.py b/test/functional/mempool_unbroadcast.py
index dedf5b8a47..365d011157 100755
--- a/test/functional/mempool_unbroadcast.py
+++ b/test/functional/mempool_unbroadcast.py
@@ -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.