Skip to content

Adding Invariant Tests#442

Open
Hakob23 wants to merge 12 commits intov2.6.0from
test/FLY-2167
Open

Adding Invariant Tests#442
Hakob23 wants to merge 12 commits intov2.6.0from
test/FLY-2167

Conversation

@Hakob23
Copy link
Collaborator

@Hakob23 Hakob23 commented Mar 3, 2026

What

Adding invariant tests, including both isolated and integrated test suites.
The changes include

  • addition of an isolated test suite for discoveryContract
  • addition of SystemInvariant test suite for integrated invariant testing
  • addition of handler contracts for all invariant tests
  • refactoring of invariant tests to use the handlers

Task

https://rsklabs.atlassian.net/browse/FLY-2167

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails
npm/@rsksmart/btc-transaction-solidity-helper 0.3.0-beta 🟢 6.5
Details
CheckScoreReason
Binary-Artifacts🟢 10no binaries found in the repo
Branch-Protection🟢 8branch protection is not maximal on development and all release branches
CI-Tests🟢 1014 out of 14 merged PRs checked by a CI test -- score normalized to 10
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
Code-Review🟢 3Found 5/14 approved changesets -- score normalized to 3
Contributors🟢 3project has 1 contributing companies or organizations -- score normalized to 3
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Dependency-Update-Tool🟢 10update tool detected
Fuzzing⚠️ 0project is not fuzzed
License🟢 10license file detected
Maintained⚠️ 00 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Packaging⚠️ -1packaging workflow not detected
Pinned-Dependencies🟢 10all dependencies are pinned
SAST🟢 8SAST tool is not run on all commits -- score normalized to 8
Security-Policy🟢 10security policy file detected
Signed-Releases⚠️ -1no releases found
Token-Permissions🟢 10GitHub workflow tokens follow principle of least privilege
Vulnerabilities⚠️ 014 existing vulnerabilities detected

Scanned Files

  • package-lock.json

@Hakob23 Hakob23 marked this pull request as ready for review March 4, 2026 19:15
@Hakob23 Hakob23 requested a review from a team as a code owner March 4, 2026 19:15
@Hakob23 Hakob23 self-assigned this Mar 4, 2026
@Hakob23 Hakob23 requested a review from Luisfc68 March 4, 2026 19:21
Copy link
Collaborator

@Luisfc68 Luisfc68 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR is approved, my comments are more related to the definition of some invariants, but not to the code itself, I think the discussion about the invariants should be taken separately as its not so simple, but as PoC the code LGTM

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a suite of Foundry invariant tests (isolated + integrated) for the Flyover system, refactoring invariant interactions through dedicated handler contracts, and includes a small PegInContract refactor to remove an opcode import dependency.

Changes:

  • Introduces invariant handler contracts for Discovery, CollateralManagement, PegIn, PegOut, and a cross-contract System handler.
  • Adds/updates invariant test suites to use the handlers, including a new integrated SystemInvariantTest.
  • Updates Foundry invariant configuration (runs, depth, fail_on_revert) and removes OpCodes import usage in PegInContract.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/invariant/handlers/HandlerBase.sol Shared utilities/constants for invariant handlers (quote staging, bookkeeping helpers).
test/invariant/handlers/DiscoveryHandler.sol Fuzzable actions for Discovery invariant testing (register/toggle/update).
test/invariant/handlers/CollateralHandler.sol Fuzzable actions for CollateralManagement invariant testing (add/slash/resign/withdraw).
test/invariant/handlers/PegInHandler.sol Fuzzable actions for PegIn invariant testing (deposit/withdraw + LP tracking).
test/invariant/handlers/PegOutHandler.sol Fuzzable actions for PegOut invariant testing (deposit/refund/withdraw + active quote tracking).
test/invariant/handlers/SystemHandler.sol Cross-contract fuzzable actions + system-level ghost accounting.
test/invariant/DiscoveryInvariant.t.sol New Discovery invariants wired to DiscoveryHandler.
test/invariant/CollateralInvariant.t.sol Refactors Collateral invariants to use CollateralHandler and adds conservation assertions.
test/invariant/PegInInvariant.t.sol Refactors PegIn invariants to use PegInHandler and tightens accounting checks.
test/invariant/PegOutInvariant.t.sol Refactors PegOut invariants to use PegOutHandler and expands accounting invariants.
test/invariant/SystemInvariant.t.sol New integrated/system invariant suite covering cross-contract solvency + conservation.
src/PegInContract.sol Replaces OpCodes constants usage with locally defined opcode bytes.
foundry.toml Adds [invariant] configuration for invariant runs/depth/revert behavior.

You can also share your feedback on Copilot code review. Take the survey.

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.

3 participants