op-vault: test that a token is independent of the PAN, not free of "4242" #126

Merged
dcharlot merged 1 commit from openpay/token-independence-test into main 2026-10-01 06:02:36 -04:00
Owner

pan_never_appears_in_token_string failed the openpay leg of standards-build on #102, which touches nothing in openpay.

Cause. The test asserted that the token never contains "424242" or "4242". A token is TOKEN_PREFIX plus a UUIDv7 in hex. A random hex string contains "4242" now and then: 23 of 200,000 UUIDv7s did, about 1 in 8,700. Any PR whose openpay leg runs can hit this. The timestamp part of the token at CI time (01a0f4ee2960) has no 4242 in it, so the match came from the random suffix.

Fix. Keep the full-PAN check. Replace the substring checks with the property they were meant to stand for: the same card tokenized twice gets two different tokens, and neither contains the PAN. A missing substring never showed that the token isn't derived from the card. Two different tokens for one card does show it.

Verified.

  • cargo test -p op-vault --features in-memory: 40 + 11 passed.
  • The test passed 300 runs out of 300 in a loop.
  • Without --features in-memory the lifecycle binary has 0 tests. CI's openpay leg does enable the feature, which is why it failed there.

🤖 Generated with Claude Code

`pan_never_appears_in_token_string` failed the openpay leg of standards-build on #102, which touches nothing in openpay. **Cause.** The test asserted that the token never contains `"424242"` or `"4242"`. A token is `TOKEN_PREFIX` plus a UUIDv7 in hex. A random hex string contains `"4242"` now and then: 23 of 200,000 UUIDv7s did, about 1 in 8,700. Any PR whose openpay leg runs can hit this. The timestamp part of the token at CI time (`01a0f4ee2960`) has no `4242` in it, so the match came from the random suffix. **Fix.** Keep the full-PAN check. Replace the substring checks with the property they were meant to stand for: the same card tokenized twice gets two different tokens, and neither contains the PAN. A missing substring never showed that the token isn't derived from the card. Two different tokens for one card does show it. **Verified.** - `cargo test -p op-vault --features in-memory`: 40 + 11 passed. - The test passed 300 runs out of 300 in a loop. - Without `--features in-memory` the lifecycle binary has 0 tests. CI's openpay leg does enable the feature, which is why it failed there. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
op-vault: test that a token is independent of the PAN, not free of "4242"
All checks were successful
standards workspaces build + test / jouleclaw-rs (pull_request) Successful in 1m38s
standards workspaces build + test / aac-rs (pull_request) Successful in 54s
standards workspaces build + test / joule-code-rs (pull_request) Successful in 37s
standards workspaces build + test / joulecontract-rs (pull_request) Successful in 37s
standards workspaces build + test / map-rs (pull_request) Successful in 34s
standards workspaces build + test / mesh-rs (pull_request) Successful in 25s
standards workspaces build + test / openpay (pull_request) Successful in 1m22s
standards workspaces build + test / eoc-rs (pull_request) Successful in 1m48s
standards workspaces build + test / jcp-rs (pull_request) Successful in 1m16s
standards workspaces build + test / proof-rs (pull_request) Successful in 1m10s
standards workspaces build + test / sandbox-rs (pull_request) Successful in 2m6s
standards workspaces build + test / smart-byte-rs (pull_request) Successful in 2m32s
standards workspaces build + test / arl-rs (pull_request) Successful in 2m13s
standards workspaces build + test / joule-ui-rs (pull_request) Successful in 2m47s
standards workspaces build + test / jouledesk-rs (pull_request) Successful in 2m32s
standards workspaces build + test / joulehook-rs (pull_request) Successful in 2m34s
standards workspaces build + test / sense-rs (pull_request) Successful in 2m32s
standards workspaces build + test / macOS energy backend (jcp-energy) (pull_request) Successful in 2m14s
f4ac4a70c9
pan_never_appears_in_token_string asserted that the token never contains
"424242" or "4242". The token is TOKEN_PREFIX plus a UUIDv7 in hex, and a
random hex string contains "4242" about once in 8,700 tokens (23 of
200,000 UUIDv7s did), so the test failed by chance: it failed the
openpay leg of standards-build on an unrelated PR (#102). A missing
substring said nothing about whether the token is derived from the card
anyway.

Keep the full-PAN check and test the real property: the same card
tokenized twice gets two different tokens, neither containing the PAN.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Transaction-Science/open-standards!126
No description provided.