Skip to content

Commit

Permalink
test(contracts): fix Symbiotic tests with correct version
Browse files Browse the repository at this point in the history
  • Loading branch information
mempirate committed Oct 23, 2024
1 parent d6ad4ee commit f72732a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 29 deletions.
48 changes: 25 additions & 23 deletions bolt-contracts/test/BoltManager.Symbiotic.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {IVault} from "@symbiotic/interfaces/vault/IVault.sol";
import {IOptInService} from "@symbiotic/interfaces/service/IOptInService.sol";
import {IVaultConfigurator} from "@symbiotic/interfaces/IVaultConfigurator.sol";
import {IBaseDelegator} from "@symbiotic/interfaces/delegator/IBaseDelegator.sol";
import {IBaseSlasher} from "@symbiotic/interfaces/slasher/IBaseSlasher.sol";
import {IMetadataService} from "@symbiotic/interfaces/service/IMetadataService.sol";
import {INetworkRestakeDelegator} from "@symbiotic/interfaces/delegator/INetworkRestakeDelegator.sol";
import {INetworkMiddlewareService} from "@symbiotic/interfaces/service/INetworkMiddlewareService.sol";
Expand All @@ -18,7 +19,6 @@ import {IVetoSlasher} from "@symbiotic/interfaces/slasher/IVetoSlasher.sol";
import {IDelegatorFactory} from "@symbiotic/interfaces/IDelegatorFactory.sol";
import {IMigratablesFactory} from "@symbiotic/interfaces/common/IMigratablesFactory.sol";
import {Subnetwork} from "@symbiotic/contracts/libraries/Subnetwork.sol";
import {SimpleCollateral} from "@symbiotic/../test/mocks/SimpleCollateral.sol";

import {IBoltValidatorsV1} from "../src/interfaces/IBoltValidatorsV1.sol";
import {IBoltMiddlewareV1} from "../src/interfaces/IBoltMiddlewareV1.sol";
Expand All @@ -32,6 +32,7 @@ import {BoltConfig} from "../src/lib/Config.sol";
import {Utils} from "./Utils.sol";

import {SymbioticSetupFixture} from "./fixtures/SymbioticSetup.f.sol";
import {Token} from "../test/mocks/Token.sol";

contract BoltManagerSymbioticTest is Test {
using BLS12381 for BLS12381.G1Point;
Expand Down Expand Up @@ -60,7 +61,7 @@ contract BoltManagerSymbioticTest is Test {
IVault public vault;
INetworkRestakeDelegator public networkRestakeDelegator;
IVaultConfigurator public vaultConfigurator;
SimpleCollateral public collateral;
Token public collateral;

address deployer = makeAddr("deployer");
address admin = makeAddr("admin");
Expand Down Expand Up @@ -102,21 +103,21 @@ contract BoltManagerSymbioticTest is Test {
IVaultConfigurator.InitParams memory vaultConfiguratorInitParams = IVaultConfigurator.InitParams({
version: IMigratablesFactory(vaultConfigurator.VAULT_FACTORY()).lastVersion(),
owner: vaultAdmin,
vaultParams: IVault.InitParams({
collateral: address(collateral),
delegator: address(0),
slasher: address(0),
burner: address(0xdead),
epochDuration: EPOCH_DURATION,
depositWhitelist: false,
isDepositLimit: false,
depositLimit: 0,
defaultAdminRoleHolder: vaultAdmin,
depositWhitelistSetRoleHolder: vaultAdmin,
depositorWhitelistRoleHolder: vaultAdmin,
isDepositLimitSetRoleHolder: vaultAdmin,
depositLimitSetRoleHolder: vaultAdmin
}),
vaultParams: abi.encode(
IVault.InitParams({
collateral: address(collateral),
burner: address(0xdead),
epochDuration: EPOCH_DURATION,
depositWhitelist: false,
isDepositLimit: false,
depositLimit: 0,
defaultAdminRoleHolder: vaultAdmin,
depositWhitelistSetRoleHolder: vaultAdmin,
depositorWhitelistRoleHolder: vaultAdmin,
isDepositLimitSetRoleHolder: vaultAdmin,
depositLimitSetRoleHolder: vaultAdmin
})
),
delegatorIndex: 0, // Use NetworkRestakeDelegator
delegatorParams: abi.encode(
INetworkRestakeDelegator.InitParams({
Expand All @@ -133,6 +134,9 @@ contract BoltManagerSymbioticTest is Test {
slasherIndex: 1, // Use VetoSlasher
slasherParams: abi.encode(
IVetoSlasher.InitParams({
baseParams: IBaseSlasher.BaseParams({
isBurnerHook: false // ?
}),
// veto duration must be smaller than epoch duration
vetoDuration: uint48(12 hours),
resolverSetEpochsDelay: 3
Expand Down Expand Up @@ -245,21 +249,19 @@ contract BoltManagerSymbioticTest is Test {
networkRestakeDelegator.setNetworkLimit(subnetwork, 2 ether);

// --- Add stake to the Vault ---
deal(address(collateral), provider, 1 ether);

vm.prank(provider);
SimpleCollateral(collateral).mint(1 ether);

vm.prank(provider);
SimpleCollateral(collateral).approve(address(vault), 1 ether);
collateral.approve(address(vault), 1 ether);

// deposit collateral from "provider" on behalf of "operator"
vm.prank(provider);
(uint256 depositedAmount, uint256 mintedShares) = vault.deposit(operator, 1 ether);

assertEq(depositedAmount, 1 ether);
assertEq(mintedShares, 1 ether);
assertEq(vault.balanceOf(operator), 1 ether);
assertEq(SimpleCollateral(collateral).balanceOf(address(vault)), 1 ether);
assertEq(vault.slashableBalanceOf(operator), 1 ether);
assertEq(collateral.balanceOf(address(vault)), 1 ether);
}

/// @notice Compute the hash of a BLS public key
Expand Down
11 changes: 5 additions & 6 deletions bolt-contracts/test/fixtures/SymbioticSetup.f.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {Slasher} from "@symbiotic/contracts/slasher/Slasher.sol";
import {VetoSlasher} from "@symbiotic/contracts/slasher/VetoSlasher.sol";
import {VaultConfigurator} from "@symbiotic/contracts/VaultConfigurator.sol";

import {SimpleCollateral} from "@symbiotic/../test/mocks/SimpleCollateral.sol";
import {Token} from "../mocks/Token.sol";

contract SymbioticSetupFixture is Test {
Expand All @@ -40,7 +39,7 @@ contract SymbioticSetupFixture is Test {
OptInService operatorVaultOptInService,
OptInService operatorNetworkOptInService,
VaultConfigurator vaultConfigurator,
SimpleCollateral collateral
Token collateral
)
{
vm.startPrank(deployer);
Expand All @@ -53,9 +52,10 @@ contract SymbioticSetupFixture is Test {
MetadataService operatorMetadataService_ = new MetadataService(address(operatorRegistry_));
MetadataService networkMetadataService_ = new MetadataService(address(networkRegistry_));
NetworkMiddlewareService networkMiddlewareService_ = new NetworkMiddlewareService(address(networkRegistry_));
OptInService operatorVaultOptInService_ = new OptInService(address(operatorRegistry_), address(vaultFactory_));
OptInService operatorVaultOptInService_ =
new OptInService(address(operatorRegistry_), address(vaultFactory_), "vaultOptIn");
OptInService operatorNetworkOptInService_ =
new OptInService(address(operatorRegistry_), address(networkRegistry_));
new OptInService(address(operatorRegistry_), address(networkRegistry_), "networkOptIn");

Vault vault_ = new Vault(address(delegatorFactory_), address(slasherFactory_), address(vaultFactory_));
vaultFactory_.whitelist(address(vault_));
Expand Down Expand Up @@ -113,7 +113,6 @@ contract SymbioticSetupFixture is Test {
slasherFactory_.transferOwnership(owner);

Token token_ = new Token("Token");
SimpleCollateral collateral_ = new SimpleCollateral(address(token_));

vm.stopPrank();

Expand All @@ -129,7 +128,7 @@ contract SymbioticSetupFixture is Test {
operatorVaultOptInService_,
operatorNetworkOptInService_,
vaultConfigurator_,
collateral_
token_
);
}
}

0 comments on commit f72732a

Please sign in to comment.