-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat(jsonrpc): add blockTimestamp to logs and receipts #6671
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,7 @@ public void testTransactionReceipt() throws JsonRpcInternalException { | |
| Protocol.TransactionInfo transactionInfo = Protocol.TransactionInfo.newBuilder() | ||
| .setId(ByteString.copyFrom("1".getBytes())) | ||
| .setContractAddress(ByteString.copyFrom("address1".getBytes())) | ||
| .setBlockTimeStamp(1000000L) | ||
| .setReceipt(Protocol.ResourceReceipt.newBuilder() | ||
| .setEnergyUsageTotal(100L) | ||
| .setResult(Protocol.Transaction.Result.contractResult.DEFAULT) | ||
|
|
@@ -90,6 +91,7 @@ public void testTransactionReceipt() throws JsonRpcInternalException { | |
| Assert.assertEquals(transactionReceipt.getLogs()[0].getBlockNumber(), "0x1"); | ||
| Assert.assertEquals(transactionReceipt.getLogs()[0].getTransactionHash(), "0x31"); | ||
| Assert.assertEquals(transactionReceipt.getLogs()[0].getTransactionIndex(), "0x0"); | ||
| Assert.assertEquals(transactionReceipt.getLogs()[0].getBlockTimestamp(), "0x3e8"); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good to assert the concrete value here. However, this is still a constructor-level unit test, while the feature request is specifically about the public JSON-RPC response shape. Please also add an API-facing assertion in
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. I've added an explicit |
||
|
|
||
| // assert default fields | ||
| Assert.assertNull(transactionReceipt.getRoot()); | ||
|
|
||
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.
This is the right kind of value assertion, but it only verifies the construction helper.
Since the compatibility change is on the external JSON-RPC response model, we should also add endpoint-level coverage for
eth_getLogs,eth_getFilterLogs, and log-typeeth_getFilterChangesto prove that the new field is actually present on the API boundary, not just on the intermediate object.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.
Good point. The existing
getLogs-related tests inJsonrpcServiceTestonly covered error paths (block range exceeded, max topics exceeded) without any positive-path field validation. I've added a newtestGetLogsthat covers the positive path foreth_getLogs, including field-level assertions forblockNumber,blockHash,logIndex,removed,topics,data, andblockTimestamp.As for
eth_getFilterLogsandeth_getFilterChanges, they share the same underlyinggetLogsByLogFilterWrapper()→LogMatch.matchBlock()path witheth_getLogs, differing only in how the filter is sourced.testGetLogsalready covers the shared code path, so no additional tests are needed.