invalidWithdrawDelegatorRewardsAssertion

This commit is contained in:
Michael Zhu
2020-01-08 10:34:18 -08:00
parent 544e09cf4b
commit c36d0fdc7c
2 changed files with 47 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
import { WETH9Events, WETH9TransferEventArgs } from '@0x/contracts-erc20';
import { loadCurrentBalance, StoredBalance } from '@0x/contracts-staking';
import { loadCurrentBalance, StakingRevertErrors, StoredBalance } from '@0x/contracts-staking';
import { expect, filterLogsToArguments } from '@0x/contracts-test-utils';
import { BigNumber } from '@0x/utils';
import { TxData } from 'ethereum-types';
@@ -73,4 +73,25 @@ export function validWithdrawDelegatorRewardsAssertion(
},
});
}
/**
* Returns a FunctionAssertion for `withdrawDelegatorRewards` which assumes the given pool hasn't
* been finalized for the previous epoch. It checks that the call reverts with a PoolNotFinalizedError.
*/
export function invalidWithdrawDelegatorRewardsAssertion(
deployment: DeploymentManager,
simulationEnvironment: SimulationEnvironment,
): FunctionAssertion<[string], void, void> {
return new FunctionAssertion(deployment.staking.stakingWrapper, 'withdrawDelegatorRewards', {
after: async (_beforeInfo: void, result: FunctionResult, args: [string]) => {
// Ensure that the tx reverted.
expect(result.success).to.be.false();
// Check revert error
const [poolId] = args;
const { currentEpoch } = simulationEnvironment;
expect(result.data).to.equal(new StakingRevertErrors.PoolNotFinalizedError(poolId, currentEpoch.minus(1)));
},
});
}
/* tslint:enable:no-unnecessary-type-assertion */