tests: Add missing assertions to interop tests#1976
tests: Add missing assertions to interop tests#1976kelemeno merged 28 commits intomatter-labs:draft-v31from
Conversation
This commit adds proper assertions to interop-related tests that were previously missing verification of execution results: - L2InteropTestUtils: Enhanced to return BundleExecutionResult for assertions and added assertBundleExecuted() helper function - L2InteropLibraryBasicTestAbstract: Added assertions for token transfer, send call, and L1 message tests - L2InteropExecuteBundleTestAbstract: Added bundle emission and execution verification - L2InteropUnbundleTestAbstract: Added verification of bundle status transitions (Verified -> Unbundled) - L2InteropNativeTokenSimpleTestAbstract: Added bundle execution assertions - L2InteropNativeTokenDifferentBaseTestAbstract: Added execution verification - L2InteropHandlerTestAbstract: Added proper assertions to message verification and inclusion tests - L2AssetTracker: Added assertions for migration function to verify migration number and chain balance updates - MessageRoot: Added batch number tracking assertions for addChainBatchRoot - AssetTrackerTest: Added migration verification assertions for L1, L2, and Gateway confirmations
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dfab9cbd2f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| bool result = IAssetTrackerBase(address(assetTracker)).tokenMigratedThisChain(bytes32(0)); | ||
|
|
||
| // For bytes32(0) with no migrations set up, it should return false | ||
| assertFalse(result, "Token with zero assetId should not be migrated"); |
There was a problem hiding this comment.
Expect true when migration numbers default to zero
tokenMigratedThisChain returns assetMigrationNumber[_chainId][_assetId] == _getChainMigrationNumber(_chainId) (see AssetTrackerBase). In this test setup, the chain migration number is never initialized and defaults to 0, and assetMigrationNumber for bytes32(0) is also 0, so the function returns true. The new assertion expects false, which will fail in the default state (i.e., before any migration number is set). If you want this test to check the “not migrated” path, set the chain migration number to a non‑zero value or use an asset with a different migration number.
Useful? React with 👍 / 👎.
| // Verify the InteropCenter emitted a message event | ||
| bool foundInteropCenterLog = false; | ||
| for (uint256 i = 0; i < logs.length; i++) { | ||
| if (logs[i].emitter == L2_INTEROP_CENTER_ADDR) { | ||
| foundInteropCenterLog = true; | ||
| break; | ||
| } | ||
| } | ||
| assertTrue(foundInteropCenterLog, "InteropCenter should emit a log when sending message to L1"); |
There was a problem hiding this comment.
Don’t require InteropCenter logs for sendMessage
InteropLibrary.sendMessage calls the L2→L1 messenger system contract, not the InteropCenter (see deploy-scripts/InteropLibrary.sol). That means the emitted log(s), if any, will come from L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR, not L2_INTEROP_CENTER_ADDR. The new check will therefore fail even when sendMessage succeeds. Consider asserting that any log was emitted (as you already do), or specifically look for the messenger contract as the emitter instead.
Useful? React with 👍 / 👎.
- Fix assertions in L2InteropLibraryBasicTestAbstract to handle L1 context limitations - Fix assertions in L2InteropHandlerTestAbstract to mock message verification - Fix assertions in L2AssetTracker and AssetTrackerTest for correct behavior - Add AGENTS.md documentation for foundry-zksync installation and test running
- GW_CTMDeployer.t.sol: Verify deployer address and contract code - L2Erc20TestAbstract.t.sol: Add balance checks for withdrawal test - L2GatewayTestAbstract.t.sol: Add assertions for forward, withdraw, and finalize tests - L2NativeTokenVaultTestAbstract.t.sol: Verify legacy token registration state
- L2AssetTracker.t.sol: Add assertions to test_processLogsAndMessages and test_initiateL1ToGatewayMigrationOnL2 - L2NativeTokenVaultTestAbstract.t.sol: Add pre/post assertions for legacy token registration - AGENTS.md: Add section on linting and pre-push checklist
- AssetRouterTest.t.sol: Add assertions for deposit and withdraw tests - ChainRegistrationSender.t.sol: Add assertions for registration tests - L1ChainAssetHandlerTest.t.sol: Add assertions for migration, pause and settlement layer tests
- L1GatewayTests.t.sol: Add meaningful assertions to 6 tests including gateway registration, chain migration, L2 registration, and recovery - AssetTrackerTest.t.sol: Fix tautology assertion, improve pause test assertions - L2GatewayTestAbstract.t.sol: Add event verification and withdrawal assertions - L2InteropLibraryBasicTestAbstract.t.sol: Improve conditional assertion coverage
a7389cf to
d7db894
Compare
- BridgehubNormalTest: Add pre/post state assertions for CTM removal, settlement layer operations, and access control tests - DeploymentTest: Add assertions for chain registration validation - Bridgehub_7702: Add balance tracking and event verification for deposits - GW_CTMDeployer: Add config validation and struct verification
d7db894 to
a3e3d3a
Compare
Document that force pushing is forbidden and agents should always create new commits instead of amending.
- L1ChainAssetHandlerTest: Add migration number and paused state checks - L2AssetTracker: Verify logs emitted from migration function - ChainRegistrationSender: Check events emitted from deposit - AssetRouterTest: Verify calldata encoding for direct transactions
- Remove duplicate vm.recordLogs() call in test_chainRegistrationSenderDeposit that was clearing logs before they could be verified - Update test_initiateL1ToGatewayMigrationOnL2 to account for L1 context limitations where L2 storage updates and message emissions don't persist
- Add L1ToGatewayMigrationInitiated event to IL2AssetTracker and L2AssetTracker - Update test_initiateL1ToGatewayMigrationOnL2 to verify event emission - Fix test_requestL2TransactionDirectWithCalldata to use explicit encoding - Fix test_finalizeDepositWithRealChainData to use helper function - Improve test_finishMigrateBackChain with meaningful state assertions - Improve test_chainRegistrationSenderDeposit to verify transaction hash
…ector - Add assertion in migrateBackChain to verify settlement layer is L1 after migration - Use IL2AssetTracker.L1ToGatewayMigrationInitiated.selector instead of manual keccak256
- Remove unused L2_MESSAGE_ROOT import from L2AssetTracker.t.sol - Remove unused balanceBefore variable from test_initiateL1ToGatewayMigrationOnL2 - Remove unused settlementLayerBefore variable from test_finishMigrateBackChain
Add L1ToGatewayMigrationInitiated event to the compiled artifact
Add guidance on fixing "zkstack-out is out of date" CI errors when modifying interface files like adding events or functions.
The test mocks block.chainid to migratingChainId during finishMigrateChainFromGateway, causing the settlement layer to be set to migratingChainId rather than the L1 chain ID. Fix the assertion to verify the settlement layer is no longer the gateway.
- Add PauseDepositsForChainRequested event to IL1AssetTracker - Emit event in requestPauseDepositsForChainOnGateway - Update test to verify event emission with correct parameters - Fix test_tokenMigratedThisChain to use meaningful assertions - Update selectors and zkstack-out artifacts
This commit adds proper assertions to interop-related tests that were previously missing verification of execution results:
What ❔
Why ❔
Checklist