-
Notifications
You must be signed in to change notification settings - Fork 340
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
feat: Improving test coverage of SCs #240
Conversation
} | ||
|
||
function getTotalPriorityTxs() external view returns (uint256) { | ||
return priorityQueue.getTotalPriorityTxs(); | ||
return PriorityQueue.getTotalPriorityTxs(priorityQueue); |
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.
Why?
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.
using for
patterns are ignored by coverage
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 also wanted to ask why the PriorityQueue folder is missing from tests in this branch, but is available in the main.
Shall I add it back or maybe the base is not correct?
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.
You should add back, thanks!
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.
It moved to state-transition folder, so all good, missed it :)
l1-contracts/test/foundry/unit/concrete/AddressAliasHelper/_AddressAliasHelper_Shared.t.sol
Show resolved
Hide resolved
...tracts/test/foundry/unit/concrete/common/libraries/UncheckedMath/_UncheckedMath_Shared.t.sol
Show resolved
Hide resolved
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 make sure no dev-contracts
/tests
/artifacts
contracts in yarn coverage:foundry
// add this to be excluded from coverage report | ||
function test() internal virtual {} |
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 should be removed in order to PriorityQueue.sol
to be in coverage
// add this to be excluded from coverage report | ||
function test() internal virtual {} |
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.
Same here
uint256 chainId = block.chainid; | ||
Diamond.DiamondCutData memory initialDiamondCutData = getDiamondCutData(diamondInit); | ||
|
||
vm.expectRevert(bytes("StateTransition: only bridgehub")); |
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.
It doesn't seem that coverage captured modifier's revert, researching how to make it work
|
||
vm.expectRevert(bytes("StateTransition: only bridgehub")); | ||
|
||
chainContractAddress.createNewChain(chainId, baseToken, sharedBridge, admin, abi.encode(initialDiamondCutData)); |
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.
Will probably move new chain creation to a function, as it's been reused in multiple places
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.
done
vm.startPrank(governor); | ||
} | ||
|
||
function getAdminSelectors() private view returns (bytes4[] memory) { |
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.
Will move selector getters to Utils
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.
done
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.
It looks good! Just nits that you mentioned in the PR already and what I left and then we can merge
import {DiamondProxy} from "solpp/state-transition/chain-deps/DiamondProxy.sol"; | ||
|
||
contract createNewChainTest is StateTransitionManagerTest { | ||
function testRevertWhenInitialDiamondCutHashMismatch() 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.
Nit: I think convention is test_RevertWhen_
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.
done
|
||
// Call fails as storage is frozen | ||
vm.expectRevert(bytes.concat("q1")); | ||
isChainFrozen = gettersFacet.isDiamondStorageFrozen(); |
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.
Is it the case that this getter can't return true? (as the call reverts with the error described above)
What ❔
Add tests for contracts or simply factor existing tests, so that they are included in coverage report.
Why ❔
Increase overall coverage of smart contracts in the repo
Checklist