-
Notifications
You must be signed in to change notification settings - Fork 364
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
Enhance test coverage for upgrade contracts #1240
Conversation
…gramist/era-contracts into test/upgrade-contracts
} | ||
|
||
// Major version is not zero | ||
function test_revertWhen_MajorVersionIsNotZero() public { |
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.
this file is very similar to the BaseUpgrade, is it possible to reuse the code for tests? The less code to maintain, the better
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.
Yeah, it's similar in a sense but I still think it would be better to keep them as separate files for better maintainability and understanding.
If you disagree, we can open a PR later on to merge all such similar code/files
|
||
contract DummyBaseZkSyncUpgradeGenesis is BaseZkSyncUpgradeGenesis, BaseUpgradeUtils {} | ||
|
||
contract BaseZkSyncUpgradeGenesisTest is BaseUpgrade { |
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.
when I take a look inside the CI's test-foundry
section, I can not see that these tests are ever run
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.
Pushed them under the l1-contracts/tests/foundry/l1/*
. Now they'll be run in the CI.
vm.expectRevert( | ||
abi.encodeWithSelector( | ||
PreviousUpgradeNotFinalized.selector, | ||
bytes32(proposedUpgrade.l2ProtocolUpgradeTx.factoryDeps[0]) |
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.
the test logic seem to be wrong, it says "wrong factory deps", but in fact the upgrade expects to receive the factory dep in the error
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.
Yeah, this test was targeted towards an earlier version (v-25). Changed it.
import {VerifierParams} from "contracts/state-transition/chain-interfaces/IVerifier.sol"; | ||
import {MAX_NEW_FACTORY_DEPS, SYSTEM_UPGRADE_L2_TX_TYPE, MAX_ALLOWED_MINOR_VERSION_DELTA} from "contracts/common/Config.sol"; | ||
import {SemVer} from "contracts/common/libraries/SemVer.sol"; | ||
import {ProtocolVersionMinorDeltaTooBig, TimeNotReached, InvalidTxType, L2UpgradeNonceNotEqualToNewProtocolVersion, TooManyFactoryDeps, ProtocolVersionTooSmall, PreviousUpgradeNotFinalized, PreviousUpgradeNotCleaned, PreviousUpgradeNotFinalized, PatchCantSetUpgradeTxn, PreviousProtocolMajorVersionNotZero, NewProtocolMajorVersionNotZero, PatchUpgradeCantSetDefaultAccount, PatchUpgradeCantSetBootloader} from "contracts/upgrades/ZkSyncUpgradeErrors.sol"; |
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.
nit: PreviousUpgradeNotFinalized
listed twice
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.
Removed one import.
} | ||
|
||
// Upgrade with mock factoryDepHash | ||
function test_revertWhen_WrongFactoryDepHash() public { |
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.
this function does not test any revert
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.
True. Changed the name.
} | ||
|
||
// Factory deps can be at most 64 (MAX_NEW_FACTORY_DEPS) | ||
function test_revertWhen_FactoryDepsCanBeAtMost32(uint8 maxNewFactoryDeps) public { |
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.
the name is incorrect
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.
Corrected.
@@ -1 +1 @@ | |||
1718185700858 |
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.
just in case, could you please remove changes for timestamp
? We don't use hardhat anymore so this thing is not needed. What's more, we probably shouldn't commit it even as it was intended for local compiler caching
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.
That makes sense. Will make this change in the next PR.
Replaces PR #496 to counter the failing CI check for coverage (in the post-coverage report step)