From a007b08edc54a3076cc8f99638b34c42b0bb1667 Mon Sep 17 00:00:00 2001 From: Marco Date: Tue, 19 Sep 2023 12:41:22 +0200 Subject: [PATCH] CHANGELOG. Include checks in tests --- CHANGELOG.md | 13 +++++++++++++ test/account/withdraw.ts | 26 ++++++++++++-------------- test/dao/network-fee-withdraw.ts | 8 ++++---- 3 files changed, 29 insertions(+), 18 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..166b5261 --- /dev/null +++ b/CHANGELOG.md @@ -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. diff --git a/test/account/withdraw.ts b/test/account/withdraw.ts index dd9b9f89..5c5c6068 100644 --- a/test/account/withdraw.ts +++ b/test/account/withdraw.ts @@ -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'); }); @@ -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'); diff --git a/test/dao/network-fee-withdraw.ts b/test/dao/network-fee-withdraw.ts index d8b60dda..c09cdad1 100644 --- a/test/dao/network-fee-withdraw.ts +++ b/test/dao/network-fee-withdraw.ts @@ -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 () => { @@ -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'); }); }); \ No newline at end of file