Skip to content

Commit

Permalink
CHANGELOG. Include checks in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mtabasco committed Sep 19, 2023
1 parent 22d2859 commit a007b08
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog

All notable changes to SSV Network contracts will be documented in this file.

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [v1.0.1.rc4] - 2023-09-19

### Fixed

- [22d2859](https://github.com/bloxapp/ssv-network/pull/262/commits/22d2859d8fe6267b09c7a1c9c645df19bdaa03ff) Fix bug in network earnings withdrawals.
26 changes: 12 additions & 14 deletions test/account/withdraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,16 @@ describe('Withdraw Tests', () => {
});

it('Sequentially withdraw more than the cluster balance reverts "InsufficientBalance"', async () => {
cluster1 = await helpers.deposit(1,
cluster1.owner,
cluster1.operatorIds,
(minDepositAmount * 2).toString(),
cluster1.cluster);

cluster1 = await helpers.withdraw(4,
cluster1.operatorIds,
minDepositAmount,
cluster1.cluster);
const burnPerBlock = helpers.CONFIG.minimalOperatorFee * 4;

cluster1 = await helpers.withdraw(4,
cluster1.operatorIds,
minDepositAmount,
cluster1.cluster);
cluster1 = await helpers.deposit(1, cluster1.owner, cluster1.operatorIds, (minDepositAmount * 2).toString(), cluster1.cluster);
expect(await ssvViews.getBalance(helpers.DB.owners[4].address, cluster1.operatorIds, cluster1.cluster)).to.be.equals(minDepositAmount * 3 - (burnPerBlock * 2));

cluster1 = await helpers.withdraw(4, cluster1.operatorIds, minDepositAmount, cluster1.cluster);
expect(await ssvViews.getBalance(helpers.DB.owners[4].address, cluster1.operatorIds, cluster1.cluster)).to.be.equals(minDepositAmount * 2 - (burnPerBlock * 3));

cluster1 = await helpers.withdraw(4, cluster1.operatorIds, minDepositAmount, cluster1.cluster);
expect(await ssvViews.getBalance(helpers.DB.owners[4].address, cluster1.operatorIds, cluster1.cluster)).to.be.equals(minDepositAmount - (burnPerBlock * 4));

await expect(ssvNetworkContract.connect(helpers.DB.owners[4]).withdraw(cluster1.operatorIds, minDepositAmount, cluster1.cluster)).to.be.revertedWithCustomError(ssvNetworkContract, 'InsufficientBalance');
});
Expand Down Expand Up @@ -120,7 +115,10 @@ describe('Withdraw Tests', () => {

it('Sequentially withdraw more than the operator balance reverts "InsufficientBalance"', async () => {
await ssvNetworkContract.connect(helpers.DB.owners[0]).withdrawOperatorEarnings(1, helpers.CONFIG.minimalOperatorFee * 3);
expect(await ssvViews.getOperatorEarnings(1)).to.be.equals(helpers.CONFIG.minimalOperatorFee * 4 - helpers.CONFIG.minimalOperatorFee * 3);

await ssvNetworkContract.connect(helpers.DB.owners[0]).withdrawOperatorEarnings(1, helpers.CONFIG.minimalOperatorFee * 3);
expect(await ssvViews.getOperatorEarnings(1)).to.be.equals(helpers.CONFIG.minimalOperatorFee * 6 - helpers.CONFIG.minimalOperatorFee * 6);

await expect(ssvNetworkContract.connect(helpers.DB.owners[0]).withdrawOperatorEarnings(1, helpers.CONFIG.minimalOperatorFee * 3
)).to.be.revertedWithCustomError(ssvNetworkContract, 'InsufficientBalance');
Expand Down
8 changes: 4 additions & 4 deletions test/dao/network-fee-withdraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ describe('DAO Network Fee Withdraw Tests', () => {
await helpers.registerValidators(4, 1, minDepositAmount, helpers.DataGenerator.cluster.new(), [GasGroup.REGISTER_VALIDATOR_NEW_STATE]);
await utils.progressBlocks(10);

// Temporary till deposit logic not available
// Mint tokens
await helpers.DB.ssvToken.mint(ssvNetworkContract.address, minDepositAmount);
});

it('Withdraw network earnings emits "NetworkEarningsWithdrawn"', async () => {
Expand Down Expand Up @@ -73,9 +70,12 @@ describe('DAO Network Fee Withdraw Tests', () => {
const amount = await ssvViews.getNetworkEarnings() / 2;

await ssvNetworkContract.withdrawNetworkEarnings(amount);
expect(await ssvViews.getNetworkEarnings()).to.be.equals(((networkFee * 13) + (networkFee * 11) - amount));

await ssvNetworkContract.withdrawNetworkEarnings(amount);
expect(await ssvViews.getNetworkEarnings()).to.be.equals(((networkFee * 14) + (networkFee * 12) - amount * 2));

await expect(ssvNetworkContract.withdrawNetworkEarnings(amount
)).to.be.revertedWithCustomError(ssvNetworkContract, 'InsufficientBalance');
)).to.be.revertedWithCustomError(ssvNetworkContract, 'InsufficientBalance');
});
});

0 comments on commit a007b08

Please sign in to comment.