Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(jellyfish-api-core): add blockchain getChainTxStats RPC #1051

Merged
merged 5 commits into from
Feb 23, 2022

Conversation

eli-lim
Copy link
Contributor

@eli-lim eli-lim commented Feb 14, 2022

What this PR does / why we need it:

/kind feature

Which issue(s) does this PR fixes?:

Implemented type for RPC: #48

  1. blockchain.getChainTxStats()

@codeclimate
Copy link

codeclimate bot commented Feb 14, 2022

Code Climate has analyzed commit bd21937 and detected 1 issue on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 1

View more on Code Climate.

@codecov
Copy link

codecov bot commented Feb 14, 2022

Codecov Report

Merging #1051 (bd21937) into main (5d99525) will increase coverage by 2.82%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1051      +/-   ##
==========================================
+ Coverage   93.20%   96.02%   +2.82%     
==========================================
  Files         161      168       +7     
  Lines        4913     5009      +96     
  Branches      647      654       +7     
==========================================
+ Hits         4579     4810     +231     
+ Misses        314      192     -122     
+ Partials       20        7      -13     
Impacted Files Coverage Δ
...ages/jellyfish-api-core/src/category/blockchain.ts 100.00% <100.00%> (ø)
packages/jellyfish-address/src/script/P2WSH.ts 72.72% <0.00%> (-22.73%) ⬇️
packages/jellyfish-address/src/script/index.ts 95.91% <0.00%> (-2.05%) ⬇️
apps/legacy-api/src/controllers/TokenController.ts 100.00% <0.00%> (ø)
...legacy-api/src/providers/WhaleApiClientProvider.ts 100.00% <0.00%> (ø)
apps/legacy-api/src/controllers/MiscController.ts 100.00% <0.00%> (ø)
apps/legacy-api/src/modules/RootModule.ts 100.00% <0.00%> (ø)
...s/legacy-api/src/controllers/PoolPairController.ts 100.00% <0.00%> (ø)
apps/legacy-api/src/index.ts 68.18% <0.00%> (ø)
apps/legacy-api/src/modules/ControllerModule.ts 100.00% <0.00%> (ø)
... and 21 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5d99525...bd21937. Read the comment docs.

@eli-lim eli-lim force-pushed the rpc-getchaintxstats branch from d676195 to 721fe09 Compare February 14, 2022 09:16
@chee-chyuan
Copy link
Contributor

we can include another negative test for when the blockNumber exceeds the blockNumber of the blockHash
eg blockhash for block 5: abcde

and we try to getChainTxStats(3, abcde) which will result in an error

- remove redundant type checking
- change to test window_final_block_hash against block hash
Copy link
Contributor

@canonbrother canonbrother left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some failed test to test

getChainTxStats(num, '0') // expect 'blockhash must be of length 64'
getChainTxStats(num, '0',repeat(64)) // expect 'Block not found'

Comment on lines +20 to +26
expect(stats.txcount).toStrictEqual(12)
expect(stats.window_final_block_hash).toStrictEqual(blockHash)
expect(stats.window_final_block_height).toStrictEqual(3)
expect(stats.window_block_count).toStrictEqual(2)
expect(stats.window_tx_count).toStrictEqual(2)
expect(stats.window_interval).toStrictEqual(2)
expect(stats.txrate).toStrictEqual(1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expect(stats).toStrictEqual({
  txcount: 12,
  ...
})

btw this works too and might be cleaner

@fuxingloh fuxingloh merged commit 5dc9348 into main Feb 23, 2022
@fuxingloh fuxingloh deleted the rpc-getchaintxstats branch February 23, 2022 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants