address comments
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { StakingRevertErrors, StoredBalance } from '@0x/contracts-staking';
|
||||
import { expect } from '@0x/contracts-test-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { BigNumber, hexUtils } from '@0x/utils';
|
||||
import { TxData } from 'ethereum-types';
|
||||
|
||||
import { DeploymentManager } from '../deployment_manager';
|
||||
@@ -26,10 +26,7 @@ export function validCreateStakingPoolAssertion(
|
||||
before: async () => {
|
||||
const lastPoolId = await stakingWrapper.lastPoolId().callAsync();
|
||||
// Effectively the last poolId + 1, but as a bytestring
|
||||
return `0x${new BigNumber(lastPoolId)
|
||||
.plus(1)
|
||||
.toString(16)
|
||||
.padStart(64, '0')}`;
|
||||
return hexUtils.leftPad(new BigNumber(lastPoolId).plus(1));
|
||||
},
|
||||
after: async (
|
||||
expectedPoolId: string,
|
||||
@@ -73,10 +70,7 @@ export function invalidCreateStakingPoolAssertion(
|
||||
before: async () => {
|
||||
const lastPoolId = await stakingWrapper.lastPoolId().callAsync();
|
||||
// Effectively the last poolId + 1, but as a bytestring
|
||||
return `0x${new BigNumber(lastPoolId)
|
||||
.plus(1)
|
||||
.toString(16)
|
||||
.padStart(64, '0')}`;
|
||||
return hexUtils.leftPad(new BigNumber(lastPoolId).plus(1));
|
||||
},
|
||||
after: async (expectedPoolId: string, result: FunctionResult, args: [number, boolean]) => {
|
||||
// Ensure that the tx reverted.
|
||||
|
@@ -9,7 +9,6 @@ import {
|
||||
StoredBalance,
|
||||
} from '@0x/contracts-staking';
|
||||
import { expect } from '@0x/contracts-test-utils';
|
||||
import { SafeMathRevertErrors } from '@0x/contracts-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { TxData } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
@@ -221,31 +220,4 @@ export function moveStakeNonexistentPoolAssertion(
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a FunctionAssertion for `moveStake` which assumes the input amount exceeds the moveable
|
||||
* amount of stake. Checks that the transaction reverts.
|
||||
*/
|
||||
export function moveStakeInvalidAmountAssertion(
|
||||
deployment: DeploymentManager,
|
||||
): FunctionAssertion<[StakeInfo, StakeInfo, BigNumber], void, void> {
|
||||
return new FunctionAssertion<[StakeInfo, StakeInfo, BigNumber], void, void>(
|
||||
deployment.staking.stakingWrapper,
|
||||
'moveStake',
|
||||
{
|
||||
after: async (_beforeInfo: void, result: FunctionResult) => {
|
||||
// Ensure that the tx reverted.
|
||||
expect(result.success).to.be.false();
|
||||
|
||||
// This isn't ideal but unfortunately there are several different revert errors that
|
||||
// can be triggered by trying to move more stake than possible.
|
||||
expect(
|
||||
result.data instanceof SafeMathRevertErrors.Uint256BinOpError ||
|
||||
result.data instanceof SafeMathRevertErrors.Uint256DowncastError ||
|
||||
result.data instanceof StakingRevertErrors.InsufficientBalanceError,
|
||||
).to.be.true();
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
/* tslint:enable:no-unnecessary-type-assertion */
|
||||
|
Reference in New Issue
Block a user