The test is currently a bit slow, and I think it might be because you’re using send_and_ping
, which waits for the other peer to send back a pong in each iteration of the loop.
You could send the messages in the for loop and then ping only at the end:
0 for i in range(MAX_ORPHANS):
1 tx_parent_1 = self.wallet.create_self_transfer()
2 tx_child_1 = self.wallet.create_self_transfer(utxo_to_spend=tx_parent_1["new_utxo"])
3 peer_1.send_message(msg_tx(tx_child_1["tx"]))
4
5 peer_1.sync_with_ping()
6
7 orphanage = node.getorphantxs()
8 assert_equal(len(orphanage), MAX_ORPHANS)
The drawback would be that you’re not checking that every single tx is entering the orphanage, although you could do that simply by saving the orphans
and checking after the ping:
0 orphans = []
1 for i in range(MAX_ORPHANS):
2 tx_parent_1 = self.wallet.create_self_transfer()
3 tx_child_1 = self.wallet.create_self_transfer(utxo_to_spend=tx_parent_1["new_utxo"])
4 orphans.append(tx_child_1["tx"])
5 peer_1.send_message(msg_tx(tx_child_1["tx"]))
6
7 peer_1.sync_with_ping()
8
9 orphanage = node.getorphantxs()
10 assert_equal(len(orphanage), MAX_ORPHANS)
11
12 for orphan in orphans:
13 assert tx_in_orphanage(node, orphan)
Personally I think the first option is good enough though, what do you think?