-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core-state): update vote balance with htlc locked balance on vote…
… transactions (#3669)
- Loading branch information
Showing
4 changed files
with
121 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ import "./accepted"; | |
import "./forged"; | ||
import "./rejected"; | ||
import "./unconfirmed"; | ||
import "./vote-balance"; |
35 changes: 35 additions & 0 deletions
35
packages/core-jest-matchers/src/functional/vote-balance.ts
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,35 @@ | ||
import got from "got"; | ||
|
||
export {}; | ||
|
||
declare global { | ||
namespace jest { | ||
// tslint:disable-next-line:interface-name | ||
interface Matchers<R> { | ||
toHaveVoteBalance(voteBalance: string): Promise<R>; | ||
} | ||
} | ||
} | ||
|
||
expect.extend({ | ||
toHaveVoteBalance: async (publicKey: string, voteBalance: string) => { | ||
let pass: boolean = false; | ||
let fetchedVoteBalance: string; | ||
try { | ||
const { body } = await got.get(`http://localhost:4003/api/v2/delegates/${publicKey}`); | ||
|
||
const parsedBody = JSON.parse(body); | ||
|
||
fetchedVoteBalance = parsedBody.data.votes; | ||
pass = fetchedVoteBalance === voteBalance; | ||
} catch (e) {} // tslint:disable-line | ||
|
||
return { | ||
pass, | ||
message: () => | ||
`expected delegate ${publicKey} ${ | ||
this.isNot ? "not" : "" | ||
} to have vote balance = ${voteBalance}, got ${fetchedVoteBalance}`, | ||
}; | ||
}, | ||
}); |
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