|
8 | 8 | import time |
9 | 9 |
|
10 | 10 | from test_framework import messages |
| 11 | +from test_framework.messages import CTxIn, COutPoint, msg_mnping |
11 | 12 | from test_framework.mininode import ( |
12 | 13 | P2PDataStore, |
13 | 14 | P2PInterface, |
14 | 15 | ) |
15 | | -from test_framework.messages import CTxIn, COutPoint, msg_mnping |
16 | 16 | from test_framework.test_framework import PivxTestFramework |
17 | 17 | from test_framework.util import ( |
18 | 18 | assert_equal, |
@@ -212,24 +212,26 @@ def test_large_inv(self): |
212 | 212 | def test_fill_askfor(self): |
213 | 213 | self.nodes[0].generate(1) # IBD |
214 | 214 | conn = self.nodes[0].add_p2p_connection(InvReceiver()) |
| 215 | + self.disable_mocktime() |
215 | 216 | invs = [] |
216 | 217 | blockhash = int(self.nodes[0].getbestblockhash(), 16) |
217 | | - for _ in range(50000): |
| 218 | + total_requests = 100 |
| 219 | + for _ in range(total_requests): |
218 | 220 | mnp = msg_mnping(CTxIn(COutPoint(getrandbits(256))), blockhash, int(time.time())) |
219 | | - conn.vec_mnp[mnp.get_hash()] = mnp |
220 | | - invs.append(messages.CInv(15, mnp.get_hash())) |
221 | | - assert_equal(len(conn.vec_mnp), 50000) |
222 | | - assert_equal(len(invs), 50000) |
| 221 | + hash = mnp.get_hash() |
| 222 | + conn.vec_mnp[hash] = mnp |
| 223 | + invs.append(messages.CInv(15, hash)) |
| 224 | + assert_equal(len(conn.vec_mnp), total_requests) |
| 225 | + assert_equal(len(invs), total_requests) |
223 | 226 | msg = messages.msg_inv(invs) |
224 | 227 | conn.send_message(msg) |
225 | | - conn.wait_for_p2p_messages(50000) |
226 | | - |
| 228 | + conn.wait_for_p2p_messages(total_requests) |
227 | 229 | # Prior #2611 the node was blocking any follow-up request. |
228 | 230 | mnp = msg_mnping(CTxIn(COutPoint(getrandbits(256))), getrandbits(256), int(time.time())) |
229 | 231 | conn.vec_mnp[mnp.get_hash()] = mnp |
230 | 232 | msg = messages.msg_inv([messages.CInv(15, mnp.get_hash())]) |
231 | 233 | conn.send_and_ping(msg) |
232 | | - conn.wait_for_p2p_messages(50001) |
| 234 | + conn.wait_for_p2p_messages(total_requests + 1) |
233 | 235 | self.nodes[0].disconnect_p2ps() |
234 | 236 |
|
235 | 237 | def test_resource_exhaustion(self): |
|
0 commit comments