-
Notifications
You must be signed in to change notification settings - Fork 358
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
Bridgehub Test Coverage Increase #494
Bridgehub Test Coverage Increase #494
Conversation
l1-contracts/test/foundry/unit/concrete/Bridgehub/experimental_bridge.t.sol
Outdated
Show resolved
Hide resolved
l1-contracts/test/foundry/unit/concrete/Bridgehub/experimental_bridge.t.sol
Outdated
Show resolved
Hide resolved
159fb4f
to
f799fa0
Compare
417a1d6
to
9ea11f4
Compare
Coverage: 88.01% (lines) | 88.60% (statements) | 75.98% (branches) | 85.09% (funcs) |
secondBridge.acceptOwnership(); | ||
|
||
sharedBridgeAddress = address(sharedBridge); | ||
secondBridgeAddress = address(secondBridge); | ||
testToken = new TestnetERC20Token("ZKSTT", "ZkSync Test Token", 18); |
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.
Can we aim for tests with tokens that have decimals other than 18, such as 6 (USDC) , cTokens from Compound and WBTC have 8, etc.
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.
Added tokens with different decimals, I've used modifier to choose random token.
_chainId: 1, | ||
_stateTransitionManager: address(mockSTM), | ||
_baseToken: address(testToken), | ||
_salt: uint256(123), |
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.
Please fuzz the tests as much as you can. In this case, try and provide the _chainId parameter as a fuzzed number bounded to be between 1 and type(uint48).max and similarly for the _salt
parameter.
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.
I've fuzzed chain ids. Can you confirm if salt spans the whole uint256 range?
|
||
vm.deal(randomCaller, l2TxnReqDirect.mintValue); | ||
vm.txGasPrice(0.05 ether); |
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.
Good approximation, but ideally we would this value to be fuzzed as well. You can upper bound the values to be in a realistic range.
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.
Gas is now fuzzed and bounded
@@ -641,8 +879,15 @@ contract ExperimentalBridgeTest is Test { | |||
mockChainContract.setBridgeHubAddress(address(bridgeHub)); | |||
assertTrue(mockChainContract.getBridgeHubAddress() == address(bridgeHub)); | |||
|
|||
vm.txGasPrice(0.05 ether); | |||
if (msgValue != mockMintValue) { |
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.
can it be if(msgValue < mockMintValue)
instead of the strict equality used here?
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.
Require statement has strict equality, so I guess strict inequality fits here. I've separated success/revert case, moved revert into separate function and used vm.assume to discard equal values.
8ef6604
to
be07ab8
Compare
* revert bridgehub changes * removed dummy bridge from erc20bridge tests * replaced dummy shared bridge with actual bridge
e8f1972
to
ebc08c1
Compare
What ❔
Increased coverage in bridgehub unit tests, add some cases for two bridges deposit.
Changed order of assert in Bridgehub contract.
Why ❔
Previous tests had low coverage on branches, asserts and types of deposits, theirs permutations.
Checklist