From 99c0592612bdcd9d4634433f5ccfb408a3128f2c Mon Sep 17 00:00:00 2001 From: Ken Sedgwick Date: Wed, 12 Aug 2026 14:55:09 -0700 Subject: [PATCH] tests/boltz/test_claimtxhandler_scoped_update.cpp: Also cover the apiAccess predicate. Both inserted rows used the same apiAccess, so the test would not catch a claim UPDATE scoped by swapId alone. Add a third row sharing swapA's swapId under a different apiAccess; the single-stamped-row count assertion now fails if either predicate is dropped. Verified: a swapId-only variant fails the count assertion. Prompted by review on #326. --- .../boltz/test_claimtxhandler_scoped_update.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/boltz/test_claimtxhandler_scoped_update.cpp b/tests/boltz/test_claimtxhandler_scoped_update.cpp index 4fcc148..dc1e318 100644 --- a/tests/boltz/test_claimtxhandler_scoped_update.cpp +++ b/tests/boltz/test_claimtxhandler_scoped_update.cpp @@ -140,8 +140,8 @@ int main() { auto env = MockEnv(broadcast_called); auto signer = MockSigner(); - auto insert_swap = [&](std::string swapId) { - return db.transact().then([&, swapId](Sqlite3::Tx tx) { + auto insert_swap = [&](std::string apiAccess, std::string swapId) { + return db.transact().then([&, apiAccess, swapId](Sqlite3::Tx tx) { tx.query(R"QRY( INSERT INTO "BoltzServiceFactory_rsub" ( apiAccess @@ -168,7 +168,7 @@ int main() { , '' ); )QRY") - .bind(":apiAccess", api) + .bind(":apiAccess", apiAccess) .bind(":tweak", tweak) .bind(":preimage", preimage) .bind(":destinationAddress", addr) @@ -188,9 +188,15 @@ int main() { tx.query_execute(schema); tx.commit(); /* Two swaps in flight at once. */ - return insert_swap("swapA"); + return insert_swap(api, "swapA"); }).then([&]() { - return insert_swap("swapB"); + return insert_swap(api, "swapB"); + }).then([&]() { + /* A third swap with the same swapId under a different + * apiAccess, so the test fails if the apiAccess + * predicate is dropped from the update. + */ + return insert_swap("other-api", "swapA"); }).then([&]() { /* Claim the first swap. */ auto handler = Boltz::Detail::ClaimTxHandler::create(