Skip to content

test: assert storage creation-fee burn through the e2e path#460

Merged
adamkrellenstein merged 1 commit into
feat/storage-economicsfrom
test/storage-fee-burn-e2e
Jun 3, 2026
Merged

test: assert storage creation-fee burn through the e2e path#460
adamkrellenstein merged 1 commit into
feat/storage-economicsfrom
test/storage-fee-burn-e2e

Conversation

@adamkrellenstein

@adamkrellenstein adamkrellenstein commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Stacked on #441 (feat/storage-economics). Closes part of the economic-e2e gap surfaced by the test-strategy audit: no test asserted an economic state transition through block processing.

What

filestorage_create_and_get previously asserted the storage creation fee υ_f was charged (fee > 0) but not that it was actually burned from total supply. This adds a supply-conservation assertion around create_agreement:

  • total supply strictly decreases across the call (the fee is burned), and
  • the drop is at least the returned created.fee (the remainder is gas, also burned).

filestorage_create_and_get is part of the dual-mode test_file_storage_regtest body, so the assertion runs:

  • in-process via the _local variant (verified locally), and
  • end-to-end via the regtest variant in CI — a mined Bitcoin block → indexer → contract → asserted supply change.

That's the missing leg: an economic state transition asserted through real block processing, not just an in-process property loop.

Design decisions

  • >= fee, not == fee. The supply drop is fee + gas (gas is also burned), so an exact-equality assertion is wrong; the robust invariant is strict decrease plus drop ≥ fee. Confirmed empirically (the exact form failed by exactly the gas amount).
  • Reused an existing dual-mode test rather than adding a new one — filestorage_create_and_get already uses a real PoR descriptor that passes in both lite and regtest modes, avoiding the trivial-root rejection that a fresh make_descriptor would hit under regtest.
  • Added a token import! to the module to read total_supply (mirrors staking_contract.rs).

Scope note

The deeper economic-e2e paths — ordering-reward accrual and challenge-failure → slash through block processing — remain blocked on the reactor↔economics wiring (#442) and are out of scope here. This PR covers the user-driven path (creation-fee burn) that is drivable end-to-end today.

Merge order

Touches native_filestorage_contract.rs, which #456 and #452 also modify. Merge after #441; coordinate with #452 (impl) / #456 (property tests) — additive changes, rebase whichever merges last.

🤖 Generated with Claude Code


Note

Low Risk
Test-only changes to contract integration tests; no production logic or auth paths modified.

Overview
Extends filestorage_create_and_get so storage agreement creation is checked against token total supply, not only that created.fee > 0. The test now snapshots supply before/after create_agreement, asserts supply strictly decreases, and that the drop is at least the creation fee υ_f (allowing additional burn from gas).

A token WIT import! is added so the test can call token::total_supply. Because this helper runs under run_regtest / test_file_storage_regtest, the same assertions apply in-process and on the regtest path (mined block → indexer → contract).

Reviewed by Cursor Bugbot for commit e99dfcc. Bugbot is set up for automated code reviews on this repo. Configure here.

The storage tests asserted the creation fee υ_f was *charged* (fee > 0) but not
that it was actually *burned from total supply* through the execution path.
Added a supply-conservation assertion to filestorage_create_and_get: total
supply strictly decreases across create_agreement, by at least the returned fee
(the remainder is gas, also burned).

filestorage_create_and_get runs in both modes, so this is verified in-process by
the _local variant and end-to-end — mined Bitcoin block → indexer → contract →
asserted supply change — by the regtest variant in CI. Closes part of the
economic-e2e gap: an economic state transition asserted through block processing,
not just an in-process property loop. Required adding a token import! to the
module to read total_supply.
@adamkrellenstein
adamkrellenstein merged commit f9763da into feat/storage-economics Jun 3, 2026
8 checks passed
@adamkrellenstein
adamkrellenstein deleted the test/storage-fee-burn-e2e branch June 3, 2026 13:16
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