Skip to content

Commit

Permalink
fix(contracts): fix tests, integrate parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
mempirate committed Oct 11, 2024
1 parent c2a0732 commit 6da5685
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
13 changes: 11 additions & 2 deletions bolt-contracts/test/BoltManager.EigenLayer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {Test, console} from "forge-std/Test.sol";

import {BoltValidators} from "../src/contracts/BoltValidators.sol";
import {BoltManager} from "../src/contracts/BoltManager.sol";
import {BoltParameters} from "../src/contracts/BoltParameters.sol";
import {BoltEigenLayerMiddleware} from "../src/contracts/BoltEigenLayerMiddleware.sol";
import {IBoltValidators} from "../src/interfaces/IBoltValidators.sol";
import {IBoltManager} from "../src/interfaces/IBoltManager.sol";
Expand Down Expand Up @@ -50,15 +51,23 @@ contract BoltManagerEigenLayerTest is Test {
eigenLayerDeployer = new EigenLayerDeployer(staker);
eigenLayerDeployer.setUp();

uint48 epochDuration = 1 days;
uint48 slashingWindow = 7 days;
bool allowUnsafeRegistration = true;

BoltParameters parameters = new BoltParameters();
parameters.initialize(admin, epochDuration, slashingWindow, allowUnsafeRegistration);

// Deploy Bolt contracts
validators = new BoltValidators();
validators.initialize(admin);
validators.initialize(admin, address(parameters));
manager = new BoltManager();
manager.initialize(admin, address(validators));
manager.initialize(admin, address(parameters), address(validators));
middleware = new BoltEigenLayerMiddleware();

middleware.initialize(
address(admin),
address(parameters),
address(manager),
address(eigenLayerDeployer.avsDirectory()),
address(eigenLayerDeployer.delegationManager()),
Expand Down
13 changes: 11 additions & 2 deletions bolt-contracts/test/BoltManager.Symbiotic.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {SimpleCollateral} from "@symbiotic/../test/mocks/SimpleCollateral.sol";
import {IBoltValidators} from "../src/interfaces/IBoltValidators.sol";
import {IBoltMiddleware} from "../src/interfaces/IBoltMiddleware.sol";

import {BoltParameters} from "../src/contracts/BoltParameters.sol";
import {BoltValidators} from "../src/contracts/BoltValidators.sol";
import {BoltManager} from "../src/contracts/BoltManager.sol";
import {BoltSymbioticMiddleware} from "../src/contracts/BoltSymbioticMiddleware.sol";
Expand Down Expand Up @@ -150,15 +151,23 @@ contract BoltManagerSymbioticTest is Test {

// --- Deploy Bolt contracts ---

uint48 epochDuration = 1 days;
uint48 slashingWindow = 7 days;
bool allowUnsafeRegistration = true;

BoltParameters parameters = new BoltParameters();
parameters.initialize(admin, epochDuration, slashingWindow, allowUnsafeRegistration);

validators = new BoltValidators();
validators.initialize(admin);
validators.initialize(admin, address(parameters));
manager = new BoltManager();
manager.initialize(admin, address(validators));
manager.initialize(admin, address(parameters), address(validators));

middleware = new BoltSymbioticMiddleware();

middleware.initialize(
admin,
address(parameters),
address(manager),
networkAdmin,
address(operatorRegistry),
Expand Down
13 changes: 11 additions & 2 deletions bolt-contracts/test/BoltValidators.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ pragma solidity 0.8.25;

import {Test, console} from "forge-std/Test.sol";

import {BoltParameters} from "../src/contracts/BoltParameters.sol";
import {BoltValidators} from "../src/contracts/BoltValidators.sol";
import {IBoltValidators} from "../src/interfaces/IBoltValidators.sol";
import {BLS12381} from "../src/lib/bls/BLS12381.sol";

contract BoltValidatorsTest is Test {
using BLS12381 for BLS12381.G1Point;

BoltParameters public parameters;
BoltValidators public validators;

uint128 public constant PRECONF_MAX_GAS_LIMIT = 5_000_000;
Expand All @@ -20,8 +22,15 @@ contract BoltValidatorsTest is Test {
address validator = makeAddr("validator");

function setUp() public {
uint48 epochDuration = 1 days;
uint48 slashingWindow = 7 days;
bool allowUnsafeRegistration = true;

parameters = new BoltParameters();

parameters.initialize(admin, epochDuration, slashingWindow, allowUnsafeRegistration);
validators = new BoltValidators();
validators.initialize(admin);
validators.initialize(admin, address(parameters));
}

function testUnsafeRegistration() public {
Expand Down Expand Up @@ -53,7 +62,7 @@ contract BoltValidatorsTest is Test {
BLS12381.G1Point memory pubkey = BLS12381.generatorG1();

vm.prank(admin);
validators.setAllowUnsafeRegistration(false);
parameters.setAllowUnsafeRegistration(false);

vm.prank(validator);
vm.expectRevert(IBoltValidators.UnsafeRegistrationNotAllowed.selector);
Expand Down

0 comments on commit 6da5685

Please sign in to comment.