Skip to content

test: one CloneFactoryTest base for the factory fixture and the NewClone assertion - #246

Open
thedavidmeister wants to merge 3 commits into
mainfrom
2026-09-21-issue-151-clone-factory-test-base
Open

thedavidmeister wants to merge 3 commits into
mainfrom
2026-09-21-issue-151-clone-factory-test-base

Conversation

@thedavidmeister

Copy link
Copy Markdown
Contributor

Closes #151

Two multi-line patterns were copy-pasted across the suite with no shared test
base:

  • The factory fixture — doc comment, TestCloneFactory internal immutable I_CLONE_FACTORY; and the constructor that news it — in four contracts
    (cloneDeterministic.t.sol, cloneDeterministicOpenSalt.t.sol,
    cloneAndInitialize.t.sol, ICloneableV2.initialize.t.sol).
  • The NewClone decode — emitter, the hand-written
    keccak256("NewClone(address,address,address,bytes32,bytes)") topic 0 and the
    abi.encode(...) data compare — in three places, so the event-signature
    literal was maintained by hand in three copies.

test/abstract/CloneFactoryTest.sol now holds both: the immutable with its
constructor, and assertNewClone(entry, sender, implementation, clone, salt, data). The four contracts inherit it and drop their field, constructor and
inline log blocks. Net -53/+13 in the four, plus the 42-line base.

The signature stays a written-out literal rather than a reference to the
interface's declaration: an assertion that imported the declaration would move
in lockstep with it and could not discriminate a drift, which is the same reason
TestCloneable writes out keccak256("ICloneableV2.initialize") instead of
importing ICLONEABLE_V2_SUCCESS.

The immutable keeps its current I_CLONE_FACTORY spelling — the storage-class
naming of these test immutables is #129/#132, a separate PR, and renaming here
would collide with it.

Deliberate deviation from the issue's proposed fix: the base is
pragma solidity =0.8.25, not ^0.8.25. The org rule floats lib/abstract files
because published src/ is compiled by downstream consumers; a test-side base
is only ever compiled in this repo, and this repo's CLAUDE.md says tests pin
=0.8.25. rain.flare's test/abstract/FtsoTest.sol pins the same way. Say the
word and it flips.

Built on #208 (issue #177, the no-op bytes32(uint256(...)) topic-0 cast).
That PR's commit is in this branch because the three inline log blocks this one
deletes are the lines it edits — merging the two independently would resolve
textually to a helper that still carries the casts. Land #208 first and this
rebases to nothing; its diff will disappear from this PR.

QA

  • Discriminating tests: testCloneDeterministicEvent, testCloneDeterministicEventPrecedesInitialize, testCloneDeterministicOpenSaltEvent - all three fail when assertNewClone's signature literal is mutated to NewClone(address,address,address,bytes32,bytes,uint256) (assertion failed: 0x3b3e5b48… != 0xdb898a34…, run 0 in each), so the helper's assertions really run at all three call sites and are not vacuous. Restored; the full suite is green (78 tests, same count as base).
  • Mutations applied: test/abstract/CloneFactoryTest.sol topic-0 literal -> a sixth argument in the event signature -> killed by all three tests above. No src/ line changed, so mutation-probe has no src behaviour to mutate here.
  • Oracle: the assertions are the ones that were already in the suite, moved verbatim — emitter against the factory instance, topic 0 against the event signature written out as a literal string, and entry.data against abi.encode of the five arguments the caller passes. Nothing is read back from the library.
  • Category check: issue asks for both duplicated patterns — the fixture in four contracts and the NewClone trio in three; both covered. grep -rn "new TestCloneFactory()" test/ afterwards returns only the base's constructor, and grep -rn "NewClone(address" test/ only the base's literal.

forge fmt --check and forge test clean locally (78 tests).

🤖 Generated with Claude Code

thedavidmeister and others added 3 commits September 21, 2026 11:19
keccak256 returns bytes32 and topics[0] is bytes32, so the uint256 hop
converted a value to another type and straight back.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…one assertion

The TestCloneFactory immutable and its constructor were copy-pasted in
four test contracts, and the NewClone emitter/topic0/data trio — with the
event signature as a hand-written literal — in three places.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
CLAUDE.md pins tests and concretes at =0.8.25; the float is for src
lib/abstract files that downstream consumers compile.

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

coderabbitai Bot commented Sep 21, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 41 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: 84e716ef-417c-443e-8ce8-4bcffcf7ff5e

📥 Commits

Reviewing files that changed from the base of the PR and between 710dff5 and 3a03077.

📒 Files selected for processing (5)
  • test/abstract/CloneFactoryTest.sol
  • test/src/interface/ICloneableV2.initialize.t.sol
  • test/src/lib/LibICloneableFactoryV4.cloneAndInitialize.t.sol
  • test/src/lib/LibICloneableFactoryV4.cloneDeterministic.t.sol
  • test/src/lib/LibICloneableFactoryV4.cloneDeterministicOpenSalt.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.

This branch has not been deployed

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

[F47] [INFO] The TestCloneFactory fixture and the NewClone log assertion are copy-pasted across the suite instead of living in one test base

1 participant