protocol/contracts/integrations/test/function-assertions/decreaseStakingPoolOperatorShare.ts
2019-11-12 12:05:38 -08:00

28 lines
1.2 KiB
TypeScript

import { expect } from '@0x/contracts-test-utils';
import { logUtils } from '@0x/utils';
import { DeploymentManager } from '../utils/deployment_manager';
import { FunctionAssertion, FunctionResult } from '../utils/function_assertions';
/**
* Returns a FunctionAssertion for `decreaseStakingPoolOperatorShare` which assumes valid input is
* provided. The FunctionAssertion checks that the operator share actually gets updated.
*/
export function validDecreaseStakingPoolOperatorShareAssertion(
deployment: DeploymentManager,
context?: any,
): FunctionAssertion<{}> {
const { stakingWrapper } = deployment.staking;
return new FunctionAssertion<{}>(stakingWrapper.decreaseStakingPoolOperatorShare, {
after: async (_beforeInfo, _result: FunctionResult, poolId: string, expectedOperatorShare: number) => {
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;
}
},
});
}