finance/lending: set the test fixture's slots-per-year to a 200ms slot - #147
Open
mikemaccana wants to merge 1 commit into
Open
mikemaccana wants to merge 1 commit into
mikemaccana wants to merge 1 commit into
Conversation
Solana's slot time is going to 200ms under SIMD-0525's staged reduction, and the fixture assumes that end state: a year is 157,680,000 slots rather than the 78,840,000 a 400ms slot gave. The program reads slots_per_year from the reserve config and is unaffected; only the fixture constant and the comment deriving it change, in the Anchor v2, Anchor v1 and quasar copies alike. The tests that warped a hard-coded 7_884_000 slots (a tenth of the old year) now warp SLOTS_PER_YEAR / 10, so they keep meaning a tenth of a year whatever the constant is. No expected value depended on the constant's absolute size: every accrual assertion is a ratio or a sign check. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lj5nP2kuDKTN7iH2o8ZH4L
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.
What
Solana's slot time is going to 200ms under SIMD-0525's staged reduction, and the lending example's test fixture now assumes that end state:
SLOTS_PER_YEARis 157,680,000 (5 slots/second × 60 × 60 × 24 × 365) rather than the 78,840,000 a 400ms slot gave. The comment deriving it changes to match.The program is unaffected. It reads
slots_per_yearfrom the reserve config, which is exactly why the figure lives in a fixture rather than in the code.Where
All three copies of the example carry the same fixture, so all three change:
finance/lending/anchor/programs/lending/tests/common/mod.rsfinance/lending/anchor-v1/programs/lending/tests/common/mod.rsfinance/lending/quasar/src/tests.rsTests
Several tests warped a literal
7_884_000slots, which was a tenth of the old year. They now warpSLOTS_PER_YEAR / 10, so the "~0.1 year" they describe stays true whatever the constant is. That touchestest_interest.rsandtest_rounding.rsin both Anchor copies, and three tests in quasar'sslot_warpmodule.No expected value depended on the constant's absolute size. Every accrual assertion is a ratio (fees are a tenth of interest, halving the divisor doubles growth) or a sign check, and the divisor-scaling tests compare two reserves over the same elapsed slots.
Verification
All three test crates compile with
cargo test --no-run, andcargo fmt --checkpasses on the changed files. The suites themselves could not be executed in the authoring environment because the SBF toolchain (platform-tools v1.52) is only distributed as a GitHub release asset, which that environment cannot download. CI runs all three suites on this branch.🤖 Generated with Claude Code
https://claude.ai/code/session_01Lj5nP2kuDKTN7iH2o8ZH4L
Generated by Claude Code