Changeset View
Changeset View
Standalone View
Standalone View
test/functional/p2p_inv_download.py
Show All 23 Lines | |||||
from test_framework.p2p import ( | from test_framework.p2p import ( | ||||
P2PInterface, | P2PInterface, | ||||
p2p_lock, | p2p_lock, | ||||
) | ) | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import ( | from test_framework.util import ( | ||||
assert_equal, | assert_equal, | ||||
assert_raises_rpc_error, | assert_raises_rpc_error, | ||||
wait_until, | |||||
) | ) | ||||
from test_framework.wallet_util import bytes_to_wif | from test_framework.wallet_util import bytes_to_wif | ||||
import functools | import functools | ||||
import time | import time | ||||
class TestP2PConn(P2PInterface): | class TestP2PConn(P2PInterface): | ||||
▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | def test_data_requests(self, context): | ||||
with p2p_lock: | with p2p_lock: | ||||
return p.last_message.get( | return p.last_message.get( | ||||
"getdata") and p.last_message["getdata"].inv[-1].hash == invid | "getdata") and p.last_message["getdata"].inv[-1].hash == invid | ||||
node_0_mocktime = int(time.time()) | node_0_mocktime = int(time.time()) | ||||
while outstanding_peer_index: | while outstanding_peer_index: | ||||
node_0_mocktime += context.constants.max_getdata_inbound_wait | node_0_mocktime += context.constants.max_getdata_inbound_wait | ||||
self.nodes[0].setmocktime(node_0_mocktime) | self.nodes[0].setmocktime(node_0_mocktime) | ||||
wait_until(lambda: any(getdata_found(i) | self.wait_until(lambda: any(getdata_found(i) | ||||
for i in outstanding_peer_index)) | for i in outstanding_peer_index)) | ||||
for i in outstanding_peer_index: | for i in outstanding_peer_index: | ||||
if getdata_found(i): | if getdata_found(i): | ||||
outstanding_peer_index.remove(i) | outstanding_peer_index.remove(i) | ||||
self.nodes[0].setmocktime(0) | self.nodes[0].setmocktime(0) | ||||
self.log.info("All outstanding peers received a getdata") | self.log.info("All outstanding peers received a getdata") | ||||
@skip(PROOF_TEST_CONTEXT) | @skip(PROOF_TEST_CONTEXT) | ||||
▲ Show 20 Lines • Show All 326 Lines • Show Last 20 Lines |