@0x/contracts-staking: Finalizer tests passing.

This commit is contained in:
Lawrence Forman
2019-09-18 18:55:03 -04:00
committed by Lawrence Forman
parent b4b6d4d969
commit d33080cf08
3 changed files with 228 additions and 262 deletions

View File

@@ -90,6 +90,17 @@ export function assertRoughlyEquals(actual: Numberish, expected: Numberish, prec
expect(actual).to.bignumber.eq(expected);
}
/**
* Asserts that two numbers are equal with up to `maxError` difference between them.
*/
export function assertIntegerRoughlyEquals(actual: Numberish, expected: Numberish, maxError: number = 1): void {
const diff = new BigNumber(actual).minus(expected).abs().toNumber();
if (diff <= maxError) {
return;
}
expect(actual).to.bignumber.eq(expected);
}
/**
* Converts `amount` into a base unit amount with 18 digits.
*/