1010"""
1111
1212from decimal import Decimal
13- from math import ceil
1413
1514from test_framework .mempool_util import (
1615 DEFAULT_MIN_RELAY_TX_FEE ,
17- fill_mempool ,
1816)
1917from test_framework .messages import (
2018 COIN ,
2624from test_framework .test_framework import BitcoinTestFramework
2725from test_framework .util import (
2826 assert_equal ,
29- assert_greater_than ,
3027)
3128from test_framework .wallet import (
3229 MiniWallet ,
@@ -39,20 +36,9 @@ def set_test_params(self):
3936 self .num_nodes = 4
4037 # hugely speeds up the test, as it involves multiple hops of tx relay.
4138 self .noban_tx_relay = True
42- self .extra_args = [[
43- "-maxmempool=5" ,
44- ]] * self .num_nodes
45-
46- def raise_network_minfee (self ):
47- fill_mempool (self , self .nodes [0 ])
48-
49- self .log .debug ("Check that all nodes' mempool minimum feerates are above min relay feerate" )
50- for node in self .nodes :
51- assert_equal (node .getmempoolinfo ()['minrelaytxfee' ], Decimal (DEFAULT_MIN_RELAY_TX_FEE ) / COIN )
52- assert_greater_than (node .getmempoolinfo ()['mempoolminfee' ], Decimal (DEFAULT_MIN_RELAY_TX_FEE ) / COIN )
5339
5440 def create_basic_1p1c (self , wallet ):
55- low_fee_parent = wallet .create_self_transfer (fee_rate = Decimal ( DEFAULT_MIN_RELAY_TX_FEE ) / COIN , confirmed_only = True )
41+ low_fee_parent = wallet .create_self_transfer (fee_rate = 0 , confirmed_only = True )
5642 high_fee_child = wallet .create_self_transfer (utxo_to_spend = low_fee_parent ["new_utxo" ], fee_rate = 999 * Decimal (DEFAULT_MIN_RELAY_TX_FEE )/ COIN )
5743 package_hex_basic = [low_fee_parent ["hex" ], high_fee_child ["hex" ]]
5844 return package_hex_basic , low_fee_parent ["tx" ], high_fee_child ["tx" ]
@@ -61,25 +47,16 @@ def create_package_2outs(self, wallet):
6147 # First create a tester tx to see the vsize, and then adjust the fees
6248 utxo_for_2outs = wallet .get_utxo (confirmed_only = True )
6349
64- low_fee_parent_2outs_tester = wallet .create_self_transfer_multi (
65- utxos_to_spend = [utxo_for_2outs ],
66- num_outputs = 2 ,
67- )
68-
69- # Target 1sat/vB so the number of satoshis is equal to the vsize.
70- # Round up. The goal is to be between min relay feerate and mempool min feerate.
71- fee_2outs = ceil (low_fee_parent_2outs_tester ["tx" ].get_vsize () / 2 )
72-
7350 low_fee_parent_2outs = wallet .create_self_transfer_multi (
7451 utxos_to_spend = [utxo_for_2outs ],
7552 num_outputs = 2 ,
76- fee_per_output = fee_2outs ,
53+ fee_per_output = 0 ,
7754 )
7855
7956 # Now create the child
8057 high_fee_child_2outs = wallet .create_self_transfer_multi (
8158 utxos_to_spend = low_fee_parent_2outs ["new_utxos" ][::- 1 ],
82- fee_per_output = fee_2outs * 100 ,
59+ fee_per_output = 10_000 ,
8360 )
8461 return [low_fee_parent_2outs ["hex" ], high_fee_child_2outs ["hex" ]], low_fee_parent_2outs ["tx" ], high_fee_child_2outs ["tx" ]
8562
@@ -93,7 +70,7 @@ def create_package_2p1c(self, wallet):
9370 return [parent1 ["hex" ], parent2 ["hex" ], child ["hex" ]], parent1 ["tx" ], parent2 ["tx" ], child ["tx" ]
9471
9572 def create_packages (self ):
96- # 1: Basic 1-parent-1-child package, parent 1sat /vB, child 999sat/vB
73+ # 1: Basic 1-parent-1-child package, parent 0sat /vB, child 999sat/vB
9774 package_hex_1 , parent_1 , child_1 = self .create_basic_1p1c (self .wallet )
9875
9976 # 2: same as 1, parent's txid is the same as its wtxid.
@@ -109,7 +86,7 @@ def create_packages(self):
10986 # Assemble return results
11087 packages_to_submit = [package_hex_1 , package_hex_2 , package_hex_3 , package_hex_4 ]
11188 # node0: sender
112- # node1: pre-received the children (orphan )
89+ # node1: pre-received the children (orphans, will be dropped on peer disconnect )
11390 # node3: pre-received the parents (too low fee)
11491 # All nodes receive parent_31 ahead of time.
11592 txns_to_send = [
@@ -127,9 +104,6 @@ def run_test(self):
127104 self .generate (self .wallet_nonsegwit , 10 )
128105 self .generate (self .wallet , 120 )
129106
130- self .log .info ("Fill mempools with large transactions to raise mempool minimum feerates" )
131- self .raise_network_minfee ()
132-
133107 # Create the transactions.
134108 self .wallet .rescan_utxos (include_mempool = True )
135109 packages_to_submit , transactions_to_presend = self .create_packages ()
@@ -141,17 +115,31 @@ def run_test(self):
141115 for tx in transactions_to_presend [i ]:
142116 peer .send_and_ping (msg_tx (tx ))
143117
118+ # The fee-having parent should be the only thing in mempools
119+ self .sync_mempools ()
120+ sufficient_parent = transactions_to_presend [2 ][0 ].txid_hex
121+ for i , node in enumerate (self .nodes ):
122+ # node1 has non-empty orphanage as well
123+ if i == 1 :
124+ assert_equal (len (self .nodes [i ].getorphantxs ()), 4 )
125+ else :
126+ assert_equal (self .nodes [i ].getorphantxs (), [])
127+
128+ assert_equal (node .getrawmempool (), [sufficient_parent ])
129+
144130 # Disconnect python peers to clear outstanding orphan requests with them, avoiding timeouts.
145131 # We are only interested in the syncing behavior between real nodes.
146132 for i in range (self .num_nodes ):
147133 self .nodes [i ].disconnect_p2ps ()
134+ self .wait_until (lambda : len (self .nodes [i ].getorphantxs ()) == 0 )
148135
149136 self .log .info ("Submit full packages to node0" )
150137 for package_hex in packages_to_submit :
151138 submitpackage_result = self .nodes [0 ].submitpackage (package_hex )
152139 assert_equal (submitpackage_result ["package_msg" ], "success" )
153140
154141 self .log .info ("Wait for mempools to sync" )
142+ self .wait_until (lambda : len (self .nodes [0 ].getrawmempool ()) == 9 )
155143 self .sync_mempools ()
156144
157145
0 commit comments