Changeset View
Changeset View
Standalone View
Standalone View
test/functional/p2p_tx_download.py
Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | def test_tx_requests(self): | ||||
self.log.info( | self.log.info( | ||||
"Test that we request transactions from all our peers, eventually") | "Test that we request transactions from all our peers, eventually") | ||||
txid = 0xdeadbeef | txid = 0xdeadbeef | ||||
self.log.info("Announce the txid from each incoming peer to node 0") | self.log.info("Announce the txid from each incoming peer to node 0") | ||||
msg = msg_inv([CInv(t=1, h=txid)]) | msg = msg_inv([CInv(t=1, h=txid)]) | ||||
for p in self.nodes[0].p2ps: | for p in self.nodes[0].p2ps: | ||||
p.send_message(msg) | p.send_and_ping(msg) | ||||
p.sync_with_ping() | |||||
outstanding_peer_index = [i for i in range(len(self.nodes[0].p2ps))] | outstanding_peer_index = [i for i in range(len(self.nodes[0].p2ps))] | ||||
def getdata_found(peer_index): | def getdata_found(peer_index): | ||||
p = self.nodes[0].p2ps[peer_index] | p = self.nodes[0].p2ps[peer_index] | ||||
with mininode_lock: | with mininode_lock: | ||||
return p.last_message.get( | return p.last_message.get( | ||||
"getdata") and p.last_message["getdata"].inv[-1].hash == txid | "getdata") and p.last_message["getdata"].inv[-1].hash == txid | ||||
Show All 27 Lines | def test_inv_block(self): | ||||
)['hex'] | )['hex'] | ||||
ctx = FromHex(CTransaction(), tx) | ctx = FromHex(CTransaction(), tx) | ||||
txid = int(ctx.rehash(), 16) | txid = int(ctx.rehash(), 16) | ||||
self.log.info( | self.log.info( | ||||
"Announce the transaction to all nodes from all {} incoming peers, but never send it".format(NUM_INBOUND)) | "Announce the transaction to all nodes from all {} incoming peers, but never send it".format(NUM_INBOUND)) | ||||
msg = msg_inv([CInv(t=1, h=txid)]) | msg = msg_inv([CInv(t=1, h=txid)]) | ||||
for p in self.peers: | for p in self.peers: | ||||
p.send_message(msg) | p.send_and_ping(msg) | ||||
p.sync_with_ping() | |||||
self.log.info("Put the tx in node 0's mempool") | self.log.info("Put the tx in node 0's mempool") | ||||
self.nodes[0].sendrawtransaction(tx) | self.nodes[0].sendrawtransaction(tx) | ||||
# Since node 1 is connected outbound to an honest peer (node 0), it | # Since node 1 is connected outbound to an honest peer (node 0), it | ||||
# should get the tx within a timeout. (Assuming that node 0 | # should get the tx within a timeout. (Assuming that node 0 | ||||
# announced the tx within the timeout) | # announced the tx within the timeout) | ||||
# The timeout is the sum of | # The timeout is the sum of | ||||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |