Skip to content

Commit

Permalink
Merge #20428: tests: shrink feature_taproot transfer of funds tx
Browse files Browse the repository at this point in the history
7ffac12 tests: shrink feature_taproot transfer of funds tx (Anthony Towns)

Pull request description:

  When moving funds from node 1 to node 0 for the pre-activation tests, there can be a large number of inputs, potentially resulting in a tx that is larger than standardness rules allow, or that takes a long time to sign. This just takes the top 500 outputs, which is plenty (~90% of the wallet balance).

ACKs for top commit:
  luke-jr:
    utACK 7ffac12
  MarcoFalke:
    cr ACK 7ffac12

Tree-SHA512: 68445b4827dddb9a8e8614d61a68f5bbd7152557bf940be0a75741cb49deeff1566198da1a777ac66cb3fed93e64a30bf895875d6cc6ae9e48275e3febb620a6
  • Loading branch information
MarcoFalke committed Nov 20, 2020
2 parents fdd0685 + 7ffac12 commit 3d632c3
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions test/functional/feature_taproot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1442,17 +1442,23 @@ def run_test(self):
self.nodes[1].generate(101)
self.test_spenders(self.nodes[1], spenders_taproot_active(), input_counts=[1, 2, 2, 2, 2, 3])

# Transfer funds to pre-taproot node.
# Transfer value of the largest 500 coins to pre-taproot node.
addr = self.nodes[0].getnewaddress()

unsp = self.nodes[1].listunspent()
unsp = sorted(unsp, key=lambda i: i['amount'], reverse=True)
unsp = unsp[:500]

rawtx = self.nodes[1].createrawtransaction(
inputs=[{
'txid': i['txid'],
'vout': i['vout']
} for i in self.nodes[1].listunspent()],
outputs={addr: self.nodes[1].getbalance()},
} for i in unsp],
outputs={addr: sum(i['amount'] for i in unsp)}
)
rawtx = self.nodes[1].signrawtransactionwithwallet(rawtx)['hex']
# Transaction is too large to fit into the mempool, so put it into a block

# Mine a block with the transaction
block = create_block(tmpl=self.nodes[1].getblocktemplate(NORMAL_GBT_REQUEST_PARAMS), txlist=[rawtx])
add_witness_commitment(block)
block.rehash()
Expand Down

0 comments on commit 3d632c3

Please sign in to comment.