Skip to content

[#27] E2E Mainnet Test Script#28

Merged
realproject7 merged 3 commits intomainfrom
task/27-e2e-mainnet-test
Mar 20, 2026
Merged

[#27] E2E Mainnet Test Script#28
realproject7 merged 3 commits intomainfrom
task/27-e2e-mainnet-test

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • Adds script/E2ETest.s.sol — a Foundry script that runs the full StoryFactory lifecycle on Base mainnet with real transactions
  • Covers all 6 scenario groups: story lifecycle (A), trading variations (B), donations (C), royalty claims (D), 9 validation barrier reverts (E), and edge cases (F)
  • Script is idempotent (creates new storylines each run), logs all results to console

Test plan

  • forge build compiles without errors
  • All 28 existing unit tests still pass (forge test)
  • Script runs end-to-end on Base mainnet: source .env && forge script script/E2ETest.s.sol --rpc-url base --broadcast -vvvv
  • Group E barriers correctly catch reverts without halting
  • Tx hashes logged for indexer verification (plotlink#374)

Fixes #27

🤖 Generated with Claude Code

Foundry script covering Groups A-F: story lifecycle (create/chain),
trading variations (buy/sell/monotonicity), donations, royalty claims,
9 validation barrier reverts, and edge cases (CID boundaries, royalty diff).

Run: source .env && forge script script/E2ETest.s.sol --rpc-url base --broadcast -vvvv

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

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

T2b Review — PR #28

Overall the script is well-structured: clean group separation, correct broadcast management for Group E reverts, proper try/catch usage, and good scenario coverage. Three issues to address:

1. Missing e2e-results.json output (blocking)

The issue explicitly requires: "Output tx hashes + storyline IDs to e2e-results.json" — and ticket 2 (plotlink#374) depends on this file. The script only logs to console. Foundry's vm.writeJson cheatcode can write structured JSON from a script. Add a vm.writeJson call at the end that writes storyline IDs, token addresses, and scenario results to e2e-results.json. Without this, the indexer verification script has no input.

2. Missing estimate-vs-actual assertions for Group B (non-blocking but recommended)

The issue specifies: "getReserveForToken() estimate matches actual reserve spent (within 1 wei tolerance)" and same for getRefundForTokens(). B1–B5 log both values but never assert they match. Add require checks with a small tolerance, e.g.:

require(spent1 <= estReserve1 + 1 && spent1 >= estReserve1 - 1, "B1: estimate mismatch");

3. Missing totalSupply assertions for Group B

The issue requires: "totalSupply changes by exact trade amount". Not currently checked. Add totalSupply() checks before/after each mint/burn.


Items 2–3 are assertion gaps that reduce confidence but don't break the script. Item 1 is blocking — the downstream ticket depends on the JSON output file.

…s, totalSupply checks

- Add vm.writeJson to output storyline IDs, token addresses, trading
  costs, and scenario results to e2e-results.json (blocking — needed
  by downstream plotlink#374)
- Add estimate-vs-actual require checks (1 wei tolerance) for all
  Group B mint/burn operations
- Add totalSupply assertions before/after every mint and burn

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

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

T2b Re-review — APPROVED

All 3 requested changes addressed cleanly in f8e10b0:

  1. e2e-results.jsonvm.serializeUint/Address/String + vm.writeJson writes structured JSON with storyline IDs, token addresses, trading costs/refunds, royalties claimed, and edge case data. Downstream plotlink#374 is unblocked.
  2. Estimate-vs-actual assertions — B1–B5 now assert require(spent <= est + 1 && spent + 1 >= est) for both mints and burns.
  3. totalSupply checks — Added IERC20Extended interface; totalSupply() verified before/after every mint/burn in Groups B and F.

Code is clean, all 30 scenarios covered with proper assertions. LGTM.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

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

Verdict: REQUEST CHANGES

Summary

The script is close, but it still misses one acceptance-criteria requirement and one of the donation scenarios is not actually being tested as specified. The PR also cannot merge in its current state because the Foundry check is failing on formatting.

Findings

  • [high] Group C uses the writer as the donor, so the donation scenarios never verify the required transfer behavior between two parties.

    • File: script/E2ETest.s.sol:280
    • Suggestion: run donations from a second funded address (or otherwise separate donor from writer) and assert the donor balance decreases while the writer balance increases by the donation amount, per the issue requirements.
  • [medium] e2e-results.json still omits the broadcast transaction hashes that issue #27 explicitly requires and that the downstream indexer-verification ticket needs.

    • File: script/E2ETest.s.sol:100
    • Suggestion: capture and persist the tx hash for each broadcast transaction alongside the storyline IDs / token addresses in e2e-results.json.
  • [low] GitHub checks are still red because forge fmt --check fails on this file.

    • File: script/E2ETest.s.sol:238
    • Suggestion: run forge fmt (or apply the equivalent formatting at the flagged lines) before re-requesting review.

Decision

Requesting changes because the script does not yet satisfy the donation assertions from the issue, does not emit the tx-hash output required by the acceptance criteria, and currently fails CI.

- Group C: Use separate DONOR_PRIVATE_KEY for two-party donation
  verification — assert both donor-decreases and writer-increases
- e2e-results.json: Add chainId, donor address, and broadcastArtifact
  path for per-broadcast tx hash resolution by downstream plotlink#374
- Fix forge fmt violations (lines 238, 405 area)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

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

Verdict: APPROVE

Summary

The updated script addresses the requested changes. Group C now uses a separate donor wallet with exact donor/writer balance assertions, the JSON output now provides the chain and Forge broadcast artifact path needed to resolve transaction hashes downstream, and CI is green.

Findings

  • None.

Decision

Approving because the PR now satisfies the previously-blocking review items and the GitHub checks are passing.

@realproject7 realproject7 merged commit c2b7533 into main Mar 20, 2026
2 checks passed
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.

[Test] E2E Mainnet Test Script — Contract Lifecycle & Validation Barriers

2 participants