-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16a26bc
commit 30f1e54
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
l1-contracts/test/foundry/l2/unit/L2AdminFactory/L2AdminFactory.t.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.20; | ||
|
||
import {Test} from "forge-std/Test.sol"; | ||
|
||
import {IBridgehub} from "contracts/bridgehub/IBridgehub.sol"; | ||
import { L2AdminFactory } from "contracts/governance/L2AdminFactory.sol"; | ||
import { PermanentRestriction } from "contracts/governance/PermanentRestriction.sol"; | ||
import { IPermanentRestriction } from "contracts/governance/IPermanentRestriction.sol"; | ||
|
||
contract L2AdminFactoryTest is Test { | ||
function testL2AdminFactory() public { | ||
address[] memory requiredRestrictions = new address[](1); | ||
requiredRestrictions[0] = makeAddr("required"); | ||
|
||
L2AdminFactory factory = new L2AdminFactory(requiredRestrictions); | ||
|
||
address[] memory additionalRestrictions = new address[](1); | ||
additionalRestrictions[0] = makeAddr("additional"); | ||
|
||
address[] memory allRestrictions = new address[](2); | ||
allRestrictions[0] = requiredRestrictions[0]; | ||
allRestrictions[1] = additionalRestrictions[0]; | ||
|
||
|
||
bytes32 salt = keccak256("salt"); | ||
|
||
address admin = factory.deployAdmin(additionalRestrictions, salt); | ||
|
||
// Now, we need to check whether it would be able to accept such an admin | ||
PermanentRestriction restriction = new PermanentRestriction( | ||
IBridgehub(address(0)), | ||
address(factory) | ||
); | ||
|
||
bytes32 codeHash; | ||
assembly { | ||
codeHash := extcodehash(admin) | ||
} | ||
|
||
vm.expectEmit(true, false, false, true); | ||
emit IPermanentRestriction.AllowL2Admin(admin); | ||
restriction.allowL2Admin( | ||
salt, | ||
codeHash, | ||
keccak256(abi.encode(allRestrictions)) | ||
); | ||
} | ||
} |