Commit Graph

1 Commits (dev)

Author SHA1 Message Date
Your Name 0484be97b1 test(snowflake): cover sequence generation and collision regression
Add tests/Unit/SnowflakeServiceTest.php covering SnowflakeService::next()
and byDate(). Datacenter/worker ids are pinned via config so ids are fully
deterministic and the sequence behaviour is assertable rather than
probabilistic.

Regression coverage for the stale-sequence bug (duplicate seq on the first
two ids -> UNIQUE constraint collisions):
  - first two ids use distinct sequence values
  - consecutive calls yield a strictly increasing sequence (1,2,3,...)
  - a 100-id burst minted in the same frozen millisecond is fully unique
  - an explicit reproduction contrasting old (1,1) vs fixed (1,2) sequences

Also covers: datacenter/worker bit encoding, sequence wraparound at 4095,
cache reseeding on missing/non-numeric counters, timestamp bit encoding,
and byDate() delegation/ordering. Verified these fail on the pre-fix code
(6 failing) and pass on the fix (14 passing).
1 week ago