Skip to content

test(e2e): cover G-ORIGIN-01 namespace publish + claim journeys - #1285

Merged
thiras merged 3 commits into
mainfrom
test/1038-g-origin-01-publish
Jul 18, 2026
Merged

thiras merged 3 commits into
mainfrom
test/1038-g-origin-01-publish

Conversation

@yigitdot

@yigitdot yigitdot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Adds one new e2e test file, crates/e2e/tests/g_origin_01_publish.rs, covering the on-chain half of G-ORIGIN-01.

What it covers

namespace_create_claim_and_union — CLI-driven happy path plus the negatives on one fixture:

  • A publisher identity backed by a real encrypted keystore (eth_identity::generate_and_persist, the same artifact decdn key-gen produces) runs decdn publish namespace create and decdn publish claim <H> as subprocesses, with --json output parsed for the minted id.
  • PublisherRegistry.namespaceOf(H) is asserted on-chain to be exactly [ns1], and ownerOf(ns1) to be the CLI signer.
  • Append-only / idempotent: re-claiming H into the same namespace reverts AlreadyClaimed and — the property that matters — leaves namespaceOf(H) a single, unduplicated entry.
  • Multi-claim union: a second namespace claiming the same H does not displace the first; namespaceOf(H) returns both ids in claim order, cross-checked against hasClaimed.
  • Authorization: claiming into a namespace the caller does not own reverts NotNamespaceOwner. Without this, a registry that dropped the owner check entirely would still have passed — every other claim in the test is made by the namespace's own owner.

namespace_transfer_respects_timelock — the 2-step ownership transfer:

  • Asserts namespaceTransferTimelock is the ADR 002 7-day default and that pendingTransfer.readyAt == <initiating block timestamp> + timelock exactly (not a one-sided >=, which a now + 700 days bug would satisfy).
  • Warps to a fixed margin short of readyAt, asserts the head really is before readyAt, then asserts finalizeNamespaceTransfer reverts TransferNotReady and ownership has not moved — so the rejection is the timelock gate specifically, not merely "no time has passed".
  • Warps past readyAt, finalizes as the recipient, and asserts ownership moved and the pending record cleared.
  • Negatives: finalizing as a non-recipient reverts NotPendingOwner; cancelling a non-existent transfer reverts NoPendingTransfer.

Every negative goes through a shared expect_revert helper that matches on the error's 4-byte selector, so a transport fault or an unrelated revert fails the test rather than passing it.

There is no publish namespace transfer CLI subcommand, so the transfer leg drives PublisherRegistry bindings directly and uses the existing crates/e2e/src/time.rs advance_to helper.

Out of scope

The issue's clause "feed into G-NODE-08 to prove H becomes servable as origin" is a forward reference to a different issue and is not attempted here. The daemon can already do it — crates/node/src/dht/chain_origin_directory.rs resolves namespaceOf(H) → assigned origins → operator, and the runtime selects it when the registry addresses are configured. What is missing is the fixture: an OriginAssignment proposal, governance activation, and a bonded operator to serve it. That setup is G-NODE-08's. The test file's module docs say so. A rotted source comment found along the way is tracked in #1289.

Other changes

  • crates/e2e/src/bindings.rs (+20): adds hasClaimed, the namespace-transfer surface (initiateNamespaceTransfer, finalizeNamespaceTransfer, cancelNamespaceTransfer, the pendingTransfer getter, namespaceTransferTimelock), and the five error declarations the selector assertions match against.
  • crates/e2e/src/node.rs (+24): hoists decdn_cli_bin() out of slash_appeal.rs into the shared fixture module, alongside the private decdn_node_bin. The new test had grown a duplicate keyed on DECDN_BIN instead of the conventional DECDN_CLI_BIN, which would have silently exec'd a stale binary.
  • crates/e2e/tests/slash_appeal.rs (−22): drops its now-shared local copy of that helper.

No production code touched; test code plus those two crates/e2e/src additions only.

Verification

$ cargo nextest run -p decdn-e2e --features anvil-e2e -E 'binary(g_origin_01_publish)'
    PASS [   1.222s] (1/2) decdn-e2e::g_origin_01_publish namespace_transfer_respects_timelock
    PASS [   4.906s] (2/2) decdn-e2e::g_origin_01_publish namespace_create_claim_and_union
     Summary [   4.906s] 2 tests run: 2 passed, 0 skipped

Run repeatedly, green each time (no flake). The new selector assertions were mutation-checked — each fails when pointed at a wrong expected error. slash_appeal, which shares the hoisted helper, still passes. Also clean:

  • cargo fmt -- --check
  • cargo clippy --workspace --all-targets -- -D warnings

The tests exec the pre-built decdn and decdn-node binaries, so cargo build them first.

🤖 Generated with Claude Code

Closes #1038

Adds `crates/e2e/tests/g_origin_01_publish.rs`, driving the publisher
control plane end-to-end against a real anvil `PublisherRegistry`:

- `namespace_create_claim_and_union`: a publisher with a real encrypted
  keystore runs `decdn publish namespace create` and `decdn publish claim`
  as subprocesses; `namespaceOf(H)` is asserted on-chain. Negatives ride
  the same fixture — a re-claim into the same namespace is rejected and
  leaves the claim set unduplicated (append-only), and a claim into a
  second namespace resolves as a union of both ids.
- `namespace_transfer_respects_timelock`: the 2-step ownership transfer
  cannot be finalized one second before `pendingTransfer.readyAt` and does
  transfer once the chain clock is warped past it. No CLI subcommand
  covers transfers, so this leg drives the bindings directly.

Adds the `hasClaimed` / transfer-surface `PublisherRegistry` bindings the
transfer leg needs.

Out of scope (forward reference to G-NODE-08): proving H becomes servable
as an origin — that needs a chain-backed origin directory in the daemon,
which does not exist yet.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 18, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@yigitdot, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 8 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Free

Run ID: 88d2b16e-a6ca-4abc-b0e7-db0e7bdd62e0

📥 Commits

Reviewing files that changed from the base of the PR and between 23e87ad and 8033306.

📒 Files selected for processing (4)
  • crates/e2e/src/bindings.rs
  • crates/e2e/src/node.rs
  • crates/e2e/tests/g_origin_01_publish.rs
  • crates/e2e/tests/slash_appeal.rs

Walkthrough

The change extends PublisherRegistry bindings and adds Anvil-backed end-to-end tests for namespace creation, content claims, duplicate handling, claim unions, and timelocked namespace ownership transfers.

Changes

Namespace publishing and transfer

Layer / File(s) Summary
PublisherRegistry namespace interfaces
crates/e2e/src/bindings.rs
Adds claim-status, namespace-transfer, pending-transfer, and timelock binding methods.
Namespace publish and claim journey
crates/e2e/tests/g_origin_01_publish.rs
Adds CLI-driven tests for namespace creation, first claims, duplicate rejection, ordered multi-claim unions, and executable/keystore test helpers.
Timelocked ownership transfer
crates/e2e/tests/g_origin_01_publish.rs
Adds tests for transfer initiation, pending transfer metadata, pre-timelock rejection, finalization, ownership changes, and cleared pending state.

Estimated code review effort: 3 (Moderate) | ~25 minutes


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands.

@yigitdot yigitdot changed the title test(e2e): G-ORIGIN-01 namespace publish + claim journeys test(e2e): cover G-ORIGIN-01 namespace publish + claim journeys Jul 18, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds contract bindings for namespace ownership transfer and claim verification, and introduces end-to-end tests for namespace publishing, claiming, and timelocked ownership transfers. Specifically, it updates crates/e2e/src/bindings.rs with new PublisherRegistry functions and adds a comprehensive test suite in crates/e2e/tests/g_origin_01_publish.rs. There are no review comments, and I have no additional feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@github-actions

github-actions Bot commented Jul 18, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 81.59% (was 81.61%, ▼ 0.03%) — 48724/59720 lines

File Coverage Lines Δ
crates/e2e/src/node.rs 18.18% 50/275 ▼ 1.12%
History
Commit Total Δ vs base
23e87ad 81.61% ● 0.00%
e8c18b4 81.59% ▼ 0.02%
8033306 (HEAD) 81.59% ▼ 0.03%

yigitdot and others added 2 commits July 18, 2026 20:08
Review follow-ups on the G-ORIGIN-01 publish journeys:

- Correct the module doc's out-of-scope rationale. It claimed
  ChainOriginDirectory "does not exist"; it does, and the runtime
  selects it. The real blocker is fixture setup (OriginAssignment
  proposal + governance activation + bonded operator), which is
  G-NODE-08's. Rotted source comment tracked in #1289.
- Replace the 1-second pre-timelock warp margin with WARP_MARGIN plus
  an explicit head < readyAt assertion. Anvil derives block timestamps
  from wall-clock, so the old margin (which relied on advance_to's
  undocumented +1) could overshoot on a loaded runner and turn the
  timelock gate into a spurious pass.
- Assert readyAt == init_ts + timelock against the initiating block's
  timestamp, replacing a one-sided >= check that a now + 700 days bug
  would have passed.
- Add expect_revert, matching on the 4-byte selector, and use it for
  every negative. Distinguishes the guard under test from a transport
  fault or a different revert, which is_err() accepted.
- Cover the authorization guards: NotNamespaceOwner on claimContent
  (previously every claim was made by the namespace's own owner, so a
  registry that dropped the check entirely still passed), NotPendingOwner
  on finalize, and NoPendingTransfer via cancelNamespaceTransfer — whose
  binding was added but never exercised.
- Drop the ownerOf check that followed a static .call() and so could
  never fail.
- Hoist decdn_cli_bin into decdn_e2e::node; the test had a duplicate
  keyed on DECDN_BIN instead of the conventional DECDN_CLI_BIN, which
  would silently exec a stale binary.

Verified: 4 consecutive green runs, plus mutation checks confirming the
new selector assertions fail on a wrong expected error. slash_appeal
(shared helper) still passes. fmt + clippy --all-targets clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`cargo doc` runs with `-D warnings`, so the `[`decdn_node_bin`]` link on
the newly-public `decdn_cli_bin` tripped rustdoc::private_intra_doc_links
(the target is private). Keep the cross-reference as prose.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@thiras
thiras merged commit 0de44e6 into main Jul 18, 2026
23 checks passed
@thiras
thiras deleted the test/1038-g-origin-01-publish branch July 18, 2026 20:28
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.

e2e G-ORIGIN-01: namespace publish + serve (uses decdn publish CLI)

2 participants