Skip to content

Commit

Permalink
test: test reorged v3 tx descendants sibling eviction
Browse files Browse the repository at this point in the history
  • Loading branch information
ismaelsadeeq committed Feb 10, 2024
1 parent e643ea7 commit 87fc7f0
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/functional/mempool_accept_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Copyright (c) 2024 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
from decimal import Decimal

from test_framework.messages import (
MAX_BIP125_RBF_SEQUENCE,
Expand Down Expand Up @@ -187,6 +188,35 @@ def test_v3_reorg(self):
# This is needed because generate() will create the exact same block again.
node.reconsiderblock(block[0])

@cleanup(extra_args=["-acceptnonstdtxn=1"])
def test_reorged_v3_tx_descendants_sibling_eviction(self):
node = self.nodes[0]
self.log.info("Test v3 transaction whose ancestor was reorged can have more than 1 sibling.")

ancestor_tx = self.wallet.send_self_transfer_multi(from_node=node, num_outputs=3, version=3)
self.check_mempool([ancestor_tx["txid"]])

block = self.generate(node, 1)
self.check_mempool([])

child_1 = self.wallet.send_self_transfer(from_node=node, version=3, utxo_to_spend=ancestor_tx["new_utxos"][0])
child_2 = self.wallet.send_self_transfer(from_node=node, version=3, utxo_to_spend=ancestor_tx["new_utxos"][1])
self.check_mempool([child_1["txid"], child_2["txid"]])

self.generate(node, 1)
self.check_mempool([])

node.invalidateblock(block[0])
self.check_mempool([ancestor_tx["txid"], child_1["txid"], child_2["txid"]])

# Increase the fee to create a conflicting transaction for child_1
child_1_conflict = self.wallet.send_self_transfer(from_node=node, version=3, utxo_to_spend=ancestor_tx["new_utxos"][0], fee_rate=Decimal("0.01"))

# Ensure child_1 and child_1_conflict are different transactions
assert (child_1_conflict["txid"] != child_1["txid"])
self.check_mempool([ancestor_tx["txid"], child_1_conflict["txid"], child_2["txid"]])
self.generate(node, 1)
self.check_mempool([])

@cleanup(extra_args=["-limitdescendantsize=10", "-datacarriersize=40000", "-acceptnonstdtxn=1"])
def test_nondefault_package_limits(self):
Expand Down Expand Up @@ -412,6 +442,7 @@ def run_test(self):
self.test_mempool_sibling()
self.test_v3_package_inheritance()
self.test_v3_in_testmempoolaccept()
self.test_reorged_v3_tx_descendants_sibling_eviction()


if __name__ == "__main__":
Expand Down

0 comments on commit 87fc7f0

Please sign in to comment.