Skip to content

test(fork): exercise TailTwins tail-match gate off parity - #16

Merged
aaronjmars merged 1 commit into
mainfrom
test/tailtwins-off-parity-fork
Sep 6, 2026
Merged

test(fork): exercise TailTwins tail-match gate off parity#16
aaronjmars merged 1 commit into
mainfrom
test/tailtwins-off-parity-fork

Conversation

@aaronjmars

Copy link
Copy Markdown
Contributor

What

Adds an off-parity fork test for TailTwins. Every ForkDeploy fixture initializes at SQRT_1_1 (2^96), whose low byte is 0, so TailTwins.requiredTail is a constant 0 and the "your size's last byte must match the price's, which shifts every swap" mechanic is never actually exercised at a nonzero tail.

test_TailTwins_tailBindsOffParity inits a Base pool off parity (sqrtPrice low byte 0x37) and asserts:

  1. requiredTail != 0 (the 1:1 blind spot is avoided),
  2. a size whose low byte is a half-ring away reverts TailMismatch,
  3. a tail-matching size clears the gate and moves the price, so the gate is proven to read live slot0, not a frozen constant.

Verification

forge build clean. All 3 GateFix tests pass on a live Base fork:

TT requiredTail @init 55
TT off-tail swap reverted TailMismatch
TT matching-tail swap OK; requiredTail now 214

Behavioral coverage only; no source or deployment change. Closes the last sibling whose gate was vacuous at parity (HeavierHand + CapGate were already covered off-parity in the same file).

ForkDeploy inits every hook at SQRT_1_1 (2^96), whose low byte is 0, so
TailTwins' requiredTail is a constant 0 and the tail-match mechanic is
never really exercised. Add a GateFix case that inits a Base pool off
parity (sqrtPrice low byte 0x37): requiredTail is nonzero, an off-tail
swap reverts TailMismatch, and a matching-tail swap clears the gate and
moves the price. Verified on a Base fork (3/3 GateFix tests pass).
@aaronjmars
aaronjmars merged commit 083acc4 into main Sep 6, 2026
1 check passed
@aaronjmars
aaronjmars deleted the test/tailtwins-off-parity-fork branch September 6, 2026 15:11
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.

1 participant