-
Notifications
You must be signed in to change notification settings - Fork 416
chore: low-hanging deviations in integ tests #2135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: draft-v31
Are you sure you want to change the base?
Changes from 3 commits
524b094
53a5731
3e4ebc6
28cfbd0
1159a5b
6106bef
afddb84
ec663d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,9 +4,10 @@ pragma solidity ^0.8.20; | |
| // solhint-disable gas-custom-errors | ||
|
|
||
| import {StdStorage, Test, stdStorage} from "forge-std/Test.sol"; | ||
| import {Vm} from "forge-std/Vm.sol"; | ||
| import "forge-std/console.sol"; | ||
|
|
||
| import {BridgedStandardERC20} from "contracts/bridge/BridgedStandardERC20.sol"; | ||
| import {BridgedStandardERC20, NonSequentialVersion} from "contracts/bridge/BridgedStandardERC20.sol"; | ||
| import {L2AssetRouter} from "contracts/bridge/asset-router/L2AssetRouter.sol"; | ||
| import {IL2NativeTokenVault} from "contracts/bridge/ntv/IL2NativeTokenVault.sol"; | ||
| import {DataEncoding} from "contracts/common/libraries/DataEncoding.sol"; | ||
|
|
@@ -35,7 +36,9 @@ abstract contract L2Erc20TestAbstract is Test, SharedL2ContractDeployer { | |
| address depositor = makeAddr("depositor"); | ||
| address receiver = makeAddr("receiver"); | ||
|
|
||
| vm.recordLogs(); | ||
| performDeposit(depositor, receiver, 100); | ||
| Vm.Log[] memory logs = vm.getRecordedLogs(); | ||
|
|
||
| address l2TokenAddress = IL2NativeTokenVault(L2_NATIVE_TOKEN_VAULT_ADDR).l2TokenAddress(L1_TOKEN_ADDRESS); | ||
|
|
||
|
|
@@ -44,6 +47,33 @@ abstract contract L2Erc20TestAbstract is Test, SharedL2ContractDeployer { | |
| assertEq(BridgedStandardERC20(l2TokenAddress).name(), TOKEN_DEFAULT_NAME); | ||
| assertEq(BridgedStandardERC20(l2TokenAddress).symbol(), TOKEN_DEFAULT_SYMBOL); | ||
| assertEq(BridgedStandardERC20(l2TokenAddress).decimals(), TOKEN_DEFAULT_DECIMALS); | ||
|
|
||
| // Verify Transfer event (mint: from address(0) to receiver) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we use standard foundry assertions for events?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think not, as these events are not emitted by the fn being called, but by subsequent calls along the line, that is why I was using I added a library in |
||
| bytes32 transferSig = keccak256("Transfer(address,address,uint256)"); | ||
| bool foundTransfer = false; | ||
| for (uint256 i = 0; i < logs.length; i++) { | ||
| if ( | ||
| logs[i].topics.length > 2 && | ||
| logs[i].topics[0] == transferSig && | ||
| logs[i].emitter == l2TokenAddress && | ||
| logs[i].topics[1] == bytes32(uint256(0)) && | ||
| logs[i].topics[2] == bytes32(uint256(uint160(receiver))) | ||
| ) { | ||
| assertEq(abi.decode(logs[i].data, (uint256)), 100, "Transfer amount should be 100"); | ||
| foundTransfer = true; | ||
| } | ||
| } | ||
| assertTrue(foundTransfer, "Transfer event (mint) should be emitted"); | ||
|
|
||
| // Verify DepositFinalizedAssetRouter event | ||
| bytes32 depositFinalizedSig = keccak256("DepositFinalizedAssetRouter(uint256,bytes32,bytes)"); | ||
| bool foundDepositFinalized = false; | ||
| for (uint256 i = 0; i < logs.length; i++) { | ||
| if (logs[i].topics.length > 0 && logs[i].topics[0] == depositFinalizedSig) { | ||
| foundDepositFinalized = true; | ||
| } | ||
| } | ||
| assertTrue(foundDepositFinalized, "DepositFinalizedAssetRouter event should be emitted"); | ||
| } | ||
|
|
||
| function test_governanceShouldBeAbleToReinitializeToken() public { | ||
|
|
@@ -72,7 +102,7 @@ abstract contract L2Erc20TestAbstract is Test, SharedL2ContractDeployer { | |
| ignoreDecimals: false | ||
| }); | ||
|
|
||
| vm.expectRevert(); | ||
| vm.expectRevert(abi.encodeWithSelector(NonSequentialVersion.selector)); | ||
| vm.prank(ownerWallet); | ||
| BridgedStandardERC20(l2TokenAddress).reinitializeToken(getters, "TestTokenNewName", "TTN", 20); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe makes sense to make a dedicated constants for 0xdead?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can just add
address constant RAND_ADDRESS = address(0xDEAD);to a newTestConstants.sol, for example atl1-contracts/test/foundry. We can also use foundry labeling throughaddress randomAddress = makeAddr("randomAddress");, it gives clearer traces but we will have to sprinkle it around the test-suite.