-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(AllbridgeCoreSdkOptions): add partnerId
- Loading branch information
1 parent
e0c8821
commit 59f5c02
Showing
11 changed files
with
149 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { InvalidAmountError } from "../../exceptions"; | ||
import { addPartnerIdToValue, validatePartnerId } from "../../utils/utils"; | ||
|
||
describe("validatePartnerId", () => { | ||
it("should not throw an error if partnerId is not provided", () => { | ||
expect(() => validatePartnerId()).not.toThrow(); | ||
}); | ||
|
||
it("should not throw an error if partnerId is within valid range", () => { | ||
expect(() => validatePartnerId(1)).not.toThrow(); | ||
expect(() => validatePartnerId(65535)).not.toThrow(); | ||
expect(() => validatePartnerId(0xffff)).not.toThrow(); | ||
}); | ||
|
||
it("should throw an error if partnerId is less than 0", () => { | ||
expect(() => validatePartnerId(-1)).toThrow(InvalidAmountError); | ||
expect(() => validatePartnerId(-1)).toThrow("Partner Id must be > 0"); | ||
expect(() => validatePartnerId(0)).toThrow("Partner Id must be > 0"); | ||
}); | ||
|
||
it("should throw an error if partnerId is greater than 65535", () => { | ||
expect(() => validatePartnerId(65536)).toThrow(InvalidAmountError); | ||
expect(() => validatePartnerId(65536)).toThrow("Partner Id must be < 0xffff (65535)"); | ||
expect(() => validatePartnerId(0x10000)).toThrow("Partner Id must be < 0xffff (65535)"); | ||
}); | ||
}); | ||
|
||
describe("addPartnerIdToValue", () => { | ||
describe("no partnerId", () => { | ||
const testCases = [ | ||
{ input: "0", expected: "0x0" }, | ||
{ input: "100", expected: "0x0" }, | ||
{ input: "55000", expected: "0x0" }, | ||
{ input: "75000", expected: "0x10000" }, | ||
{ input: "175000", expected: "0x20000" }, | ||
{ input: "6175000", expected: "0x5e0000" }, | ||
]; | ||
|
||
test.each(testCases)("no partnerId $input", ({ input, expected }) => { | ||
const result = addPartnerIdToValue(input); | ||
expect(result).toEqual(expected); | ||
}); | ||
}); | ||
describe("with partnerId", () => { | ||
const testCases = [ | ||
{ input: "0", expected: "0x1", partnerId: 0x1 }, | ||
{ input: "0", expected: "0x123", partnerId: 0x123 }, | ||
{ input: "0", expected: "0x1234", partnerId: 0x1234 }, | ||
{ input: "0", expected: "0xffff", partnerId: 65535 }, | ||
{ input: "100", expected: "0x1", partnerId: 0x1 }, | ||
{ input: "55000", expected: "0x1", partnerId: 0x1 }, | ||
{ input: "55000", expected: "0x123", partnerId: 0x123 }, | ||
{ input: "55000", expected: "0x1234", partnerId: 0x1234 }, | ||
{ input: "75000", expected: "0x10123", partnerId: 0x123 }, | ||
{ input: "175000", expected: "0x21234", partnerId: 0x1234 }, | ||
{ input: "175000", expected: "0x2ffff", partnerId: 65535 }, | ||
{ input: "6175123", expected: "0x5e0001", partnerId: 0x1 }, | ||
{ input: "6175123", expected: "0x5e0123", partnerId: 0x123 }, | ||
{ input: "6175123", expected: "0x5e1234", partnerId: 0x1234 }, | ||
{ input: "6175123", expected: "0x5effff", partnerId: 65535 }, | ||
]; | ||
|
||
test.each(testCases)("partnerId $partnerId input $input", ({ input, expected, partnerId }) => { | ||
const result = addPartnerIdToValue(input, partnerId); | ||
expect(result).toEqual(expected); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -19,5 +19,5 @@ | |
"allowJs": true, | ||
"strictNullChecks": true, | ||
"noUncheckedIndexedAccess": true | ||
} | ||
}, | ||
} |