mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-29 13:32:33 +02:00
test: Remove global wait_until from p2p_getdata
This commit is contained in:
parent
999922baed
commit
fa80b4788b
@ -9,12 +9,8 @@ from test_framework.messages import (
|
|||||||
CInv,
|
CInv,
|
||||||
msg_getdata,
|
msg_getdata,
|
||||||
)
|
)
|
||||||
from test_framework.mininode import (
|
from test_framework.mininode import P2PInterface
|
||||||
mininode_lock,
|
|
||||||
P2PInterface,
|
|
||||||
)
|
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
from test_framework.util import wait_until
|
|
||||||
|
|
||||||
|
|
||||||
class P2PStoreBlock(P2PInterface):
|
class P2PStoreBlock(P2PInterface):
|
||||||
@ -32,21 +28,21 @@ class GetdataTest(BitcoinTestFramework):
|
|||||||
self.num_nodes = 1
|
self.num_nodes = 1
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
self.nodes[0].add_p2p_connection(P2PStoreBlock())
|
p2p_block_store = self.nodes[0].add_p2p_connection(P2PStoreBlock())
|
||||||
|
|
||||||
self.log.info("test that an invalid GETDATA doesn't prevent processing of future messages")
|
self.log.info("test that an invalid GETDATA doesn't prevent processing of future messages")
|
||||||
|
|
||||||
# Send invalid message and verify that node responds to later ping
|
# Send invalid message and verify that node responds to later ping
|
||||||
invalid_getdata = msg_getdata()
|
invalid_getdata = msg_getdata()
|
||||||
invalid_getdata.inv.append(CInv(t=0, h=0)) # INV type 0 is invalid.
|
invalid_getdata.inv.append(CInv(t=0, h=0)) # INV type 0 is invalid.
|
||||||
self.nodes[0].p2ps[0].send_and_ping(invalid_getdata)
|
p2p_block_store.send_and_ping(invalid_getdata)
|
||||||
|
|
||||||
# Check getdata still works by fetching tip block
|
# Check getdata still works by fetching tip block
|
||||||
best_block = int(self.nodes[0].getbestblockhash(), 16)
|
best_block = int(self.nodes[0].getbestblockhash(), 16)
|
||||||
good_getdata = msg_getdata()
|
good_getdata = msg_getdata()
|
||||||
good_getdata.inv.append(CInv(t=2, h=best_block))
|
good_getdata.inv.append(CInv(t=2, h=best_block))
|
||||||
self.nodes[0].p2ps[0].send_and_ping(good_getdata)
|
p2p_block_store.send_and_ping(good_getdata)
|
||||||
wait_until(lambda: self.nodes[0].p2ps[0].blocks[best_block] == 1, timeout=30, lock=mininode_lock)
|
p2p_block_store.wait_until(lambda: self.nodes[0].p2ps[0].blocks[best_block] == 1)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user