-
Notifications
You must be signed in to change notification settings - Fork 83
feat: Prepare Additional Conformity Test Scenarios (#3886) #3887
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: main
Are you sure you want to change the base?
feat: Prepare Additional Conformity Test Scenarios (#3886) #3887
Conversation
…se validation (hiero-ledger#3886) Signed-off-by: Michał Walczak <[email protected]>
…h wildcard validation (hiero-ledger#3886) Signed-off-by: Michał Walczak <[email protected]>
…ith wildcard validation (hiero-ledger#3886) Signed-off-by: Michał Walczak <[email protected]>
Signed-off-by: Michał Walczak <[email protected]>
Signed-off-by: Michał Walczak <[email protected]>
…hance flexibility (hiero-ledger#3886) Signed-off-by: Michał Walczak <[email protected]>
…tilities (hiero-ledger#3886) Signed-off-by: Michał Walczak <[email protected]>
…maintainability (hiero-ledger#3886) Signed-off-by: Michał Walczak <[email protected]>
…iero-ledger#3886) Signed-off-by: Michał Walczak <[email protected]>
…nd wildcard validation (hiero-ledger#3886) Signed-off-by: Michał Walczak <[email protected]>
…ion (hiero-ledger#3886) Signed-off-by: Michał Walczak <[email protected]>
…orted method responses (hiero-ledger#3886) Signed-off-by: Michał Walczak <[email protected]>
…sults (hiero-ledger#3886) Signed-off-by: Michał Walczak <[email protected]>
…lob-related fields and improved wildcard handling (hiero-ledger#3886) Signed-off-by: Michał Walczak <[email protected]>
…er handling and added overrides for enhanced modularity (hiero-ledger#3886) Signed-off-by: Michał Walczak <[email protected]>
… expand transaction receipt test overrides (hiero-ledger#3886) Signed-off-by: Michał Walczak <[email protected]>
Signed-off-by: Michał Walczak <[email protected]>
… and modular improvements (hiero-ledger#3886) Signed-off-by: Michał Walczak <[email protected]>
Signed-off-by: Michał Walczak <[email protected]>
…reasons for unsupported EIPs (hiero-ledger#3886) Signed-off-by: Michał Walczak <[email protected]>
…plexTypes` logic for improved object/array handling (hiero-ledger#3886) Signed-off-by: Michał Walczak <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅ @@ Coverage Diff @@
## main #3887 +/- ##
=======================================
Coverage ? 48.12%
=======================================
Files ? 83
Lines ? 4819
Branches ? 989
=======================================
Hits ? 2319
Misses ? 2122
Partials ? 378 🚀 New features to boost your workflow:
|
import { ErrorResponse, JsonRpcResponse, Method, Schema } from './interfaces'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const execApisOpenRpcData = require('../../../../../../../openrpc_exec_apis.json'); |
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.
Seems like this file doesn't exist yet when the CI is ran and it is causing it to fial, perhaps you can load it lazily here?
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.
Fixed: d1d61e1
if (needError) { | ||
return { | ||
jsonrpc: '2.0', | ||
id: request.id, | ||
error: { | ||
code: -32603, | ||
message: error instanceof Error ? error.message : 'An unknown error occurred', | ||
}, | ||
} as JsonRpcResponse; |
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.
Why not return the actual error if such exists? e.g.
if (error.response?.data) {
return error.response.data;
}
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.
Fixed: 3202fac
expect(valid).to.be.true; | ||
if (response.result) { | ||
console.log('Comparing response result with expected result.'); | ||
expect(response.result).to.be.equal(JSON.parse(content.response).result); |
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.
nit: isn't this expect redundant because of the isResponseValid
call from earlier?
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.
Fixed: b2d3aa7
// All other fields must remain unchanged to preserve the integrity of the original test case. | ||
|
||
>> {"jsonrpc":"2.0","id":1,"method":"eth_getTransactionCount","params":["0xc37f417fA09933335240FCA72DD257BFBdE9C275","latest"]} | ||
<< {"jsonrpc":"2.0","id":1,"result":"0x7"} |
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.
Relying on an exact nonce here could make the test fragile in the future, maybe we could use the wildcard here as well and only verify that the response is in a valid nonce format.
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.
Fixed: a31f265
Hi there, thanks for the great work! This PR includes a large number of file changes and added lines, so it would be helpful to expand the description with more context. Specifically: Could you provide a summary of what was changed in the conformityTest.spec file (e.g., what was removed, what was added, and why) I see you created new files and exported functions, but you could just point this out in the description? Also, please clarify why new tests were added—what functionality or edge cases are they covering? It would be helpful to list the new tests briefly so reviewers can quickly understand their scope and purpose. |
return checkObjectProperties(actual as Record<string, unknown>, expected as Record<string, unknown>, wildcards, path); | ||
} | ||
|
||
function checkValues(actual: unknown, expected: unknown, wildcards: string[], path = ''): boolean { |
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.
Maybe a better name for this is areValuesMatching or something like that, wdyt?
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.
Fixed: 2ef979a
return checkObjectProperties(actual as Record<string, unknown>, expected as Record<string, unknown>, wildcards, path); | ||
} | ||
|
||
function checkValues(actual: unknown, expected: unknown, wildcards: string[], path = ''): boolean { |
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.
add JSDoc for this method to better clarify what it does
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.
Fixed: 2ef979a
import { legacyTransaction, transaction1559, transaction1559_2930, transaction2930 } from './transactions'; | ||
import { getTransactionCount } from './utils'; | ||
|
||
export async function updateRequestParams<T = unknown>( |
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.
Add JSDoc
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.
Fixed: db1d6f4
import { checkResponseFormat, findSchema, isResponseValid } from './validations'; | ||
|
||
export function splitReqAndRes(content: 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.
Why is the JSDoc inside the method, I know usually it is outside. May not be wrong, just wondering
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.
Fixed: 213fa2a
const ajv = new Ajv({ strict: false }); | ||
addFormats(ajv); | ||
|
||
export function checkResponseFormat( |
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 method is used here https://github.com/hiero-ledger/hiero-json-rpc-relay/pull/3887/files#diff-91e05f05522a20e9c472bbe550e0d72948fe90f252ff853e9aed3ba95a90f833R63 where it is assigned to a variable 'hasMissingKeys' maybe its better to change the name to something like isFormatValid/hasResponseFormatIssues?
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.
Fixed: df81ef7
|
||
const ajv = new Ajv({ strict: false }); | ||
addFormats(ajv); | ||
|
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.
Add JSDoc for the checkResponseFormat method
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.
Fixed: df81ef7
return false; | ||
} | ||
|
||
function checkComplexTypes(actual: object | null, expected: object, wildcards: string[], path: string): boolean { |
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.
Again maybe the name is slightly misleading, since we return true for non-valid results
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.
Fixed: a19ed69
@@ -23,5 +23,8 @@ | |||
// 6. tx.origin — 0x00 expected and returned; tx sent from 0x0, so origin is also zero. | |||
// 7. msg.value — 0x00 expected and returned; no value was sent with the call, as expected. | |||
// | |||
|
|||
## wildcard: result |
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.
@mwb-al So what exactly is the purpose of the wildcard, to not actually check the values?
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.
As noted in the description, most of these values (especially block.number, block.coinbase, difficulty/prevrandao) vary with each run and chain state. Hence, the wildcard is required to ensure the test remains valid.
…iero-ledger#3886) Signed-off-by: Michał Walczak <[email protected]>
…RPC parameter overrides (hiero-ledger#3886) Signed-off-by: Michał Walczak <[email protected]>
…th detailed parameter and operation descriptions (hiero-ledger#3886) Signed-off-by: Michał Walczak <[email protected]>
…update references with improved JSDoc documentation (hiero-ledger#3886) Signed-off-by: Michał Walczak <[email protected]>
…y, improve JSDoc descriptions (hiero-ledger#3886) Signed-off-by: Michał Walczak <[email protected]>
Signed-off-by: Michał Walczak <[email protected]>
…iero-ledger#3886) Signed-off-by: Michał Walczak <[email protected]>
…ger#3886) Signed-off-by: Michał Walczak <[email protected]>
Signed-off-by: Michał Walczak <[email protected]>
Description:
This PR refactors the conformity test suite (
@conformity-batch-1
) to improve code organization, readability, and maintainability. The main changes include:What Was Removed
What Was Added
utils
directory with modular utility functions:utils.ts
- Core utility functionsconstants.ts
- Test constants and configurationinterfaces.ts
- Type definitions and interfacesoverwrites.ts
- Override handling logicprocessors.ts
- Test data processing functionsvalidations.ts
- Validation utilitiestransactions.ts
- Transaction-related utilitiesWhy These Changes Were Made
overwrites.ts
)Validation Types in Override Files
The
/overwrites
folder contains various types of test validations:eth_blockNumber
eth_blockNumber/simple-test.io
- Simple block number test with wildcard result validationeth_call
eth_call/call-callenv.io
- Contract call with environment variables, wildcard resulteth_call/call-contract.io
- Basic contract call testeth_call/call-revert-abi-error.io
- Contract call with ABI error reverteth_call/call-revert-abi-panic.io
- Contract call with ABI panic reverteth_call/call-callenv-options-eip1559.io
- Contract call with EIP-1559 options, wildcard resulteth_chainId
eth_chainId/get-chain-id.io
- Chain ID retrieval testeth_createAccessList
eth_createAccessList/create-al-contract.io
- Create access list for contract interactioneth_createAccessList/create-al-value-transfer.io
- Create access list for value transfereth_createAccessList/create-al-contract-eip1559.io
- Create access list for contract with EIP-1559eth_estimateGas
eth_estimateGas/estimate-gas-contract.io
- Gas estimation for contract callseth_estimateGas/estimate-gas-value-transfer.io
- Gas estimation for value transferseth_estimateGas/estimate-gas-contract-eip1559.io
- Gas estimation for EIP-1559 contractseth_feeHistory
eth_feeHistory/fee-history.io
- Fee history with wildcards for gas ratios and base feeseth_getBalance
eth_getBalance/get-balance-blockhash.io
- Balance at specific block hasheth_getBalance/get-balance.io
- Standard balance retrievaleth_getBalance/get-balance-unknown-account.io
- Balance for non-existent accounteth_getBlockByHash
eth_getBlockByHash/get-block-by-hash.io
- Block retrieval by hasheth_getBlockByNumber
eth_getBlockByNumber/get-block-n.io
- Block retrieval with multiple wildcard fieldseth_getBlockByNumber/get-finalized.io
- Finalized block with hash and timestamp wildcardseth_getBlockByNumber/get-latest.io
- Latest block with dynamic fieldseth_getBlockByNumber/get-genesis.io
- Genesis block with dynamic fieldseth_getBlockByNumber/get-safe.io
- Safe block with wildcard resulteth_getBlockTransactionCountByNumber
eth_getBlockTransactionCountByNumber/get-genesis.io
- Genesis block transaction count with wildcardeth_getCode
eth_getCode/get-code-contract.io
- Contract code retrievaleth_getCode/get-code-empty.io
- Empty contract code testeth_getLogs
eth_getLogs/no-topics.io
- Log query with invalid address parameter erroreth_getLogs/contract-addr.io
- Log query with invalid topics parameter erroreth_getProof
eth_getProof/get-account-proof-blockhash.io
- Account proof with unsupported method erroreth_getStorageAt
eth_getStorageAt/get-storage.io
- Contract storage retrievaleth_getStorageAt/get-storage-invalid-key.io
- Invalid storage key erroreth_getTransactionByBlockHashAndIndex
eth_getTransactionByBlockHashAndIndex/get-transaction-by-block-hash-and-index.io
- Transaction by block hash and indexeth_getTransactionByBlockNumberAndIndex
eth_getTransactionByBlockNumberAndIndex/get-transaction-by-block-number-and-index.io
- Transaction by block number and indexeth_getTransactionByHash
eth_getTransactionByHash/get-transaction-by-hash.io
- Transaction retrieval by hasheth_getTransactionCount
eth_getTransactionCount/get-nonce.io
- Account nonce retrievaleth_getTransactionReceipt
eth_getTransactionReceipt/get-access-list.io
- Transaction receipt for access list transactionseth_getTransactionReceipt/get-blob-tx.io
- Transaction receipt for blob transactionseth_getTransactionReceipt/get-dynamic-fee.io
- Transaction receipt for dynamic fee transactionseth_getTransactionReceipt/get-legacy-contract.io
- Transaction receipt for legacy contract transactionseth_getTransactionReceipt/get-legacy-input.io
- Transaction receipt for legacy input transactionseth_getTransactionReceipt/get-legacy-receipt.io
- Transaction receipt for legacy receipt transactionseth_sendRawTransaction
eth_sendRawTransaction/send-access-list-transaction.io
- Send access list transactioneth_sendRawTransaction/send-blob-tx.io
- Send blob transactioneth_sendRawTransaction/send-dynamic-fee-access-list-transaction.io
- Send dynamic fee access list transactioneth_sendRawTransaction/send-dynamic-fee-transaction.io
- Send dynamic fee transactioneth_sendRawTransaction/send-legacy-transaction.io
- Send legacy transactionThe list includes all endpoints that required modifications - even if only due to the fact that the transactions from chain.rlp are not replayed before the tests start - in order for them to pass successfully.
Related issue(s):
Fixes #3886
Checklist