Skip to content

Commit

Permalink
/blocks & /transactions improvement (#385)
Browse files Browse the repository at this point in the history
* Fixed tx ordering, added block reward and vout total

* Tests passing

* Refactor tests and rename vout

* PR feedback,. simplified db structure, fixed test

* Fix api test

* Correct test

* Fix test

* Apply suggestions from code review

Co-authored-by: Fuxing Loh <[email protected]>
  • Loading branch information
monstrobishi and fuxingloh authored Sep 26, 2021
1 parent c9c6fed commit 432f3c6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions packages/whale-api-client/__tests__/api/blocks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ const ExpectedBlock = {
merkleroot: expect.stringMatching(/[0-f]{64}/),
size: expect.any(Number),
sizeStripped: expect.any(Number),
weight: expect.any(Number)
weight: expect.any(Number),
reward: expect.any(String)
}

describe('list', () => {
Expand Down Expand Up @@ -124,6 +125,7 @@ describe('get', () => {
describe('getTransactions', () => {
const ExpectedTransaction = {
id: expect.stringMatching(/[0-f]{64}/),
order: expect.any(Number),
block: {
hash: expect.stringMatching(/[0-f]{64}/),
height: expect.any(Number),
Expand All @@ -138,7 +140,8 @@ describe('getTransactions', () => {
weight: expect.any(Number),
lockTime: expect.any(Number),
vinCount: expect.any(Number),
voutCount: expect.any(Number)
voutCount: expect.any(Number),
totalVoutValue: expect.any(String)
}

it('should getTransactions through hash', async () => {
Expand Down
4 changes: 3 additions & 1 deletion packages/whale-api-client/__tests__/api/transaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ describe('get', () => {
const transaction = await client.transactions.get(txid)
expect(transaction).toStrictEqual({
id: txid,
order: expect.any(Number),
block: {
hash: expect.any(String),
height: expect.any(Number),
Expand All @@ -83,7 +84,8 @@ describe('get', () => {
weight: expect.any(Number),
lockTime: expect.any(Number),
vinCount: expect.any(Number),
voutCount: expect.any(Number)
voutCount: expect.any(Number),
totalVoutValue: expect.any(String)
})
})

Expand Down
1 change: 1 addition & 0 deletions packages/whale-api-client/src/api/blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export interface Block {
masternode: string
minter: string
minterBlockCount: number
reward: string // ------------| reward string as decimal

stakeModifier: string
merkleroot: string
Expand Down
1 change: 1 addition & 0 deletions packages/whale-api-client/src/api/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export interface Transaction {
lockTime: number
vinCount: number
voutCount: number
totalVoutValue: string
}

/**
Expand Down

0 comments on commit 432f3c6

Please sign in to comment.