Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tamtamchik committed Feb 12, 2025
1 parent b19caf9 commit ccd9043
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion contracts/0.8.25/vaults/StakingVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {IStakingVault} from "./interfaces/IStakingVault.sol";
* - `lock()`
* - `report()`
* - `rebalance()`
* - `forceValidatorWithdrawals()`
* - `triggerValidatorWithdrawal()` (only full validator exit when the vault is unbalanced)
* - Anyone:
* - Can send ETH directly to the vault (treated as rewards)
*
Expand Down
2 changes: 1 addition & 1 deletion contracts/0.8.25/vaults/VaultHub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ abstract contract VaultHub is PausableUntilWithRoles {
/// @param _vault vault address
/// @param _pubkeys pubkeys of the validators to withdraw
/// @param _refundRecepient address of the recipient of the refund
function forceValidatorWithdrawals(
function forceValidatorWithdrawal(
address _vault,
bytes calldata _pubkeys,
address _refundRecepient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ contract StakingVault__HarnessForTestUpgrade is IStakingVault, OwnableUpgradeabl
address _recipient
) external payable {}

function forceValidatorWithdrawals(bytes calldata _pubkeys) external payable {}

error ZeroArgument(string name);
error VaultAlreadyInitialized();
}
22 changes: 11 additions & 11 deletions test/0.8.25/vaults/vaulthub/vaulthub.withdrawals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,47 +109,47 @@ describe("VaultHub.sol:withdrawals", () => {
});
});

context("forceValidatorWithdrawals", () => {
context("forceValidatorWithdrawal", () => {
it("reverts if msg.value is 0", async () => {
await expect(vaultHub.forceValidatorWithdrawals(vaultAddress, SAMPLE_PUBKEY, feeRecipient, { value: 0n }))
await expect(vaultHub.forceValidatorWithdrawal(vaultAddress, SAMPLE_PUBKEY, feeRecipient, { value: 0n }))
.to.be.revertedWithCustomError(vaultHub, "ZeroArgument")
.withArgs("msg.value");
});

it("reverts if the vault is zero address", async () => {
await expect(vaultHub.forceValidatorWithdrawals(ZeroAddress, SAMPLE_PUBKEY, feeRecipient, { value: 1n }))
await expect(vaultHub.forceValidatorWithdrawal(ZeroAddress, SAMPLE_PUBKEY, feeRecipient, { value: 1n }))
.to.be.revertedWithCustomError(vaultHub, "ZeroArgument")
.withArgs("_vault");
});

it("reverts if zero pubkeys", async () => {
await expect(vaultHub.forceValidatorWithdrawals(vaultAddress, "0x", feeRecipient, { value: 1n }))
await expect(vaultHub.forceValidatorWithdrawal(vaultAddress, "0x", feeRecipient, { value: 1n }))
.to.be.revertedWithCustomError(vaultHub, "ZeroArgument")
.withArgs("_pubkeys");
});

it("reverts if zero refund recipient", async () => {
await expect(vaultHub.forceValidatorWithdrawals(vaultAddress, SAMPLE_PUBKEY, ZeroAddress, { value: 1n }))
await expect(vaultHub.forceValidatorWithdrawal(vaultAddress, SAMPLE_PUBKEY, ZeroAddress, { value: 1n }))
.to.be.revertedWithCustomError(vaultHub, "ZeroArgument")
.withArgs("_refundRecepient");
});

it("reverts if vault is not connected to the hub", async () => {
await expect(vaultHub.forceValidatorWithdrawals(stranger, SAMPLE_PUBKEY, feeRecipient, { value: 1n }))
await expect(vaultHub.forceValidatorWithdrawal(stranger, SAMPLE_PUBKEY, feeRecipient, { value: 1n }))
.to.be.revertedWithCustomError(vaultHub, "NotConnectedToHub")
.withArgs(stranger.address);
});

it("reverts if called for a disconnected vault", async () => {
await vaultHub.connect(user).disconnect(vaultAddress);

await expect(vaultHub.forceValidatorWithdrawals(vaultAddress, SAMPLE_PUBKEY, feeRecipient, { value: 1n }))
await expect(vaultHub.forceValidatorWithdrawal(vaultAddress, SAMPLE_PUBKEY, feeRecipient, { value: 1n }))
.to.be.revertedWithCustomError(vaultHub, "NotConnectedToHub")
.withArgs(vaultAddress);
});

it("reverts if called for a healthy vault", async () => {
await expect(vaultHub.forceValidatorWithdrawals(vaultAddress, SAMPLE_PUBKEY, feeRecipient, { value: 1n }))
await expect(vaultHub.forceValidatorWithdrawal(vaultAddress, SAMPLE_PUBKEY, feeRecipient, { value: 1n }))
.to.be.revertedWithCustomError(vaultHub, "AlreadyBalanced")
.withArgs(vaultAddress, 0n, 0n);
});
Expand All @@ -158,13 +158,13 @@ describe("VaultHub.sol:withdrawals", () => {
beforeEach(async () => await makeVaultUnhealthy());

it("reverts if fees are insufficient", async () => {
await expect(vaultHub.forceValidatorWithdrawals(vaultAddress, SAMPLE_PUBKEY, feeRecipient, { value: 1n }))
await expect(vaultHub.forceValidatorWithdrawal(vaultAddress, SAMPLE_PUBKEY, feeRecipient, { value: 1n }))
.to.be.revertedWithCustomError(vault, "InsufficientValidatorWithdrawalFee")
.withArgs(1n, FEE);
});

it("initiates force validator withdrawal", async () => {
await expect(vaultHub.forceValidatorWithdrawals(vaultAddress, SAMPLE_PUBKEY, feeRecipient, { value: FEE }))
await expect(vaultHub.forceValidatorWithdrawal(vaultAddress, SAMPLE_PUBKEY, feeRecipient, { value: FEE }))
.to.emit(vaultHub, "VaultForceWithdrawalTriggered")
.withArgs(vaultAddress, SAMPLE_PUBKEY, feeRecipient);
});
Expand All @@ -174,7 +174,7 @@ describe("VaultHub.sol:withdrawals", () => {
const pubkeys = "0x" + "ab".repeat(numPubkeys * 48);

await expect(
vaultHub.forceValidatorWithdrawals(vaultAddress, pubkeys, feeRecipient, { value: FEE * BigInt(numPubkeys) }),
vaultHub.forceValidatorWithdrawal(vaultAddress, pubkeys, feeRecipient, { value: FEE * BigInt(numPubkeys) }),
)
.to.emit(vaultHub, "VaultForceWithdrawalTriggered")
.withArgs(vaultAddress, pubkeys, feeRecipient);
Expand Down

0 comments on commit ccd9043

Please sign in to comment.