-
Notifications
You must be signed in to change notification settings - Fork 37
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
Add new getBlockHeader rpc #163
Conversation
Deploy preview for jellyfish-defi ready! Built with commit 003e4aa |
size-limit report 📦
|
Codecov Report
@@ Coverage Diff @@
## main #163 +/- ##
=======================================
Coverage 95.47% 95.47%
=======================================
Files 52 52
Lines 1105 1106 +1
Branches 137 137
=======================================
+ Hits 1055 1056 +1
Misses 48 48
Partials 2 2
Continue to review full report at Codecov.
|
interface blockchain { | ||
getBlockHeader (hash: string, verbosity: true): Promise<BlockHeader> | ||
getBlockHeader (hash: string, verbosity: false): Promise<string> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove empty line
|
||
/** | ||
* Get block header data with particular header hash. | ||
* Returns an Object with information about block header. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returns a string that is serialized, hex-encoded data for blockheader.
it('should getBlockHeader with verbosity false and return just a string that is serialized, hex-encoded data for block', async () => { | ||
const blockHash = await waitForBlockHash(1) | ||
const hash: string = await client.blockchain.getBlockHeader(blockHash, false) | ||
expect(hash).not.toBeNull() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert test this is a string.
/** | ||
* Wait for block hash to reach a certain height | ||
*/ | ||
|
||
async function waitForBlockHash (height: number): Promise<string> { | ||
await waitForExpect(async () => { | ||
const info = await client.blockchain.getBlockchainInfo() | ||
expect(info.blocks).toBeGreaterThan(height) | ||
}) | ||
|
||
return await client.blockchain.getBlockHash(height) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seeing that everyone is using this utility for waitForBlockHash
, you should refactor and move it towards the top level and remove all duplicates.
/kind feature
Add new getBlockHeader rpc