forked from alchemyplatform/aa-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'alchemyplatform:main' into main
- Loading branch information
Showing
29 changed files
with
237 additions
and
114 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
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
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
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
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
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,29 @@ | ||
import { RoundingMode, bigIntMultiply } from "../bigint.js"; | ||
|
||
describe("BigInt utility", () => { | ||
describe("multiplication operations", () => { | ||
it("should multiply a big int correctly with an int", async () => { | ||
expect(bigIntMultiply(10n, 2, RoundingMode.ROUND_UP)).toEqual(20n); | ||
}); | ||
|
||
it("should multiply a big int correctly with a float", async () => { | ||
expect(bigIntMultiply(10n, 0.5, RoundingMode.ROUND_UP)).toEqual(5n); | ||
}); | ||
|
||
it("should fail to multiply a big int and a float with too much precision", async () => { | ||
expect(() => | ||
bigIntMultiply(10n, 0.53958491842948789, RoundingMode.ROUND_UP) | ||
).toThrowError( | ||
"bigIntMultiply requires a multiplier validated number as the second argument" | ||
); | ||
}); | ||
|
||
it("should multiply a big int correctly when rouding up", async () => { | ||
expect(bigIntMultiply(10n, 0.53, RoundingMode.ROUND_UP)).toEqual(6n); | ||
}); | ||
|
||
it("should multiply a big int correctly when rouding down", async () => { | ||
expect(bigIntMultiply(10n, 0.53, RoundingMode.ROUND_DOWN)).toEqual(5n); | ||
}); | ||
}); | ||
}); |
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
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
Oops, something went wrong.