moveStake assertion; use SimulationEnvironment to track global stake and staking pools

This commit is contained in:
Michael Zhu
2019-11-06 19:03:51 -08:00
parent c2919bcdb0
commit f33a9d162a
13 changed files with 373 additions and 88 deletions

View File

@@ -1,3 +1,4 @@
import { StakingPoolById } from '@0x/contracts-staking';
import { expect } from '@0x/contracts-test-utils';
import { logUtils } from '@0x/utils';
@@ -10,18 +11,17 @@ import { FunctionAssertion, FunctionResult } from '../utils/function_assertions'
*/
export function validDecreaseStakingPoolOperatorShareAssertion(
deployment: DeploymentManager,
context?: any,
pools: StakingPoolById,
): FunctionAssertion<{}> {
const { stakingWrapper } = deployment.staking;
return new FunctionAssertion<{}>(stakingWrapper.decreaseStakingPoolOperatorShare, {
after: async (_beforeInfo, _result: FunctionResult, poolId: string, expectedOperatorShare: number) => {
logUtils.log(`decreaseStakingPoolOperatorShare(${poolId}, ${expectedOperatorShare})`);
const { operatorShare } = await stakingWrapper.getStakingPool.callAsync(poolId);
expect(operatorShare).to.bignumber.equal(expectedOperatorShare);
logUtils.log(`decreaseStakingPoolOperatorShare(${poolId}, ${expectedOperatorShare})`);
if (context !== undefined) {
context.operatorShares[poolId] = operatorShare;
}
pools[poolId].operatorShare = operatorShare;
},
});
}