Add DDO E2E integration tests with Anvil fork helpers#655
Open
Add DDO E2E integration tests with Anvil fork helpers#655
Conversation
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.
parkan
reviewed
Apr 1, 2026
Collaborator
|
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? |
Collaborator
|
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? |
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
parkan
reviewed
Apr 2, 2026
| return &MockDDOFacet{Address: mockAddr, RPCURL: rpcURL} | ||
| } | ||
|
|
||
| // diamondCutViaRPC encodes and sends a diamondCut transaction via impersonation. |
Collaborator
There was a problem hiding this comment.
this is a standard deployed contract, no need to hand-roll the abi
parkan
reviewed
Apr 2, 2026
| require.NoError(t, err) | ||
| // Replace selector: createAllocationRequests -> mockCreateRawAllocationRequests (0x76e92deb) | ||
| mockSelector := common.FromHex("0x76e92deb") | ||
| copy(realCallData[0:4], mockSelector) |
Collaborator
There was a problem hiding this comment.
prefer to use real facet abi here also
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.
Summary
util/testutil/evm.go:AnvilImpersonate,ReadContractOwner,TransferERC20,SendImpersonatedTxCalibnetDDOProviderActorIDconstant for the FF calibnet minert0178773Key finding
CreateAllocationsreverts withActorNotFoundon 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:t0178773is registered in the DDO contract on live calibnet by the contract owner (0xCb71D6e32E12B618f8e0B4DCf36b6A10b5CEDC14)Test plan
go test ./service/dealpusher/ -run TestIntegration_DDO -v(requiresanvilon PATH)go test ./service/dealtracker/ -run DDO -vgo test ./service/dealpusher/ -run DDO -v