Skip to content

Commit

Permalink
relay test
Browse files Browse the repository at this point in the history
  • Loading branch information
0x0aa0 committed Dec 19, 2024
1 parent 2a2350d commit 3fad78b
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions contracts/test/unit/EigenDARelayRegistryUnit.t.sol
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);
}
}

0 comments on commit 3fad78b

Please sign in to comment.