|
28 | 28 | # Associated ScriptSig's to spend satisfy P2SH_1 and P2SH_2
|
29 | 29 | SCRIPT_SIG = [CScript([OP_TRUE, REDEEM_SCRIPT_1]), CScript([OP_TRUE, REDEEM_SCRIPT_2])]
|
30 | 30 |
|
| 31 | + |
31 | 32 | def small_txpuzzle_randfee(from_node, conflist, unconflist, amount, min_fee, fee_increment):
|
32 | 33 | """Create and send a transaction with a random fee.
|
33 | 34 |
|
@@ -69,6 +70,7 @@ def small_txpuzzle_randfee(from_node, conflist, unconflist, amount, min_fee, fee
|
69 | 70 |
|
70 | 71 | return (ToHex(tx), fee)
|
71 | 72 |
|
| 73 | + |
72 | 74 | def split_inputs(from_node, txins, txouts, initial_split=False):
|
73 | 75 | """Generate a lot of inputs so we can generate a ton of transactions.
|
74 | 76 |
|
@@ -97,6 +99,7 @@ def split_inputs(from_node, txins, txouts, initial_split=False):
|
97 | 99 | txouts.append({"txid": txid, "vout": 0, "amount": half_change})
|
98 | 100 | txouts.append({"txid": txid, "vout": 1, "amount": rem_change})
|
99 | 101 |
|
| 102 | + |
100 | 103 | def check_estimates(node, fees_seen):
|
101 | 104 | """Call estimatesmartfee and verify that the estimates meet certain invariants."""
|
102 | 105 |
|
@@ -189,22 +192,22 @@ def run_test(self):
|
189 | 192 | split_inputs(self.nodes[0], self.nodes[0].listunspent(0), self.txouts, True)
|
190 | 193 |
|
191 | 194 | # Mine
|
192 |
| - while (len(self.nodes[0].getrawmempool()) > 0): |
| 195 | + while len(self.nodes[0].getrawmempool()) > 0: |
193 | 196 | self.nodes[0].generate(1)
|
194 | 197 |
|
195 | 198 | # Repeatedly split those 2 outputs, doubling twice for each rep
|
196 | 199 | # Use txouts to monitor the available utxo, since these won't be tracked in wallet
|
197 | 200 | reps = 0
|
198 |
| - while (reps < 5): |
| 201 | + while reps < 5: |
199 | 202 | # Double txouts to txouts2
|
200 |
| - while (len(self.txouts) > 0): |
| 203 | + while len(self.txouts) > 0: |
201 | 204 | split_inputs(self.nodes[0], self.txouts, self.txouts2)
|
202 |
| - while (len(self.nodes[0].getrawmempool()) > 0): |
| 205 | + while len(self.nodes[0].getrawmempool()) > 0: |
203 | 206 | self.nodes[0].generate(1)
|
204 | 207 | # Double txouts2 to txouts
|
205 |
| - while (len(self.txouts2) > 0): |
| 208 | + while len(self.txouts2) > 0: |
206 | 209 | split_inputs(self.nodes[0], self.txouts2, self.txouts)
|
207 |
| - while (len(self.nodes[0].getrawmempool()) > 0): |
| 210 | + while len(self.nodes[0].getrawmempool()) > 0: |
208 | 211 | self.nodes[0].generate(1)
|
209 | 212 | reps += 1
|
210 | 213 | self.log.info("Finished splitting")
|
@@ -244,5 +247,6 @@ def run_test(self):
|
244 | 247 | self.log.info("Final estimates after emptying mempools")
|
245 | 248 | check_estimates(self.nodes[1], self.fees_per_kb)
|
246 | 249 |
|
| 250 | + |
247 | 251 | if __name__ == '__main__':
|
248 | 252 | EstimateFeeTest().main()
|
0 commit comments