Skip to content
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

Feature/ejector contract tests #212

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions .github/workflows/reusable-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,21 @@ jobs:
run: forge install

- uses: foundry-rs/foundry-toolchain@v1
- name: Run forge tests
- name: Run forge tests - Contract
working-directory: contracts
run: forge test
run: forge test --no-match-contract 'Integration'

- name: Run forge tests - Integration folder
run: |
make start-anvil-and-deploy
cd contracts
forge test -vvv --fork-url=http://localhost:8545 --match-contract 'Integration'

- name: kill anvil
if: success() || failure()
run: |
pkill anvil


build-foundry-deployer-image:
name: Build foundry deployer Docker image with smart contracts code
Expand Down
2 changes: 1 addition & 1 deletion avs-eigensdk-go
33 changes: 0 additions & 33 deletions contracts/script/output/31337/strategy_output.json

This file was deleted.

26 changes: 26 additions & 0 deletions contracts/test/integration/TestUtils.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
pragma solidity =0.8.12;

import "forge-std/Test.sol";
import "forge-std/Script.sol";
import "forge-std/StdJson.sol";
import "forge-std/console.sol";

contract TestUtils is Script, Test {

function getAvsConfigFile() view public returns (string memory){
string memory configData = vm.readFile("script/output/31337/avs_deployment_output.json");
return configData;
}
function getRollDownConfigFileEth() view public returns (string memory){
string memory configData = vm.readFile("script/output/31337/ethereum_rolldown_output.json");
return configData;
}
function getRollDownConfigFileArb() view public returns (string memory){
string memory configData = vm.readFile("script/output/31337/arbitrum_rolldown_output.json");
return configData;
}
function getErc20ConfigFile() view public returns (string memory){
string memory configData = vm.readFile("script/output/31337/strategy_output.json");
return configData;
}
}
92 changes: 92 additions & 0 deletions contracts/test/integration/ejector.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// SPDX-License-Identifier: BUSL-1.1
// ::: How to run:::
//cd contracts ; pkill anvil ; clear ; cd ../ ; make start-anvil-and-deploy ; cd contracts ; forge test -vvv --fork-url=http://localhost:8545 --match-contract 'Integration'
pragma solidity =0.8.12;

import { FinalizerServiceManager } from "../../src/FinalizerServiceManager.sol";
import {BitmapUtils} from "@eigenlayer-middleware/src/libraries/BitmapUtils.sol";
import { TestUtils } from "./TestUtils.sol";
import "forge-std/StdJson.sol";
import "forge-std/Test.sol";

contract IntegrationEjectorAdminRuleTest is Test {

address deployer = address(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266);

function testEjectorCanBeResetByDeployer() public {

address tu = address(deployer);

FinalizerServiceManager fsm = FinalizerServiceManager(stdJson.readAddress(new TestUtils().getRollDownConfigFileEth(), ".addresses.serviceManager"));
address ejectorAddr = fsm.ejector();
emit log_address(ejectorAddr);

vm.startBroadcast(tu);
fsm.setEjector(tu);
vm.stopBroadcast();

address ejectorAddr2 = fsm.ejector();
emit log_address(ejectorAddr2);
assert(ejectorAddr != ejectorAddr2);

}
function testEjectorCanNotBeResetByaNonDeployer() public {

address tu = address(101);

FinalizerServiceManager fsm = FinalizerServiceManager(stdJson.readAddress(new TestUtils().getRollDownConfigFileEth(), ".addresses.serviceManager"));
address ejectorAddr = fsm.ejector();
emit log_address(ejectorAddr);

vm.startBroadcast(tu);
vm.expectRevert("Ownable: caller is not the owner");
fsm.setEjector(tu);
vm.stopBroadcast();

address ejectorAddr2 = fsm.ejector();
emit log_address(ejectorAddr2);
assert(ejectorAddr == ejectorAddr2);

}
function testEjectorCanEject() public {

FinalizerServiceManager fsm = FinalizerServiceManager(stdJson.readAddress(new TestUtils().getRollDownConfigFileEth(), ".addresses.serviceManager"));
address ejectorAddr = fsm.ejector();

address[] memory operators = new address[](2);
operators[0] = address(0x1);
operators[1] = address(0x2);

bytes[] memory quorumNumbers = new bytes[](2) ;
quorumNumbers[0] = BitmapUtils.bitmapToBytesArray(0);
quorumNumbers[1] = BitmapUtils.bitmapToBytesArray(1);
console.log("quorumNumbers");

vm.startBroadcast(ejectorAddr);
vm.expectRevert("RegistryCoordinator._deregisterOperator: operator is not registered");
fsm.ejectOperators(operators, quorumNumbers);
vm.stopBroadcast();

}
//https://mangatafinance.atlassian.net/browse/MGX-1315
function testOwnerCanEject() public {

FinalizerServiceManager fsm = FinalizerServiceManager(stdJson.readAddress(new TestUtils().getRollDownConfigFileEth(), ".addresses.serviceManager"));
address ejectorAddr = fsm.ejector();

address[] memory operators = new address[](2);
operators[0] = address(0x1);
operators[1] = address(0x2);

bytes[] memory quorumNumbers = new bytes[](2) ;
quorumNumbers[0] = BitmapUtils.bitmapToBytesArray(0);
quorumNumbers[1] = BitmapUtils.bitmapToBytesArray(1);
console.log("quorumNumbers");

vm.startBroadcast(deployer);
vm.expectRevert("RegistryCoordinator._deregisterOperator: operator is not registered");
fsm.ejectOperators(operators, quorumNumbers);
vm.stopBroadcast();

}
}
File renamed without changes.
Loading