Skip to content

Commit

Permalink
[functional test] package RBF network
Browse files Browse the repository at this point in the history
  • Loading branch information
glozow committed Nov 9, 2023
1 parent c9d82ee commit 57a2bab
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
14 changes: 6 additions & 8 deletions src/txorphanage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,12 @@ CTransactionRef TxOrphanage::MaybeGetSingleChild(const CTransactionRef& parent,
const auto it_by_prev = m_outpoint_to_orphan_it.find(COutPoint(parent->GetHash(), i));
if (it_by_prev != m_outpoint_to_orphan_it.end()) {
for (const auto& elem : it_by_prev->second) {
if (elem->second.fromPeer == peer) {
// If we have already found an orphan who is missing this parent, return
// nullptr because we don't have a way of deciding which child to use.
if (child_found) {
return nullptr;
} else {
child_found = elem->second.tx;
}
// If we have already found an orphan who is missing this parent, return
// nullptr because we don't have a way of deciding which child to use.
if (child_found) {
return nullptr;
} else {
child_found = elem->second.tx;
}
}
}
Expand Down
24 changes: 19 additions & 5 deletions test/functional/p2p_1p1c_package_relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,25 @@ def create_packages(self):
self.transactions_to_presend[1] = [high_fee_child["tx"]]
# Parent would have been previously rejected
self.transactions_to_presend[3] = [low_fee_parent["tx"]]
self.total_txns += 2

# Basic v3 package, same as above but parent is 0-fee
v3_zero_fee_parent = self.wallet.create_self_transfer(fee_rate=0, fee=0, version=3, confirmed_only=True)
v3_child = self.wallet.create_self_transfer(utxo_to_spend=v3_zero_fee_parent["new_utxo"], fee_rate=999*FEERATE_1SAT_VB, version=3)
utxo_for_v3 = self.wallet.get_utxo(confirmed_only=True)
utxo_conf_1 = self.wallet.get_utxo(confirmed_only=True)
v3_zero_fee_parent = self.wallet.create_self_transfer_multi(utxos_to_spend=[utxo_for_v3, utxo_conf_1], fee_per_output=0, version=3)
v3_child = self.wallet.create_self_transfer(utxo_to_spend=v3_zero_fee_parent["new_utxos"][0], fee_rate=99*FEERATE_1SAT_VB, version=3)
package_hex_v3 = [v3_zero_fee_parent["hex"], v3_child["hex"]]
self.packages_to_submit.append(package_hex_v3)
# Child should already be in orphanage
self.transactions_to_presend[1] = [v3_child["tx"]]
# Parent would have been previously rejected
self.transactions_to_presend[3] = [v3_zero_fee_parent["tx"]]
self.total_txns += 2

# v3 package to replace package_hex_v3 via package RBF
utxo_conf_2 = self.wallet.get_utxo(confirmed_only=True)
v3_replacement_parent = self.wallet.create_self_transfer_multi(utxos_to_spend=[utxo_for_v3, utxo_conf_2], fee_per_output=0, version=3)
v3_replacement_child = self.wallet.create_self_transfer(utxo_to_spend=v3_replacement_parent["new_utxos"][0], fee_rate=300*FEERATE_1SAT_VB, version=3)
package_hex_v3_rbf = [v3_replacement_parent["hex"], v3_replacement_child["hex"]]
self.replacement_packages.append(package_hex_v3_rbf)

def test_individual_logic(self):
node = self.nodes[0]
Expand Down Expand Up @@ -181,7 +188,7 @@ def run_test(self):
self.log.info("Check end-to-end package relay across multiple nodes")
self.packages_to_submit = []
self.transactions_to_presend = [[]] * self.num_nodes
self.total_txns = 0
self.replacement_packages = []

self.log.info("Create transactions and then mature the coinbases")
self.wallet.rescan_utxos(include_mempool=True)
Expand All @@ -208,6 +215,13 @@ def run_test(self):
self.log.info("Wait for mempools to sync")
self.sync_mempools(timeout=20)

self.log.info("Submit replacement package to node3")
for package_hex in self.replacement_packages:
self.nodes[3].submitpackage(package_hex)

self.log.info("Wait for mempools to sync")
self.sync_mempools(timeout=20)


if __name__ == '__main__':
PackageRelayTest().main()

0 comments on commit 57a2bab

Please sign in to comment.