-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: don't compare bn with integer (#1704)
- Loading branch information
Showing
3 changed files
with
15 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@fuel-ts/providers": patch | ||
--- | ||
|
||
stop comparing bn with integer in coinQuantityfy helper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
import { BN } from '@fuel-ts/math'; | ||
|
||
import { coinQuantityfy } from './coin-quantity'; | ||
|
||
/** | ||
* @group node | ||
*/ | ||
describe('coinQuantityfy', () => { | ||
it('should returns 1 when input is < 1', () => { | ||
it('amount that is less than 1 is rounded up to 1', () => { | ||
expect(coinQuantityfy([Number.MIN_VALUE]).amount.toNumber()).toEqual(1); | ||
expect(coinQuantityfy([0]).amount.toNumber()).toEqual(1); | ||
expect(coinQuantityfy([0.9]).amount.toNumber()).toEqual(1); | ||
expect(coinQuantityfy([1 - Number.EPSILON]).amount.toNumber()).toEqual(1); | ||
}); | ||
test('amount of return value is set properly', () => { | ||
expect(coinQuantityfy([2]).amount.toNumber()).toEqual(2); | ||
const maxPlusOne = new BN(Number.MAX_SAFE_INTEGER).add(new BN(1)); | ||
expect(coinQuantityfy([maxPlusOne]).amount.toString()).toEqual(maxPlusOne.toString()); | ||
}); | ||
}); |