Wire dead test modules, add lending risk tests, and pin proxy stub behavior - #1043
Open
Ibinola wants to merge 1 commit into
Open
Wire dead test modules, add lending risk tests, and pin proxy stub behavior#1043Ibinola wants to merge 1 commit into
Ibinola wants to merge 1 commit into
Conversation
…havior Closes MettaChain#978 Closes MettaChain#979 Closes MettaChain#980 Closes MettaChain#981 - database: wire the extracted src/tests.rs into lib.rs so its six tests actually run instead of being flagged dead code. - oracle: wire src/tests.rs into the contract module and repair stale tests: give oracle_source_multisig_tests its own setup helper, replace the removed ink_env get_block_timestamp test API with ink::env::block_timestamp, and update two assertions whose expected behavior changed (missing properties now return a zeroed valuation, never-reported sources are exempt from staleness slashing). - lending: add risk-path coverage for margin position PnL boundaries (long/short/zero-delta/unknown id), liquidation threshold enforcement with post-liquidation state consistency, and the full restructuring approval flow including unauthorized parties and record cleanup. - proxy: interim stub test that pins deploy + dispatch while the real transparent-proxy reimplementation lands; documents that upgrade-path tests are required there. - workspace: allow clippy::clone_on_copy crate-wide; current nightly fires it inside ink!-generated storage accessors on a pristine main.
|
@Ibinola Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves four test-coverage issues in one coherent pass over the lending, proxy, oracle, and database crates.
Database (Closes #981)
contracts/database/src/tests.rswas extracted from the contract body but never included, so its six tests were compiled as dead code and never executed. The module is now wired intolib.rsbehind#[cfg(test)]and all six tests run and pass.Oracle (Closes #980)
Same story for the oracle's extracted test suite — wired it into the contract module, then repaired the staleness that had accumulated while the file was dead:
oracle_source_multisig_testscalled asetup_oracle()helper that only existed inside the siblingoracle_testsmodule; the helper is now defined per-module.ink_env::test_api::get_block_timestamp, which no longer exists in ink 5.1.1; replaced withink::env::block_timestamp::<DefaultEnvironment>().test_get_nonexistent_valuation_fails: unknown property ids now return a zeroed placeholder valuation (aggregation fallback) instead ofPropertyNotFound; the test now pins the zeroed fallback.test_auto_slash_on_staleness: sources that have never reported (last_report == 0) are exempt from staleness slashing; the fixture now records a nonzero report time so the scenario still exercises an actual stale source.Lending (Closes #978)
Added risk-path coverage to
src/test.rs:PositionNotFoundfor unknown ids.should_liquidate_loanandliquidate_loanrefuse; threshold breach → liquidation succeeds; post-state consistency (status persisted, double-liquidation rejected withLoanNotActive, non-Active loans no longer report liquidatable).false; lender completion applies new terms, marks the loanRestructured, removes the record, and re-approval fails withRestructuringNotFound.Proxy (Closes #979)
The crate is currently a documented stub. Added interim coverage pinning deploy + message dispatch, with a note that the planned transparent-proxy reimplementation must extend the module with upgrade-path tests (delegation works, upgrade admin-only, non-admin rejected) before landing.
Workspace clippy
Current nightly fires
clippy::clone_on_copyinside ink!-generated storage accessors on a pristine checkout of main, failing-D warningsCI for every PR. A crate-level#![allow(clippy::clone_on_copy)]with a comment is added to each affected lib root so this PR's own changes can be evaluated on their merits.Test plan
cargo +nightly fmt --checkcargo clippy --all-targets --all-features -- -D warningscargo test --all-features --workspace(0 failures; database 6, oracle 51, lending 48+1, proxy 1)