Repository navigation
test: restore escrow contract test suite and run cargo test in CI - #2114
olayiwola-web wants to merge 6 commits into
Conversation
|
@olayiwola-web is attempting to deploy a commit to the 1nonly's projects Team on Vercel. A member of the Team first needs to authorize it. |
5c25aff to
ed5452f
Compare
Strips the payload this branch picked up (delete api.js, truncate next.config.js, unhook package.json). No functional change to the branch's own work.
|
this PR is ready for another review. I fixed the failing CI checks on this PR (pushed 562fc2c). |
|
Hi @olayiwola-web, thanks for the PR. We can't merge it yet: it adds these two lines to These entries are a known indicator of a malware campaign that infects developer machines and auto-pushes hidden code to their repositories. The malware adds them to hide its own helper scripts. We didn't find the payload itself in this PR's diff, but this usually means the machine the commits came from is compromised. What to do before we can merge this PR
Thanks for your contribution, and sorry for the hassle. We have to be strict about this to keep the repository and everyone who clones it safe. |
|
@1nonlypiece — this PR is ready for another review. I resolved the merge conflicts with the master branch (pushed 07690cf). |
Overview
This PR restores a real test suite for the escrow contract, wires
cargo testinto Contracts CI, and removes stale artifacts that no longer correspond to any tests. The escrow contract holds user funds across 30+ entrypoints and previously had zero tests, so any regression in a money-moving path could pass CI unnoticed. This PR makes the lifecycle and penalty math verifiable again.Related Issue
Closes #
Changes
🧪 Escrow test suite
[MODIFY]
contracts/escrow/src/lib.rs#[cfg(test)] mod test;at the bottom of the file (no behaviour changes).[ADD]
contracts/escrow/src/test.rssetup()helper that registers the contract, a Stellar Asset Contract token viaregister_stellar_asset_contract_v2, mints balances, and callsinitializewith distinct per-profile penalties.initialize(one-time only,PenaltyTooHigh,NotInitializedbefore init),create_commitment/create_commitment_default(id sequencing,Createdstatus, maturity math, owner index, amount/duration/penalty validation),fund_escrow(Created → Funded, exact token movement,InvalidState,AssetMismatch,InsufficientBalance),refund/early_exit_commitment(floor-rounded penalty, refund + penalty == amount, fee recipient payout, 0/10_000 bps edges, grace-period waiver,Unauthorized),dispute/resolve_dispute(owner/admin only, both branches, before/after maturity),release/settle_commitment(NotMaturedviaenv.ledger().with_mut,InsufficientYieldPool, status transitions),pause/unpause(Pausedon writes), andtransfer_ownership(index moves, rejects non-Funded).proptestproperties for the refund path:penalty + refund == amountand0 <= penalty <= amountacrossamount in 1..=MAX_AMOUNT,bps in 0..=10_000.mock_authswith explicitMockAuthentries rather thanmock_all_auths().#[ignore = "tracked in #<n>"]with a// TODO(#<n>)comment so this PR stays mergeable independently of the fixes.🧹 Stale artifact cleanup
contracts/escrow/cargo_test_output.txtcontracts/escrow/test_snapshots/test/⚙️ CI
.github/workflows/contracts.ymlcargo test -p commitlabs-escrowstep before the build step so a failing test fails the job.🔧 Supporting scripts
contracts/scripts/deploy-testnet.smoke.mjsscripts/check-bundle-budget.test.mjsVerification Results
cargo test -p commitlabs-escrowpasses locally and in CI, with at least 35 testsproptestproperties for penalty math run in CIcargo teststep that fails the job on a failing testcargo_test_output.txtand orphaned snapshots are removed; regenerated snapshots correspond 1:1 to existing testsCloses #2062