Skip to content

Model tests: the layout tiles the word, an update writes no handle bit, storage parity checks get and export - #169

Closed
thedavidmeister wants to merge 8 commits into
mainfrom
model-tests
Closed

thedavidmeister wants to merge 8 commits into
mainfrom
model-tests

Conversation

@thedavidmeister

@thedavidmeister thedavidmeister commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #163 (test-lib-support). Merges last in wave 2.

Closes #107
Closes #121
Closes #134
Closes #137
Closes #115
Closes #136
Closes #146
Closes #158
Closes #123
Closes #124
Closes #126
Closes #138
Closes #149

#123, #124, #126, #138 and #149 are split across W2b–W2e. This PR is their closer and merges after those.

Base

This branch merges origin/main (8220918), so it no longer carries #162 itself: #162 is on main. It also merges
test-lib-support at 02043b3, which contains #162, so the diff shows only this PR's three files.
Imports follow the split helpers: LibMemoryKVExport, LibMemoryKVHandle, LibMemoryKVKeys, LibMemoryKVAssert,
LibFreeMemory.

Owned files: test/src/lib/LibMemoryKV.types.t.sol, LibMemoryKV.crossFunction.t.sol,
LibMemoryKV.storageParity.t.sol. No other file is edited.

Changes

types (LibMemoryKV.types.t.sol)

crossFunction (LibMemoryKV.crossFunction.t.sol)

storageParity (LibMemoryKV.storageParity.t.sol)

Deviations from the plan

  • Amendment 4 replaces the plan's "library constants equal the test tree's" half of the A20 test. Only the tiling
    half remains, stated on src's constants, renamed testLayoutConstantsTileTheWord.
  • testSaturatedBuilderRefusesKeysReachingPastItsBase is added to pin the A31 guard in both directions.
  • Renames: testMultiGetSetSingle → testSetSequenceMatchesStorage, testMultiGetSetDouble →
    testTwoLiveStoresEachMatchTheirOwnStorage.
  • types' countPair(...) != 0 → exactly once (A46), beyond the plan's types bullet.
  • testSetSequenceMatchesStorage gas rises from μ 2.77M to μ ~10M: it now calls get and countPair per key.

Test counts

Owned files: 11 before (base 70a7ab3) → 12 after (types 6, crossFunction 3, storageParity 3). The one new test is
testSaturatedBuilderRefusesKeysReachingPastItsBase; the two zero-word tests become two layout tests.

Full suite, from the CI test job logs: 159 passed of 159 on base test-lib-support at 02043b3
(https://github.com/rainlanguage/rain.lib.memkv/actions/runs/35339867369) → 160 passed of 160 at head 90c3daa
(https://github.com/rainlanguage/rain.lib.memkv/actions/runs/35340530745).

QA

All probes: mutation-probe from rainlanguage/adversarial-mutation-test, base 70a7ab3 (the owned files before this
PR) vs head 83b25c2. The final head 90c3daa differs from 83b25c2 only in LibMemoryKV.gasClaims.t.sol, from
the base merge, which no probe below runs. Raw reports: /home/gildlab/artifacts/memkv/audit-2026-09-18/w2f/.

🤖 Generated with Claude Code

thedavidmeister and others added 6 commits September 18, 2026 10:51
The types test compares the library's layout constants, which #162 adds
to src, against the test tree's.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The layout test checks the library's LIST_COUNT, SLOT_BITS, POINTER_MASK,
COUNT_BIT_OFFSET and NODE_BYTES against the test tree's, and that the
count and fifteen head slots tile the 256-bit word (#123).

The two zero-word tests could not fail: any shift or mask of zero is
zero. They are replaced by a test that fills all fifteen lists and checks
the count and that each head slot points at its own list's node (#137).

The count and heads are read through lengthOf/headOf (#124, #149), and
the exports are checked exactly once with countPair (#149).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The asymmetry test snapshots every handle word before the update and
asserts each is identical after it, including the handle set returns
(#107). The header states what the file pins, with no mutation framing
(#121, #138).

buildSaturatedExternal checks that the decoded keys end at or below
SATURATED_BASE before it rewinds the free pointer, and a test pins the
boundary on both sides (#134). The layout constants come from the test
helpers and the pointer is positioned with setFreePointer (#123, #126).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
One assertion helper serves both multi-set tests: every key set reads
back through get with storage's value, is exported exactly once with it,
and the export is two words per distinct key (#115, #136). Each store
has its own storage oracle, both stores are checked only once both are
built, and the PAIRS_PER_STORE cap is documented (#115).

The fuzz struct NatSpec calls it a key/value pair; testSingleGetSet
names its local got and drops the no-op wrap/unwrap (#146, #158).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
origin/main carries #162, so this branch no longer carries it as its own
merge.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The test tree names no layout value, so the types, crossFunction and
storageParity tests read LibMemoryKV's constants directly. The constants
test keeps only what the constants must satisfy together: the count sits
above the last list and is the top slot, and POINTER_MASK is one slot wide
as both the widest pointer and the widest count.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@thedavidmeister thedavidmeister self-assigned this Sep 18, 2026
@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 57 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 64f84295-c812-4fe8-91ce-de71ea2df1d6

📥 Commits

Reviewing files that changed from the base of the PR and between e442de9 and 90c3daa.

📒 Files selected for processing (3)
  • test/src/lib/LibMemoryKV.crossFunction.t.sol
  • test/src/lib/LibMemoryKV.storageParity.t.sol
  • test/src/lib/LibMemoryKV.types.t.sol

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

thedavidmeister and others added 2 commits September 18, 2026 11:19
The helpers file is split into files named for what they hold; the owned
tests import from LibMemoryKVExport, LibMemoryKVHandle, LibMemoryKVKeys,
LibMemoryKVAssert and LibFreeMemory.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Brings in 02043b3, the export gas uniformity tolerance that fixes testExportGasIsUniformAcrossSlots (564 != 563).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@thedavidmeister
thedavidmeister changed the base branch from test-lib-support to main September 18, 2026 14:12
@thedavidmeister

Copy link
Copy Markdown
Contributor Author

Superseded by per-issue PRs: #107 → #174 (merged), #121 → #185 (merged), #134 → #187 (merged), #124 → #180 (merged), #146 → #183 (merged), #136 → #179, #115 → #186, #158 → #184, #137 → #188, #149 → #190, #123 → #192, #126 → #191, #138 → #189.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment