Skip to content

Commit

Permalink
functional test with new submitpackage behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
instagibbs committed Nov 10, 2023
1 parent 29f31c8 commit 2344aa9
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions test/functional/mempool_ephemeral_anchor.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ def test_fee_having_parent(self):
del self.coins[-1]

package_hex0, package_txns0 = self.create_simple_package(parent_coin=parent_coin, parent_fee=1, child_fee=DEFAULT_FEE)
assert_raises_rpc_error(-26, "invalid-ephemeral-fee", node.submitpackage, package_hex0)
res = node.submitpackage(package_hex0)
assert res["tx-results"][package_txns0[0].getwtxid()]["error"] == "invalid-ephemeral-fee"
assert_equal(node.getrawmempool(), [])

# But works with no parent fee
Expand All @@ -192,7 +193,8 @@ def test_multianchor(self):
del self.coins[-1]

package_hex0, package_txns0 = self.create_simple_package(parent_coin=parent_coin, parent_fee=0, child_fee=DEFAULT_FEE, additional_outputs=[CTxOut(0, ANCHOR_SCRIPT)] * 2)
assert_raises_rpc_error(-26, "too-many-ephemeral-anchors", node.submitpackage, package_hex0)
res = node.submitpackage(package_hex0)
assert res["tx-results"][package_txns0[0].getwtxid()]["error"] == "too-many-ephemeral-anchors"
assert_equal(node.getrawmempool(), [])

self.generate(node, 1)
Expand Down Expand Up @@ -225,7 +227,8 @@ def test_prioritise_parent(self):
package_hex0, package_txns0 = self.create_simple_package(parent_coin=parent_coin, parent_fee=1, child_fee=DEFAULT_FEE)
parent_txid = node.decoderawtransaction(package_hex0[0])['txid']
node.prioritisetransaction(txid=parent_txid, dummy=0, fee_delta=COIN)
assert_raises_rpc_error(-26, "invalid-ephemeral-fee", node.submitpackage, package_hex0)
res = node.submitpackage(package_hex0)
assert res["tx-results"][package_txns0[0].getwtxid()]["error"] == "invalid-ephemeral-fee"
assert_equal(node.getrawmempool(), [])

# Also doesn't make it invalid if applied to the parent
Expand All @@ -249,7 +252,8 @@ def test_non_v3(self):
del self.coins[-1]

package_hex, package_txns = self.create_simple_package(parent_coin=parent_coin, parent_fee=0, child_fee=DEFAULT_FEE, version=2)
assert_raises_rpc_error(-26, "wrong-ephemeral-nversion", node.submitpackage, package_hex)
res = node.submitpackage(package_hex)
assert res["tx-results"][package_txns[0].getwtxid()]["error"] == "wrong-ephemeral-nversion"
assert_equal(node.getrawmempool(), [])

def test_unspent_ephemeral(self):
Expand All @@ -262,7 +266,8 @@ def test_unspent_ephemeral(self):
# Submit whole package, but anchor are unspent
package_hex0, package_txns0 = self.create_simple_package(parent_coin=parent_coin, parent_fee=0, child_fee=DEFAULT_FEE, spend_anchor=
0)
assert_raises_rpc_error(-26, "missing-ephemeral-spends", node.submitpackage, package_hex0)
res = node.submitpackage(package_hex0)
assert "missing-ephemeral-spends" in res["tx-results"][package_txns0[0].getwtxid()]["error"]
assert_equal(node.getrawmempool(), [])

# Individual submission also fails
Expand Down Expand Up @@ -487,12 +492,14 @@ def test_sponsor_swap(self):
version=3
)

# sendraw for single child_b propagates, but not the submitpackage?
# Submit a + b + c ancestor package, (a) is rejected for not spending parent anchors
assert_raises_rpc_error(-26, "ephemeral-anchor-unspent, tx does not spend all parent ephemeral anchors", node.submitpackage, [child_a["hex"], child_b["hex"], child_c["hex"]])
res = node.submitpackage([child_a["hex"], child_b["hex"], child_c["hex"]])
assert res["tx-results"][child_a["wtxid"]]["error"] == "ephemeral-anchor-unspent, tx does not spend all parent ephemeral anchors"
assert "error" not in res["tx-results"][child_b["wtxid"]]
assert res["tx-results"][child_c["wtxid"]]["error"] == "bad-txns-inputs-missingorspent"

# Only the sponsor RBF makes it into mempool, parent is evicted and other descendants have been rejected for V3 violations
# self.sync_all() # Check for propagation FIXME: submitpackage's child_b doesnt propagate unless sent via sendrawtansaction...
self.sync_all() # Check for propagation FIXME: submitpackage's child_b doesnt propagate unless sent via sendrawtansaction...
assert_equal(node.getrawmempool(), [child_b["txid"]])

# Mining everything
Expand Down

0 comments on commit 2344aa9

Please sign in to comment.