test(documents): end-to-end sign-off against a real database and real keys - #386
Merged
Conversation
… keys
Document Sign-Off had no integration test. Every existing test covers one
piece of it in isolation, and the chain those pieces form — create, draft,
publish, freeze the signer set, sign, reach the threshold, export a proof,
verify it — had never been executed.
That is exactly where this feature's worst bug lived. `sign()` rejected
every valid signature for as long as the feature existed, and its unit
test did not catch it because it mocked `checkSignature` — the one thing
it was meant to prove. So this test signs with a real key, through the
real helper, against a real Postgres. The wallet is seeded with an address
whose mnemonic the test holds, which is what makes a genuine CIP-8
signature possible instead of a fixture pretending to be one.
Three cases:
- The whole lifecycle, ending in `verifyProof({ valid: true })` through
the public procedure. It also asserts the published contentHash equals
sha256 of the bytes the server stored, which is the claim that makes
"what you sign is what was published" true rather than asserted, and
that publishing is refused outright when server storage is off.
- A forged payload is rejected and the version stays InReview.
- A new version supersedes the signed one and resets approvals to zero.
Two bugs found writing it were mine, not the product's, and both are worth
recording. `publishDraft` creates a version without bumping the draft
revision, so my second save presented a stale expectedRevision. And the
first tamper attempt edited prose in the body — which proved nothing,
because the payload binds the content HASH, not the text. It now tampers
with the hash itself, and asserts the string actually changed so the test
cannot silently go vacuous again.
Runs in the existing trpc-integration-tests workflow. 88 integration tests
pass, 1161 unit tests pass, tsc clean, next build exit 0.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Document Sign-Off had no integration test. Every existing test covers one piece in isolation, and the chain those pieces form — create → draft → publish → freeze the signer set → sign → reach the threshold → export a proof → verify it — had never been executed.
That is exactly where this feature's worst bug lived.
sign()rejected every valid signature for as long as the feature existed, and its unit test didn't catch it because it mockedcheckSignature— the one thing it was meant to prove.So this signs with a real key, through the real helper, against a real Postgres. The wallet is seeded with an address whose mnemonic the test holds, which is what makes a genuine CIP-8 signature possible instead of a fixture pretending to be one.
Three cases
verifyProof({ valid: true })through the public procedure. It also asserts the publishedcontentHashequalssha256of the bytes the server stored — the claim that makes "what you sign is what was published" true rather than asserted — and that publishing is refused outright when server storage is off.InReview.Two bugs I found were mine, and both are worth recording
publishDraftcreates a version without bumping the draft revision, so my second save presented a staleexpectedRevision. Worth knowing before someone builds on the draft API.On the browser suite
Playwright is not runnable here:
globalSetuprequires three funded preprod mnemonics, a Blockfrost key and a bootstrapped context, and running it spends real testnet ADA. It is covered by CI —playwright-browserpassed on every PR in this batch (#384, #385).This test plugs into the existing
trpc-integration-testsworkflow, so it runs on every PR from here.88 integration tests pass, 1161 unit tests pass,
tsc --noEmitclean,next buildexit 0.🤖 Generated with Claude Code