Skip to content

test(reservations): M2 test-coverage backfill (7 of 8 items) - #4280

Draft
piotr-roslaniec wants to merge 3 commits into
m1/reservation-multisigner-integration-testfrom
m1/reservation-test-coverage-backfill
Draft

test(reservations): M2 test-coverage backfill (7 of 8 items)#4280
piotr-roslaniec wants to merge 3 commits into
m1/reservation-multisigner-integration-testfrom
m1/reservation-test-coverage-backfill

Conversation

@piotr-roslaniec

Copy link
Copy Markdown
Collaborator

Summary

Implements implementation-plan.md Milestone 2's test-coverage backfill:
7 of the 8 listed items. Stacked on m1/reservation-multisigner-integration-test
(#4279), tip
cb4334627.

The 8th item (ValidateReservationAnchorProposal/
ValidateReservationReanchorProposal tests) is explicitly deferred - it
needs go-ethereum simulated-backend test infrastructure that doesn't
exist anywhere in pkg/chain/ethereum today, well beyond the plan's
0.5-day estimate. See docs/spec/reservations/m1-keep-core-readiness/01-gap-analysis.md's
new Minor row for the full finding.

Change

pkg/tbtc/reservation_test.go

  • TestAssembleReservationAnchorTransaction: happy-path output shape
    (1-in-1-out, deposit value minus fee, P2WPKH to the target wallet). Also
    doubles as the golden reference for pkg/tbtcpg's dedup test below.
  • TestAssembleReservationReanchorTransaction: same shape assertion for
    the re-anchor sibling.

pkg/chain/ethereum/tbtc_test.go

  • TestConvertReservationParametersFromAbiType: full 10-tuple field
    mapping, every field a distinct non-zero value so a swapped or dropped
    field can't hide behind a shared zero default.
  • TestConvertReservationFromAbiType_DropsCumulativeReanchorFee: pins the
    intentional CumulativeReanchorFee omission and verifies every other
    field maps correctly around it.

pkg/tbtcpg/reservation_acceptance_test.go

  • TestReservationAcceptanceTask_BoundaryChecks: 6-case table (at-limit
    accepts / one-over rejects) for MaxReservationsPerWallet,
    ReservationMinAmount, and ReservationMaxTotalAmount -
    TestReservationAcceptanceTask_BoundedLookback only ever used these
    fields as fixture data, never at the actual boundary.
  • TestReservationAcceptanceTask_ReservationParametersFetchedLive: runs
    the same task twice against the same deposit, mutating
    ReservationMinAmount between calls - proves ReservationParameters()
    is fetched live per call, not cached on the task.

pkg/tbtcpg/reservation_anchor_dedup_test.go (new file, package tbtcpg - internal, not tbtcpg_test - to reach the unexported function)

  • TestBuildReservationAnchorTransaction_MatchesPkgTbtcGoldenOutput:
    buildReservationAnchorTransaction (pkg/tbtcpg) and
    assembleReservationAnchorTransaction (pkg/tbtc) are independently
    maintained copies of the same logic, both unexported in different
    packages - Go's visibility rules make a single test calling both
    impossible without a production-code change. This test and pkg/tbtc's
    TestAssembleReservationAnchorTransaction instead pin the identical
    golden input/output values (deposit 100000, fee 1500, output 98500) in
    each package, catching either copy drifting from the other. The
    underlying duplication itself is unresolved - extracting a shared
    exported helper is the real fix, deferred as a larger (L, 1-2 day)
    change per decision this session.

Testing

  • go test ./pkg/tbtc/... ./pkg/tbtcpg/... ./pkg/chain/ethereum/...:
    519/519 pass.
  • go build ./... && go test ./...: full repo, 49 packages, zero FAIL.
  • gofmt -l / go vet: clean on all 4 changed/new files.

Not in this PR

  • ValidateReservationAnchorProposal/ValidateReservationReanchorProposal
    tests - deferred, documented in the gap-analysis doc.
  • Extracting a shared buildReservationAnchorTransaction/
    assembleReservationAnchorTransaction helper to eliminate the
    duplication for good - the golden-value tests catch drift but don't fix
    the root duplication.

Implementation-plan.md Milestone 2, all items except the one item
(ValidateReservationAnchorProposal/ValidateReservationReanchorProposal
tests) that needs simulated-backend test infrastructure this
repository doesn't have - see docs/spec/reservations/m1-keep-core-
readiness/01-gap-analysis.md's new Minor row for that finding, and
the item-8 dedup row for the golden-value equivalence decision.

pkg/tbtc/reservation_test.go:
- TestAssembleReservationAnchorTransaction: happy-path output shape
  (1-in-1-out, deposit value minus fee, P2WPKH to the target wallet).
  Also doubles as the golden reference for pkg/tbtcpg's dedup test.
- TestAssembleReservationReanchorTransaction: same shape assertion
  for the re-anchor sibling.

pkg/chain/ethereum/tbtc_test.go:
- TestConvertReservationParametersFromAbiType: full 10-tuple field
  mapping, every field set to a distinct non-zero value so a swapped
  or dropped field can't hide behind a shared zero default.
- TestConvertReservationFromAbiType_DropsCumulativeReanchorFee: pins
  the intentional CumulativeReanchorFee omission and verifies every
  other field maps correctly around it.

pkg/tbtcpg/reservation_acceptance_test.go:
- TestReservationAcceptanceTask_BoundaryChecks: 6-case table
  (at-limit accepts / one-over rejects) for MaxReservationsPerWallet,
  ReservationMinAmount, and ReservationMaxTotalAmount -
  BoundedLookback only ever used these as fixture data, never at the
  actual boundary.
- TestReservationAcceptanceTask_ReservationParametersFetchedLive:
  runs the same task twice against the same deposit, mutating
  ReservationMinAmount between calls - proves ReservationParameters()
  is fetched live per call, not cached on the task.

pkg/tbtcpg/reservation_anchor_dedup_test.go (new file, package
tbtcpg - internal, not tbtcpg_test - to reach the unexported
function):
- TestBuildReservationAnchorTransaction_MatchesPkgTbtcGoldenOutput:
  buildReservationAnchorTransaction (pkg/tbtcpg) and
  assembleReservationAnchorTransaction (pkg/tbtc) are independently
  maintained copies of the same logic, both unexported in different
  packages - Go's visibility rules make a single test calling both
  impossible without a production-code change. This test and
  pkg/tbtc's TestAssembleReservationAnchorTransaction instead pin the
  identical golden input/output values (deposit 100000, fee 1500,
  output 98500) in each package, catching either copy drifting from
  the other without eliminating the underlying duplication (real fix
  deferred, per decision this session).

Testing:
- go test ./pkg/tbtc/... ./pkg/tbtcpg/... ./pkg/chain/ethereum/...:
  519/519 pass.
- go build ./... && go test ./...: full repo, 49 packages, zero FAIL.
- gofmt -l / go vet: clean on all 4 changed/new files.
@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…servation-test-coverage-backfill

Reconciles this branch's M2 test-coverage backfill work with several
independent changes on the base: dead-code removal, the conversion
function rename, and a new net-of-fee minimum-amount gate.

- Deleted pkg/tbtcpg/reservation_anchor_dedup_test.go entirely: its
  sole test pinned buildReservationAnchorTransaction (tbtcpg package)
  against a golden value shared with pkg/tbtc's sibling function, to
  catch drift between the two independently-maintained duplicate
  implementations. c48d17b deleted buildReservationAnchorTransaction
  from production code (reservation_acceptance.go now derives the
  reservation key from the anchor UTXO instead of reassembling the
  transaction) - the duplication this test existed to guard against no
  longer exists, so the guard is moot, not just broken.
- pkg/tbtc/reservation_test.go: fixed two tests
  (TestAssembleReservationAnchorTransaction,
  TestAssembleReservationReanchorTransaction) left calling the
  pre-rename lowercase assembleReservation{Anchor,Reanchor}Transaction;
  both functions were exported and gained a required
  *ReservationAction parameter (fee-ceiling guard) upstream. Updated
  call sites and doc comments; both tests' own value remains real
  (happy-path output-shape coverage the nearby InputValidation test
  doesn't provide).
- pkg/chain/ethereum/tbtc_test.go: this branch and the base
  independently added TestConvertReservationParametersFromAbiType with
  different fixture values (both equally rigorous); kept this branch's
  version (doc-linked to the gap-analysis finding it backfills) and
  the base's two genuinely new, non-overlapping tests
  (TestConvertReservationFromAbiType,
  TestConvertReservationActionFromAbiType).
- pkg/tbtcpg/reservation_acceptance_test.go: same collision pattern -
  this branch's TestReservationAcceptanceTask_ReservationParametersFetchedLive
  and the base's TestReservationAcceptanceTask_GetWalletError are
  unrelated tests that landed at the same insertion point; kept both.
  Fixed three latent fixture gaps this merge surfaced in this branch's
  own ReservationParametersFetchedLive/BoundaryChecks tests (pre-dating
  this merge, never run against current production code until now):
  missing EndBlock on the DepositRevealedEventFilter, missing Vault on
  the DepositRevealedEvent (both added by c48d17b's EndBlock/vault-
  match hardening), and a missing fee-oracle rate
  (SetEstimateSatPerVByteFee) now required by dynamic fee estimation.
  Also corrected the 'exactly at minimum' boundary case's deposit
  amount: proposeReservationAcceptance now enforces the minimum against
  the *net-of-fee* anchor value, not the gross deposit amount, so the
  boundary must be reservationMinAmount + the fixture's deterministic
  710-sat fee, not reservationMinAmount itself.

Full repo: zero FAIL.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant