Skip to content

Add DDO E2E integration tests with Anvil fork helpers#655

Open
anjor wants to merge 4 commits intomainfrom
feat/ddo-e2e-integration-test
Open

Add DDO E2E integration tests with Anvil fork helpers#655
anjor wants to merge 4 commits intomainfrom
feat/ddo-e2e-integration-test

Conversation

@anjor
Copy link
Copy Markdown
Collaborator

@anjor anjor commented Apr 1, 2026

Summary

  • Adds 5 DDO integration tests exercising the full deal lifecycle against a calibnet Anvil fork: client connectivity, wallet funding, SP validation, SP registration via owner impersonation, and the complete payment setup flow (deposit + operator approval)
  • Adds reusable Anvil test helpers in util/testutil/evm.go: AnvilImpersonate, ReadContractOwner, TransferERC20, SendImpersonatedTx
  • Adds CalibnetDDOProviderActorID constant for the FF calibnet miner t0178773

Key finding

CreateAllocations reverts with ActorNotFound on Anvil forks because Filecoin's built-in actor system doesn't have mappings for freshly generated test keys. The payment setup path is fully validated. Full allocation creation will work once:

  1. The SP t0178773 is registered in the DDO contract on live calibnet by the contract owner (0xCb71D6e32E12B618f8e0B4DCf36b6A10b5CEDC14)
  2. Tests are run with an address that has a real calibnet actor ID

Test plan

  • go test ./service/dealpusher/ -run TestIntegration_DDO -v (requires anvil on PATH)
  • go test ./service/dealtracker/ -run DDO -v
  • Verify no regressions in existing DDO unit tests: go test ./service/dealpusher/ -run DDO -v

Exercise the full DDO deal lifecycle against a calibnet Anvil fork:
- SP registration via contract owner impersonation
- USDFC token transfer and payment setup (deposit + operator approval)
- CreateAllocations (documents ActorNotFound limitation on Anvil forks)

Also adds reusable Anvil test helpers (impersonation, contract owner
reads, ERC20 transfers, impersonated tx sending) and the calibnet
FF miner t0178773 constant.
@anjor anjor requested a review from parkan April 1, 2026 10:47
@parkan
Copy link
Copy Markdown
Collaborator

parkan commented Apr 1, 2026

re: the "key finding", are you saying that the DC registry calls are not testable on anvil because they call into native FEVM precompiles which need to look at actor state?

@parkan
Copy link
Copy Markdown
Collaborator

parkan commented Apr 1, 2026

ok I think I see what's happening, anvil default deterministic account is materialized (with actor to match) on calibnet, why not use that directly?

anjor added 3 commits April 1, 2026 14:07
Switch from generating a fresh test key to using Anvil's pre-funded
account 0, which already has USDFC tokens and deposited funds on the
calibnet fork. This removes the need for ERC20 transfers.

CreateAllocations still reverts because Anvil forks lack the Filecoin
resolve_address precompile (0xFe00...0001) — this is a fundamental
limitation of using a standard EVM fork for FEVM contract testing,
not an account issue.
Remove local tokenConfig struct in registerSPViaImpersonation and use
ddotypes.TokenConfig from the ddo-client SDK directly, avoiding
brittle ABI redefinition.
The real createAllocationRequests calls DataCapAPI.transfer() which
requires Filecoin's CALL_ACTOR_ID precompile — unavailable on Anvil.

This deploys the ddo-client's MockAllocationFacet on the Anvil fork
via Diamond cut, then calls mockCreateRawAllocationRequests which
skips DataCap and emits AllocationCreated events with mock IDs.

The full E2E flow now validates end-to-end:
  SP registration → payment setup → mock allocation → event parsing
return &MockDDOFacet{Address: mockAddr, RPCURL: rpcURL}
}

// diamondCutViaRPC encodes and sends a diamondCut transaction via impersonation.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this is a standard deployed contract, no need to hand-roll the abi

require.NoError(t, err)
// Replace selector: createAllocationRequests -> mockCreateRawAllocationRequests (0x76e92deb)
mockSelector := common.FromHex("0x76e92deb")
copy(realCallData[0:4], mockSelector)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

prefer to use real facet abi here also

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.

2 participants