Skip to content

Commit 9365baa

Browse files
committed
test: add conflicting topology test case
We want to ensure that even if topologies that are acceptable are relaxed, like removing package-not-child-with-unconfirmed-parents, that we don't end up accepting packages we shouldn't.
1 parent 43a66c5 commit 9365baa

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/functional/rpc_packages.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
fill_mempool,
2222
)
2323
from test_framework.wallet import (
24+
COIN,
2425
DEFAULT_FEE,
2526
MiniWallet,
2627
)
@@ -237,6 +238,37 @@ def test_conflicting(self):
237238
{"txid": tx2["txid"], "wtxid": tx2["wtxid"], "package-error": "conflict-in-package"}
238239
])
239240

241+
# Add a child that spends both at high feerate to submit via submitpackage
242+
tx_child = self.wallet.create_self_transfer_multi(
243+
fee_per_output=int(DEFAULT_FEE * 5 * COIN),
244+
utxos_to_spend=[tx1["new_utxo"], tx2["new_utxo"]],
245+
)
246+
247+
testres = node.testmempoolaccept([tx1["hex"], tx2["hex"], tx_child["hex"]])
248+
249+
assert_equal(testres, [
250+
{"txid": tx1["txid"], "wtxid": tx1["wtxid"], "package-error": "conflict-in-package"},
251+
{"txid": tx2["txid"], "wtxid": tx2["wtxid"], "package-error": "conflict-in-package"},
252+
{"txid": tx_child["txid"], "wtxid": tx_child["wtxid"], "package-error": "conflict-in-package"}
253+
])
254+
255+
submitres = node.submitpackage([tx1["hex"], tx2["hex"], tx_child["hex"]])
256+
assert_equal(submitres, {'package_msg': 'conflict-in-package', 'tx-results': {}, 'replaced-transactions': []})
257+
258+
# Submit tx1 to mempool, then try the same package again
259+
node.sendrawtransaction(tx1["hex"])
260+
261+
submitres = node.submitpackage([tx1["hex"], tx2["hex"], tx_child["hex"]])
262+
assert_equal(submitres, {'package_msg': 'conflict-in-package', 'tx-results': {}, 'replaced-transactions': []})
263+
assert tx_child["txid"] not in node.getrawmempool()
264+
265+
# ... and without the in-mempool ancestor tx1 included in the call
266+
submitres = node.submitpackage([tx2["hex"], tx_child["hex"]])
267+
assert_equal(submitres, {'package_msg': 'package-not-child-with-unconfirmed-parents', 'tx-results': {}, 'replaced-transactions': []})
268+
269+
# Regardless of error type, the child can never enter the mempool
270+
assert tx_child["txid"] not in node.getrawmempool()
271+
240272
def test_rbf(self):
241273
node = self.nodes[0]
242274

0 commit comments

Comments
 (0)