MCPcopy Create free account
hub / github.com/SmarDex-Dev/smart-contracts / assertBigNumberClose

Function assertBigNumberClose

test/helpers/assert.ts:14–32  ·  view source on GitHub ↗
(
  actual: BigNumberish,
  expected: BigNumberish,
  variance: BigNumberish = 10,
  reason: string = "",
)

Source from the content-addressed store, hash-verified

12}
13
14export function assertBigNumberClose(
15 actual: BigNumberish,
16 expected: BigNumberish,
17 variance: BigNumberish = 10,
18 reason: string = "",
19) {
20 const actualBigNumber = BigNumber.from(actual);
21 const expectedBigNumber = BigNumber.from(expected);
22
23 assert.ok(
24 actualBigNumber.gte(expectedBigNumber.sub(variance)),
25 `${reason}: actual is too small to be close with expected with variance ${variance}`,
26 );
27
28 assert.ok(
29 actualBigNumber.lte(expectedBigNumber.add(variance)),
30 `${reason}: actual is too big to be close with expected with variance ${variance}`,
31 );
32}
33
34export function assertBigNumberClosePercent(
35 a: BigNumberish,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected