@@ -186,17 +186,18 @@ def verify_utxo_hash(self):
186
186
assert_equal (nodei_utxo_hash , node3_utxo_hash )
187
187
188
188
def generate_small_transactions (self , node , count , utxo_list ):
189
- FEE = 1000 # TODO: replace this with node relay fee based calculation
190
189
num_transactions = 0
191
190
random .shuffle (utxo_list )
192
191
while len (utxo_list ) >= 2 and num_transactions < count :
192
+ fee = 1000
193
193
tx = CTransaction ()
194
194
input_amount = 0
195
195
for _ in range (2 ):
196
196
utxo = utxo_list .pop ()
197
197
tx .vin .append (CTxIn (COutPoint (int (utxo ['txid' ], 16 ), utxo ['vout' ])))
198
198
input_amount += int (utxo ['amount' ] * COIN )
199
- output_amount = (input_amount - FEE ) // 3
199
+ output_amount = (input_amount - fee ) // 3
200
+ fee = input_amount - (3 * output_amount )
200
201
201
202
if output_amount <= 0 :
202
203
# Sanity check -- if we chose inputs that are too small, skip
@@ -205,6 +206,9 @@ def generate_small_transactions(self, node, count, utxo_list):
205
206
for _ in range (3 ):
206
207
tx .vout .append (CTxOut (output_amount , bytes .fromhex (utxo ['scriptPubKey' ])))
207
208
209
+ # ELEMENTS: add fee output
210
+ tx .vout .append (CTxOut (fee ))
211
+
208
212
# Sign and send the transaction to get into the mempool
209
213
tx_signed_hex = node .signrawtransactionwithwallet (tx .serialize ().hex ())['hex' ]
210
214
node .sendrawtransaction (tx_signed_hex )
@@ -234,7 +238,8 @@ def run_test(self):
234
238
# Main test loop:
235
239
# each time through the loop, generate a bunch of transactions,
236
240
# and then either mine a single new block on the tip, or some-sized reorg.
237
- for i in range (40 ):
241
+ # ELEMENTS: reduced iters to run in some "reasonable" amount of time (~6 hours)
242
+ for i in range (4 ):
238
243
self .log .info (f"Iteration { i } , generating 2500 transactions { self .restart_counts } " )
239
244
# Generate a bunch of small-ish transactions
240
245
self .generate_small_transactions (self .nodes [3 ], 2500 , utxo_list )
0 commit comments