From 9d0b94305a6f2331305b2342d79cb0d826cf376c Mon Sep 17 00:00:00 2001 From: Greg Hysen Date: Tue, 25 Jun 2019 18:07:31 -0700 Subject: [PATCH] deleted old staker test - much code saved! --- contracts/staking/test/core_test.ts | 182 +--------------------------- 1 file changed, 1 insertion(+), 181 deletions(-) diff --git a/contracts/staking/test/core_test.ts b/contracts/staking/test/core_test.ts index cdb1b34115..5c607845bd 100644 --- a/contracts/staking/test/core_test.ts +++ b/contracts/staking/test/core_test.ts @@ -107,7 +107,7 @@ describe('Staking Core', () => { } }); - it.only('staking/unstaking', async () => { + it('staking/unstaking', async () => { // setup test parameters const amountToStake = stakingWrapper.toBaseUnitAmount(10); const amountToDeactivate = stakingWrapper.toBaseUnitAmount(4); @@ -131,186 +131,6 @@ describe('Staking Core', () => { await staker.withdrawAsync(amountToWithdraw); }); - it('staking/unstaking', async () => { - ///// 1 SETUP TEST PARAMETERS ///// - const amountToStake = stakingWrapper.toBaseUnitAmount(10); - const amountToDeactivate = stakingWrapper.toBaseUnitAmount(4); - const amountToReactivate = stakingWrapper.toBaseUnitAmount(1); - const amountToWithdraw = stakingWrapper.toBaseUnitAmount(1.5); - const owner = stakers[0]; - // check zrx token balances before minting stake - const zrxTokenBalanceOfVaultBeforeStaking = await stakingWrapper.getZrxTokenBalanceOfZrxVault(); - expect(zrxTokenBalanceOfVaultBeforeStaking).to.be.bignumber.equal(new BigNumber(0)); - const zrxTokenBalanceOfStakerBeforeStaking = await stakingWrapper.getZrxTokenBalance(owner); - expect(zrxTokenBalanceOfStakerBeforeStaking).to.be.bignumber.gte(amountToStake); - ///// 2 STAKE ZRX ///// - // mint stake - await stakingWrapper.depositAndStakeAsync(owner, amountToStake); - { - // check stake balance after minting - const stakeBalance = await stakingWrapper.getTotalStakeAsync(owner); - expect(stakeBalance).to.be.bignumber.equal(amountToStake); - // check zrx vault balance - const vaultBalance = await stakingWrapper.getZrxVaultBalance(owner); - expect(vaultBalance).to.be.bignumber.equal(amountToStake); - // check zrx token balances - const zrxTokenBalanceOfVaultAfterStaking = await stakingWrapper.getZrxTokenBalanceOfZrxVault(); - expect(zrxTokenBalanceOfVaultAfterStaking).to.be.bignumber.equal(amountToStake); - const zrxTokenBalanceOfStakerAfterStaking = await stakingWrapper.getZrxTokenBalance(owner); - expect(zrxTokenBalanceOfStakerAfterStaking).to.be.bignumber.equal(zrxTokenBalanceOfStakerBeforeStaking.minus(amountToStake)); - } - ///// 3 DEACTIVATE AND TIMELOCK STAKE ///// - // unstake - await stakingWrapper.deactivateAndTimelockStakeAsync(owner, amountToDeactivate); - { - // check total stake balance didn't change - const totalStake = await stakingWrapper.getTotalStakeAsync(owner); - expect(totalStake).to.be.bignumber.equal(amountToStake); - // check timelocked stake is no longer activated - const activatedStakeBalance = await stakingWrapper.getActivatedStakeAsync(owner); - expect(activatedStakeBalance).to.be.bignumber.equal(amountToStake.minus(amountToDeactivate)); - // check that timelocked stake is deactivated - const deactivatedStakeBalance = await stakingWrapper.getDeactivatedStakeAsync(owner); - expect(deactivatedStakeBalance).to.be.bignumber.equal(amountToDeactivate); - // check amount that is timelocked - const timelockedStakeBalance = await stakingWrapper.getTimelockedStakeAsync(owner); - expect(timelockedStakeBalance).to.be.bignumber.equal(amountToDeactivate); - // check that timelocked stake cannot be withdrawn - const withdrawableStakeBalance = await stakingWrapper.getWithdrawableStakeAsync(owner); - expect(withdrawableStakeBalance).to.be.bignumber.equal(0); - // check that timelocked stake cannot be reactivated - const activatableStakeBalance = await stakingWrapper.getActivatableStakeAsync(owner); - expect(activatableStakeBalance).to.be.bignumber.equal(0); - } - /* - ///// 4 SKIP TO NEXT TIMELOCK PERIOD - NOTHING SHOULD HAVE CHANGED ///// - await stakingWrapper.skipToNextTimelockPeriodAsync(); - { - // check total stake balance didn't change - const totalStake = await stakingWrapper.getTotalStakeAsync(owner); - expect(totalStake).to.be.bignumber.equal(amountToStake); - // check timelocked stake is no longer activated - const activatedStakeBalance = await stakingWrapper.getActivatedStakeAsync(owner); - expect(activatedStakeBalance).to.be.bignumber.equal(amountToStake.minus(amountToDeactivate)); - // check that timelocked stake is deactivated - const deactivatedStakeBalance = await stakingWrapper.getDeactivatedStakeAsync(owner); - expect(deactivatedStakeBalance).to.be.bignumber.equal(amountToDeactivate); - // check amount that is timelocked - const timelockedStakeBalance = await stakingWrapper.getTimelockedStakeAsync(owner); - expect(timelockedStakeBalance).to.be.bignumber.equal(amountToDeactivate); - // check that timelocked stake cannot be withdrawn - const withdrawableStakeBalance = await stakingWrapper.getWithdrawableStakeAsync(owner); - expect(withdrawableStakeBalance).to.be.bignumber.equal(0); - // check that timelocked stake cannot be reactivated - const activatableStakeBalance = await stakingWrapper.getActivatableStakeAsync(owner); - expect(activatableStakeBalance).to.be.bignumber.equal(0); - } - ///// 5 SKIP TO NEXT TIMELOCK PEIOD - SHOULD BE ABLE TO REACTIVATE/WITHDRAW TIMELOCKED STAKE ///// - await stakingWrapper.skipToNextTimelockPeriodAsync(); - { - // check total stake balance didn't change - const totalStake = await stakingWrapper.getTotalStakeAsync(owner); - expect(totalStake).to.be.bignumber.equal(amountToStake); - // check timelocked stake is no longer activated - const activatedStakeBalance = await stakingWrapper.getActivatedStakeAsync(owner); - expect(activatedStakeBalance).to.be.bignumber.equal(amountToStake.minus(amountToDeactivate)); - // check that timelocked stake is deactivated - const deactivatedStakeBalance = await stakingWrapper.getDeactivatedStakeAsync(owner); - expect(deactivatedStakeBalance).to.be.bignumber.equal(amountToDeactivate); - // check amount that is timelocked - const timelockedStakeBalance = await stakingWrapper.getTimelockedStakeAsync(owner); - expect(timelockedStakeBalance).to.be.bignumber.equal(0); - // check that timelocked stake cannot be withdrawn - const withdrawableStakeBalance = await stakingWrapper.getWithdrawableStakeAsync(owner); - expect(withdrawableStakeBalance).to.be.bignumber.equal(amountToDeactivate); - // check that timelocked stake cannot be reactivated - const activatableStakeBalance = await stakingWrapper.getActivatableStakeAsync(owner); - expect(activatableStakeBalance).to.be.bignumber.equal(amountToDeactivate); - } - - - - ///// 6 FORCE A SYNC - BALANCES SHOULD NOT CHANGE - await stakingWrapper.forceTimelockSyncAsync(owner); - { - // check total stake balance didn't change - const totalStake = await stakingWrapper.getTotalStakeAsync(owner); - expect(totalStake).to.be.bignumber.equal(amountToStake); - // check timelocked stake is no longer activated - const activatedStakeBalance = await stakingWrapper.getActivatedStakeAsync(owner); - expect(activatedStakeBalance).to.be.bignumber.equal(amountToStake.minus(amountToDeactivate)); - // check that timelocked stake is deactivated - const deactivatedStakeBalance = await stakingWrapper.getDeactivatedStakeAsync(owner); - expect(deactivatedStakeBalance).to.be.bignumber.equal(amountToDeactivate); - // check amount that is timelocked - const timelockedStakeBalance = await stakingWrapper.getTimelockedStakeAsync(owner); - expect(timelockedStakeBalance).to.be.bignumber.equal(0); - // check that timelocked stake cannot be withdrawn - const withdrawableStakeBalance = await stakingWrapper.getWithdrawableStakeAsync(owner); - expect(withdrawableStakeBalance).to.be.bignumber.equal(amountToDeactivate); - // check that timelocked stake cannot be reactivated - const activatableStakeBalance = await stakingWrapper.getActivatableStakeAsync(owner); - expect(activatableStakeBalance).to.be.bignumber.equal(amountToDeactivate); - } - */ - - - ///// 7 REACTIVATE SOME STAKE ///// - - - await stakingWrapper.activateStakeAsync(owner, amountToReactivate); - { - // check total stake balance didn't change - const totalStake = await stakingWrapper.getTotalStakeAsync(owner); - expect(totalStake).to.be.bignumber.equal(amountToStake); - // check timelocked stake is no longer activated - const activatedStakeBalance = await stakingWrapper.getActivatedStakeAsync(owner); - expect(activatedStakeBalance).to.be.bignumber.equal(amountToStake.minus(amountToDeactivate).plus(amountToReactivate)); - // check that timelocked stake is deactivated - const deactivatedStakeBalance = await stakingWrapper.getDeactivatedStakeAsync(owner); - expect(deactivatedStakeBalance).to.be.bignumber.equal(amountToDeactivate.minus(amountToReactivate)); - // check amount that is timelocked - const timelockedStakeBalance = await stakingWrapper.getTimelockedStakeAsync(owner); - expect(timelockedStakeBalance).to.be.bignumber.equal(0); - // check that timelocked stake cannot be withdrawn - const withdrawableStakeBalance = await stakingWrapper.getWithdrawableStakeAsync(owner); - expect(withdrawableStakeBalance).to.be.bignumber.equal(amountToDeactivate.minus(amountToReactivate)); - // check that timelocked stake cannot be reactivated - const activatableStakeBalance = await stakingWrapper.getActivatableStakeAsync(owner); - expect(activatableStakeBalance).to.be.bignumber.equal(amountToDeactivate.minus(amountToReactivate)); - } - ///// 8 WITHDRAW SOME STAKE ///// - await stakingWrapper.withdrawAsync(owner, amountToWithdraw); - { - // check total stake balance didn't change - const totalStake = await stakingWrapper.getTotalStakeAsync(owner); - expect(totalStake).to.be.bignumber.equal(amountToStake.minus(amountToWithdraw)); - // check timelocked stake is no longer activated - const activatedStakeBalance = await stakingWrapper.getActivatedStakeAsync(owner); - expect(activatedStakeBalance).to.be.bignumber.equal(amountToStake.minus(amountToDeactivate).plus(amountToReactivate)); - // check that timelocked stake is deactivated - const deactivatedStakeBalance = await stakingWrapper.getDeactivatedStakeAsync(owner); - expect(deactivatedStakeBalance).to.be.bignumber.equal(amountToDeactivate.minus(amountToReactivate).minus(amountToWithdraw)); - // check amount that is timelocked - const timelockedStakeBalance = await stakingWrapper.getTimelockedStakeAsync(owner); - expect(timelockedStakeBalance).to.be.bignumber.equal(0); - // check that timelocked stake cannot be withdrawn - const withdrawableStakeBalance = await stakingWrapper.getWithdrawableStakeAsync(owner); - expect(withdrawableStakeBalance).to.be.bignumber.equal(amountToDeactivate.minus(amountToReactivate).minus(amountToWithdraw)); - // check that timelocked stake cannot be reactivated - const activatableStakeBalance = await stakingWrapper.getActivatableStakeAsync(owner); - expect(activatableStakeBalance).to.be.bignumber.equal(amountToDeactivate.minus(amountToReactivate).minus(amountToWithdraw)); - // check zrx vault balance - const vaultBalance = await stakingWrapper.getZrxVaultBalance(owner); - expect(vaultBalance).to.be.bignumber.equal(amountToStake.minus(amountToWithdraw)); - // check zrx token balances - const zrxTokenBalanceOfVaultAfterStaking = await stakingWrapper.getZrxTokenBalanceOfZrxVault(); - expect(zrxTokenBalanceOfVaultAfterStaking).to.be.bignumber.equal(amountToStake.minus(amountToWithdraw)); - const zrxTokenBalanceOfStakerAfterStaking = await stakingWrapper.getZrxTokenBalance(owner); - expect(zrxTokenBalanceOfStakerAfterStaking).to.be.bignumber.equal(zrxTokenBalanceOfStakerBeforeStaking.minus(amountToStake).plus(amountToWithdraw)); - } - }); - it('delegating/undelegating', async () => { ///// 1 SETUP TEST PARAMETERS ///// const amountToDelegate = stakingWrapper.toBaseUnitAmount(10);