-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e60b35b
commit 895205e
Showing
3 changed files
with
54 additions
and
1 deletion.
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 @@ | ||
--- | ||
"@ledgerhq/coin-polkadot": minor | ||
--- | ||
|
||
Update lockedbalance retrieval polkadot |
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,48 @@ | ||
import BigNumber from "bignumber.js"; | ||
import { getAccount } from "./sidecar"; | ||
|
||
const networkApiMock = jest.fn(); | ||
|
||
describe("getAccount", () => { | ||
it("should estimate lockedBalance correctly with 1 locked balance type", async () => { | ||
const lockedBalanceFn = getAccount(networkApiMock, jest.fn()); | ||
networkApiMock.mockResolvedValue({ | ||
data: { | ||
locks: [ | ||
{ | ||
amount: "60000000000", | ||
reasons: "All", | ||
}, | ||
], | ||
targets: [], | ||
}, | ||
}); | ||
const { lockedBalance } = await lockedBalanceFn("addr"); | ||
expect(lockedBalance).toEqual(new BigNumber("60000000000")); | ||
}); | ||
|
||
it("should estimate lockedBalance when one locked balance is higher than others", async () => { | ||
const lockedBalanceFn = getAccount(networkApiMock, jest.fn()); | ||
networkApiMock.mockResolvedValue({ | ||
data: { | ||
locks: [ | ||
{ | ||
amount: "1", | ||
reasons: "reason 1", | ||
}, | ||
{ | ||
amount: "5", | ||
reasons: "reason 2", | ||
}, | ||
{ | ||
amount: "3", | ||
reasons: "reason 3", | ||
}, | ||
], | ||
targets: [], | ||
}, | ||
}); | ||
const { lockedBalance } = await lockedBalanceFn("addr"); | ||
expect(lockedBalance).toEqual(new BigNumber("5")); | ||
}); | ||
}); |