Skip to content

finance/lending: set the test fixture's slots-per-year to a 200ms slot - #147

Open
mikemaccana wants to merge 1 commit into
mainfrom
claude/nifty-mccarthy-n0cta8
Open

mikemaccana wants to merge 1 commit into
mainfrom
claude/nifty-mccarthy-n0cta8

Conversation

@mikemaccana

Copy link
Copy Markdown
Collaborator

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_YEAR is 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_year from 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.rs
  • finance/lending/anchor-v1/programs/lending/tests/common/mod.rs
  • finance/lending/quasar/src/tests.rs

Tests

Several tests warped a literal 7_884_000 slots, which was a tenth of the old year. They now warp SLOTS_PER_YEAR / 10, so the "~0.1 year" they describe stays true whatever the constant is. That touches test_interest.rs and test_rounding.rs in both Anchor copies, and three tests in quasar's slot_warp module.

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, and cargo fmt --check passes 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

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
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.

2 participants