-
Notifications
You must be signed in to change notification settings - Fork 195
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
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
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,44 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity =0.8.12; | ||
|
||
import "../MockEigenDADeployer.sol"; | ||
|
||
contract EigenDARelayRegistryUnit is MockEigenDADeployer { | ||
|
||
event RelayAdded(address indexed relay, uint32 indexed key, string relayURL); | ||
|
||
function setUp() virtual public { | ||
_deployDA(); | ||
} | ||
|
||
function test_initalize() public { | ||
require(eigenDARelayRegistry.owner() == registryCoordinatorOwner, "EigenDARelayRegistry: owner is not set"); | ||
vm.expectRevert("Initializable: contract is already initialized"); | ||
eigenDARelayRegistry.initialize(address(this)); | ||
} | ||
|
||
function test_addRelayInfo() public { | ||
RelayInfo memory relayInfo = RelayInfo({ | ||
relayAddress: address(uint160(uint256(keccak256(abi.encodePacked("relay"))))), | ||
relayURL: "https://relay.com" | ||
}); | ||
|
||
vm.expectEmit(address(eigenDARelayRegistry)); | ||
emit RelayAdded(relayInfo.relayAddress, eigenDARelayRegistry.nextRelayKey(), relayInfo.relayURL); | ||
vm.prank(registryCoordinatorOwner); | ||
eigenDARelayRegistry.addRelayInfo(relayInfo); | ||
|
||
assertEq(eigenDARelayRegistry.relayKeyToAddress(eigenDARelayRegistry.nextRelayKey() - 1), relayInfo.relayAddress); | ||
assertEq(eigenDARelayRegistry.relayKeyToUrl(eigenDARelayRegistry.nextRelayKey() - 1), relayInfo.relayURL); | ||
} | ||
|
||
function test_addRelayInfo_revert_notOwner() public { | ||
RelayInfo memory relayInfo = RelayInfo({ | ||
relayAddress: address(uint160(uint256(keccak256(abi.encodePacked("relay"))))), | ||
relayURL: "https://relay.com" | ||
}); | ||
|
||
vm.expectRevert("Ownable: caller is not the owner"); | ||
eigenDARelayRegistry.addRelayInfo(relayInfo); | ||
} | ||
} |