diff --git a/docs/openrpc.json b/docs/openrpc.json index 3c784ee11..16463d33c 100644 --- a/docs/openrpc.json +++ b/docs/openrpc.json @@ -57,7 +57,9 @@ "name": "Accounts", "description": "Always returns an empty array", "schema": { - "$ref": "#/components/schemas/addresses" + "title": "empty array", + "type": "array", + "pattern": "^\\[\\s*\\]$" } } }, @@ -577,8 +579,9 @@ "description": "![](https://raw.githubusercontent.com/hashgraph/hedera-json-rpc-relay/main/docs/images/http_label.png)", "params": [], "result": { - "name": "Always returns null. There are no uncles in Hedera.", + "name": "eth_getUncleByBlockHashAndIndex result", "schema": { + "description": "Always returns null. There are no uncles in Hedera.", "$ref": "#/components/schemas/null" } } @@ -589,8 +592,9 @@ "description": "![](https://raw.githubusercontent.com/hashgraph/hedera-json-rpc-relay/main/docs/images/http_label.png)", "params": [], "result": { - "name": "Always returns null. There are no uncles in Hedera.", + "name": "eth_getUncleByBlockNumberAndIndex result", "schema": { + "description": "Always returns null. There are no uncles in Hedera.", "$ref": "#/components/schemas/null" } } @@ -601,8 +605,9 @@ "description": "![](https://raw.githubusercontent.com/hashgraph/hedera-json-rpc-relay/main/docs/images/http_label.png)", "params": [], "result": { - "name": "Always returns '0x0'. There are no uncles in Hedera.", + "name": "eth_getUncleCountByBlockHash result", "schema": { + "description": "Always returns '0x0'. There are no uncles in Hedera.", "title": "hex encoded unsigned integer", "type": "string", "pattern": "0x0" @@ -615,8 +620,9 @@ "description": "![](https://raw.githubusercontent.com/hashgraph/hedera-json-rpc-relay/main/docs/images/http_label.png)", "params": [], "result": { - "name": "Always returns '0x0'. There are no uncles in Hedera.", + "name": "eth_getUncleCountByBlockNumber result", "schema": { + "description": "Always returns '0x0'. There are no uncles in Hedera.", "title": "hex encoded unsigned integer", "type": "string", "pattern": "0x0" @@ -651,8 +657,9 @@ "description": "![](https://raw.githubusercontent.com/hashgraph/hedera-json-rpc-relay/main/docs/images/http_label.png) ![](https://raw.githubusercontent.com/hashgraph/hedera-json-rpc-relay/main/docs/images/ws_label.png)", "params": [], "result": { - "name": "Always returns '0x0'. Hedera doesn't have a concept of tipping nodes to promote any behavior", + "name": "eth_maxPriorityFeePerGas result", "schema": { + "description": "Always returns '0x0'. Hedera doesn't have a concept of tipping nodes to promote any behavior", "title": "hex encoded unsigned integer", "type": "string", "pattern": "0x0" @@ -937,7 +944,7 @@ "name": "The current client version.", "schema": { "type": "string", - "pattern": "relay/[0-9]\\.[0-9]\\.[0-9]" + "pattern": "relay/[0-9]+\\.[0-9]+\\.[0-9]+(-[a-zA-Z0-9-]+)?$" } } }, @@ -988,7 +995,8 @@ "result": { "name": "subscription_id", "schema": { - "type": "string" + "type": "string", + "$ref": "#/components/schemas/hash32" }, "description": "The hex encoded subscription ID used to identify and manage the subscription." } @@ -1015,120 +1023,6 @@ "description": "True if the subscription was successfully cancelled, otherwise false." } }, - { - "name": "eth_newFilter", - "summary": "Creates a filter object for notifying when the state changes (logs).", - "description": "![](https://raw.githubusercontent.com/hashgraph/hedera-json-rpc-relay/main/docs/images/http_label.png) ![](https://raw.githubusercontent.com/hashgraph/hedera-json-rpc-relay/main/docs/images/ws_label.png)", - "params": [ - { - "name": "filter_options", - "required": true, - "schema": { - "type": "object", - "properties": { - "fromBlock": { - "$ref": "#/components/schemas/BlockNumberOrTag" - }, - "toBlock": { - "$ref": "#/components/schemas/BlockNumberOrTag" - }, - "address": { - "type": ["string", "array"], - "items": { - "type": "string" - } - }, - "topics": { - "type": ["array"], - "items": { - "type": ["string", "null"] - } - } - } - }, - "description": "Filter options to specify the exact event(s) logs to get." - } - ], - "result": { - "name": "filter_id", - "schema": { - "type": "string" - }, - "description": "The ID of the newly created filter." - } - }, - { - "name": "eth_uninstallFilter", - "summary": "Uninstalls a filter with given ID. Should always be called when watch is no longer needed.", - "description": "![](https://raw.githubusercontent.com/hashgraph/hedera-json-rpc-relay/main/docs/images/http_label.png)", - "params": [ - { - "name": "filter_id", - "required": true, - "schema": { - "type": "string" - }, - "description": "The ID of the filter to uninstall." - } - ], - "result": { - "name": "uninstalled", - "schema": { - "type": "boolean" - }, - "description": "True if the filter was successfully uninstalled, otherwise false." - } - }, - { - "name": "eth_getFilterChanges", - "summary": "Polling method for a filter, which returns an array of logs which occurred since last poll.", - "description": "![](https://raw.githubusercontent.com/hashgraph/hedera-json-rpc-relay/main/docs/images/http_label.png)", - "params": [ - { - "name": "filter_id", - "required": true, - "schema": { - "type": "string" - }, - "description": "The ID of the filter to check for changes." - } - ], - "result": { - "name": "logs", - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Log" - } - }, - "description": "Array of log objects since last poll." - } - }, - { - "name": "eth_getFilterLogs", - "summary": "Returns an array of all logs matching filter with given ID.", - "description": "![](https://raw.githubusercontent.com/hashgraph/hedera-json-rpc-relay/main/docs/images/http_label.png)", - "params": [ - { - "name": "filter_id", - "required": true, - "schema": { - "type": "string" - }, - "description": "The ID of the filter to retrieve all matching logs." - } - ], - "result": { - "name": "logs", - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Log" - } - }, - "description": "Array of log objects that match the filter." - } - }, { "name": "debug_traceTransaction", "summary": "Attempts to run the transaction in the exact same manner as it was executed on the network.", diff --git a/packages/server/tests/acceptance/conformityTests.spec.ts b/packages/server/tests/acceptance/conformityTests.spec.ts index 7b002fcc0..3fe2e77a8 100644 --- a/packages/server/tests/acceptance/conformityTests.spec.ts +++ b/packages/server/tests/acceptance/conformityTests.spec.ts @@ -31,6 +31,7 @@ import WebSocket from 'ws'; import LogsContract from '../contracts/Logs.json'; import CallerContract from '../contracts/Caller.json'; import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'; +import { parseOpenRPCDocument } from '@open-rpc/schema-utils-js'; const directoryPath = path.resolve(__dirname, '../../../../node_modules/execution-apis/tests'); @@ -65,6 +66,7 @@ const NONEXISTENT_TX_HASH = '0x0000000000000000000000000000000000000000000000000 const ajv = new Ajv({ strict: false }); addFormats(ajv); let execApisOpenRpcData; +let relayOpenRpcData: any; const chainId = Number(ConfigService.get('CHAIN_ID') || 0x12a); @@ -242,11 +244,11 @@ function checkResponseFormat(actualReponse, expectedResponse) { } } -function findSchema(file) { +const findSchema = function (file) { const schema = execApisOpenRpcData.methods.find((method) => method.name === file)?.result?.schema; return schema; -} +}; function isResponseValid(schema, response) { const validate = ajv.compile(schema); @@ -333,54 +335,21 @@ async function processFileContent(directory, file, content) { expect(valid).to.be.true; } -describe('@api-conformity @conformity-batch-1 Ethereum execution apis tests', function () { - this.timeout(240 * 1000); - before(async () => { - legacyTransactionAndBlockHash = await signAndSendRawTransaction(legacyTransaction); - transaction2930AndBlockHash = await signAndSendRawTransaction(transaction2930); - transaction1559AndBlockHash = await signAndSendRawTransaction(transaction1559); - createContractLegacyTransactionAndBlockHash = await signAndSendRawTransaction(createContractLegacyTransaction); - currentBlockHash = await getLatestBlockHash(); - }); - //Reading the directories within the ethereum execution api repo - let directories = fs.readdirSync(directoryPath); - const relaySupportedMethodNames = openRpcData.methods.map((method) => method.name); - - //Filtering in order to use only the tests for methods we support in our relay - directories = directories.filter((directory) => relaySupportedMethodNames.includes(directory)); - for (const directory of directories) { - const filePath = path.join(directoryPath, directory); - if (fs.statSync(filePath).isDirectory()) { - const files = fs.readdirSync(path.resolve(directoryPath, directory)); - for (const file of files) { - it(`Executing for ${directory} and ${file}`, async () => { - //We are excluding these directories, since these tests in execution-apis repos - //use set of contracts which are not deployed on our network - if (directory === 'eth_getLogs' || directory === 'eth_call' || directory === 'eth_estimateGas') { - return; - } - execApisOpenRpcData = require('../../../../openrpc_exec_apis.json'); - //Currently, we do not support blobs - if (file.includes('blob')) { - return; - } - const data = fs.readFileSync(path.resolve(directoryPath, directory, file)); - const content = splitReqAndRes(data.toString('utf-8')); - await processFileContent(directory, file, content); - }); - } - } - } -}); - -const synthesizeTestCases = (testCases, updateParamIfNeeded) => { +const synthesizeTestCases = function (testCases, updateParamIfNeeded) { for (const testName in testCases) { - it(`${testName}`, async () => { + it(`${testName}`, async function () { const isErrorStatusExpected: boolean = !!(testCases[testName]?.status && testCases[testName].status != 200); + const schema = relayOpenRpcData.methods.find((method) => method.name === testName)?.result?.schema; try { const req = updateParamIfNeeded(testName, JSON.parse(testCases[testName].request)); const res = await sendRequestToRelay(req, false); const hasMissingKeys: boolean = checkResponseFormat(res, JSON.parse(testCases[testName].response)); + + if (schema && schema.pattern) { + const check = isResponseValid(schema, res); + expect(check).to.be.true; + } + expect(hasMissingKeys).to.be.false; expect(isErrorStatusExpected).to.be.false; } catch (e: any) { @@ -391,133 +360,91 @@ const synthesizeTestCases = (testCases, updateParamIfNeeded) => { } }; -describe('@api-conformity @conformity-batch-2 Ethereum execution apis tests', async function () { - this.timeout(240 * 1000); - - let existingBlockFilter: string; - let existingContractFilter: string; - +describe('@api-conformity', async function () { before(async () => { - existingBlockFilter = ( - await sendRequestToRelay( - { - jsonrpc: '2.0', - method: 'eth_newBlockFilter', - params: [], - id: 1, - }, - false, - ) - ).result; - - const deployLogsContractTx = await signAndSendRawTransaction({ - chainId, - to: null, - from: sendAccountAddress, - maxPriorityFeePerGas: gasPrice, - maxFeePerGas: gasPrice, - gasLimit: gasLimit, - type: 2, - data: LogsContract.bytecode, - }); - - existingContractFilter = ( - await sendRequestToRelay( - { - jsonrpc: '2.0', - method: 'eth_newFilter', - params: [ - { - fromBlock: '0x1', - toBlock: '0x160c', - address: deployLogsContractTx.contractAddress, - }, - ], - id: 1, - }, - false, - ) - ).result; + relayOpenRpcData = await parseOpenRPCDocument(JSON.stringify(openRpcData)); }); - const TEST_CASES_BATCH_2 = require('./data/conformity-tests-batch-2.json'); - - const updateParamIfNeeded = (testName, request) => { - switch (testName) { - case 'eth_getFilterChanges - existing filter': - request.params = [existingBlockFilter]; - break; - case 'eth_getFilterLogs - existing filter': - request.params = [existingContractFilter]; - break; + describe('@conformity-batch-1 Ethereum execution apis tests', function () { + this.timeout(240 * 1000); + before(async () => { + legacyTransactionAndBlockHash = await signAndSendRawTransaction(legacyTransaction); + transaction2930AndBlockHash = await signAndSendRawTransaction(transaction2930); + transaction1559AndBlockHash = await signAndSendRawTransaction(transaction1559); + createContractLegacyTransactionAndBlockHash = await signAndSendRawTransaction(createContractLegacyTransaction); + currentBlockHash = await getLatestBlockHash(); + }); + //Reading the directories within the ethereum execution api repo + let directories = fs.readdirSync(directoryPath); + const relaySupportedMethodNames = openRpcData.methods.map((method) => method.name); + + //Filtering in order to use only the tests for methods we support in our relay + directories = directories.filter((directory) => relaySupportedMethodNames.includes(directory)); + for (const directory of directories) { + const filePath = path.join(directoryPath, directory); + if (fs.statSync(filePath).isDirectory()) { + const files = fs.readdirSync(path.resolve(directoryPath, directory)); + for (const file of files) { + it(`Executing for ${directory} and ${file}`, async () => { + //We are excluding these directories, since these tests in execution-apis repos + //use set of contracts which are not deployed on our network + if (directory === 'eth_getLogs' || directory === 'eth_call' || directory === 'eth_estimateGas') { + return; + } + execApisOpenRpcData = require('../../../../openrpc_exec_apis.json'); + //Currently, we do not support blobs + if (file.includes('blob')) { + return; + } + const data = fs.readFileSync(path.resolve(directoryPath, directory, file)); + const content = splitReqAndRes(data.toString('utf-8')); + await processFileContent(directory, file, content); + }); + } + } } - - return request; - }; - - synthesizeTestCases(TEST_CASES_BATCH_2, updateParamIfNeeded); -}); - -describe('@api-conformity @conformity-batch-3 Ethereum execution apis tests', async function () { - this.timeout(240 * 1000); - - let txHash; - - before(async () => { - txHash = (await signAndSendRawTransaction(transaction1559)).transactionHash; }); - const TEST_CASES_BATCH_3 = require('./data/conformity-tests-batch-3.json'); + describe('@conformity-batch-2 Ethereum execution apis tests', async function () { + this.timeout(240 * 1000); + + let existingBlockFilter: string; + let existingContractFilter: string; - const updateParamIfNeeded = (testName, request) => { - switch (testName) { - case 'debug_traceTransaction - existing tx': - request.params = [ - txHash, + before(async () => { + existingBlockFilter = ( + await sendRequestToRelay( { - tracer: 'callTracer', - tracerConfig: { - onlyTopCall: true, - }, + jsonrpc: '2.0', + method: 'eth_newBlockFilter', + params: [], + id: 1, }, - ]; - break; - } - - return request; - }; - - synthesizeTestCases(TEST_CASES_BATCH_3['server'], updateParamIfNeeded); - - describe('ws related rpc methods', async function () { - let webSocket: WebSocket; - let contractAddress: string; - let existingFilter: string; + false, + ) + ).result; - before(async () => { - contractAddress = ( - await signAndSendRawTransaction({ - chainId, - to: null, - from: sendAccountAddress, - maxPriorityFeePerGas: gasPrice, - maxFeePerGas: gasPrice, - gasLimit: gasLimit, - type: 2, - data: CallerContract.bytecode, - }) - ).contractAddress; - - existingFilter = ( + const deployLogsContractTx = await signAndSendRawTransaction({ + chainId, + to: null, + from: sendAccountAddress, + maxPriorityFeePerGas: gasPrice, + maxFeePerGas: gasPrice, + gasLimit: gasLimit, + type: 2, + data: LogsContract.bytecode, + }); + + existingContractFilter = ( await sendRequestToRelay( { jsonrpc: '2.0', method: 'eth_newFilter', params: [ { - fromBlock: '0x3', - toBlock: '0x56ac', - address: contractAddress, + fromBlock: '0x1', + toBlock: '0x160c', + address: deployLogsContractTx.contractAddress, }, ], id: 1, @@ -527,260 +454,347 @@ describe('@api-conformity @conformity-batch-3 Ethereum execution apis tests', as ).result; }); - beforeEach(() => { - webSocket = new WebSocket(wsRelayUrl); - }); + const TEST_CASES_BATCH_2 = require('./data/conformity-tests-batch-2.json'); + + const updateParamIfNeeded = (testName, request) => { + switch (testName) { + case 'eth_getFilterChanges - existing filter': + request.params = [existingBlockFilter]; + break; + case 'eth_getFilterLogs - existing filter': + request.params = [existingContractFilter]; + break; + } - afterEach(() => { - webSocket.close(); + return request; + }; + + synthesizeTestCases(TEST_CASES_BATCH_2, updateParamIfNeeded); + }); + + describe('@conformity-batch-3 Ethereum execution apis tests', async function () { + this.timeout(240 * 1000); + + let txHash; + + before(async () => { + txHash = (await signAndSendRawTransaction(transaction1559)).transactionHash; }); + const TEST_CASES_BATCH_3 = require('./data/conformity-tests-batch-3.json'); + const updateParamIfNeeded = (testName, request) => { switch (testName) { - case 'eth_subscribe - existing contract': + case 'debug_traceTransaction - existing tx': request.params = [ - 'logs', + txHash, { - address: contractAddress, + tracer: 'callTracer', + tracerConfig: { + onlyTopCall: true, + }, }, ]; break; - case 'eth_unsubscribe - existing filter': - request.params = [existingFilter]; - break; } return request; }; - const synthesizeWsTestCases = (testCases, updateParamIfNeeded) => { - for (const testName in testCases) { - it(`${testName}`, async () => { - const req = updateParamIfNeeded(testName, JSON.parse(testCases[testName].request)); + synthesizeTestCases(TEST_CASES_BATCH_3['server'], updateParamIfNeeded); - let response: any = {}; - webSocket.on('message', function incoming(data) { - response = JSON.parse(data); - }); - webSocket.on('open', function open() { - webSocket.send(JSON.stringify(req)); - }); - await new Promise((r) => setTimeout(r, 500)); + describe('ws related rpc methods', async function () { + let webSocket: WebSocket; + let contractAddress: string; + let existingFilter: string; - const hasMissingKeys: boolean = checkResponseFormat(response, JSON.parse(testCases[testName].response)); - expect(hasMissingKeys).to.be.false; - }); - } - }; + before(async () => { + contractAddress = ( + await signAndSendRawTransaction({ + chainId, + to: null, + from: sendAccountAddress, + maxPriorityFeePerGas: gasPrice, + maxFeePerGas: gasPrice, + gasLimit: gasLimit, + type: 2, + data: CallerContract.bytecode, + }) + ).contractAddress; + + existingFilter = ( + await sendRequestToRelay( + { + jsonrpc: '2.0', + method: 'eth_newFilter', + params: [ + { + fromBlock: '0x3', + toBlock: '0x56ac', + address: contractAddress, + }, + ], + id: 1, + }, + false, + ) + ).result; + }); + + beforeEach(() => { + webSocket = new WebSocket(wsRelayUrl); + }); + + afterEach(() => { + webSocket.close(); + }); + + const updateParamIfNeeded = (testName, request) => { + switch (testName) { + case 'eth_subscribe - existing contract': + request.params = [ + 'logs', + { + address: contractAddress, + }, + ]; + break; + case 'eth_unsubscribe - existing filter': + request.params = [existingFilter]; + break; + } + + return request; + }; + + const synthesizeWsTestCases = (testCases, updateParamIfNeeded) => { + for (const testName in testCases) { + it(`${testName}`, async () => { + const req = updateParamIfNeeded(testName, JSON.parse(testCases[testName].request)); + + let response: any = {}; + webSocket.on('message', function incoming(data) { + response = JSON.parse(data); + }); + webSocket.on('open', function open() { + webSocket.send(JSON.stringify(req)); + }); + await new Promise((r) => setTimeout(r, 500)); + + const hasMissingKeys: boolean = checkResponseFormat(response, JSON.parse(testCases[testName].response)); + expect(hasMissingKeys).to.be.false; + }); + } + }; - synthesizeWsTestCases(TEST_CASES_BATCH_3['ws-server'], updateParamIfNeeded); + synthesizeWsTestCases(TEST_CASES_BATCH_3['ws-server'], updateParamIfNeeded); + }); }); -}); -describe('@api-conformity @conformity-batch-4 Ethereum execution apis tests', async function () { - this.timeout(240 * 1000); + describe('@conformity-batch-4 Ethereum execution apis tests', async function () { + this.timeout(240 * 1000); - let existingCallerContractAddress: string; - let existingLogsContractAddress: string; - let fromBlockForLogs: string; - - before(async () => { - const deployCallerContractTx = await signAndSendRawTransaction({ - chainId: 0x12a, - to: null, - from: sendAccountAddress, - maxPriorityFeePerGas: gasPrice, - maxFeePerGas: gasPrice, - gasLimit: gasLimit, - type: 2, - data: CallerContract.bytecode, - }); - - const deployLogsContractTx = await signAndSendRawTransaction({ - chainId: 0x12a, - to: null, - from: sendAccountAddress, - maxPriorityFeePerGas: gasPrice, - maxFeePerGas: gasPrice, - gasLimit: gasLimit, - type: 2, - data: LogsContract.bytecode, - }); + let existingCallerContractAddress: string; + let existingLogsContractAddress: string; + let fromBlockForLogs: string; - existingCallerContractAddress = deployCallerContractTx.contractAddress; - existingLogsContractAddress = deployLogsContractTx.contractAddress; - - const log0ContractCall = await signAndSendRawTransaction({ - chainId: 0x12a, - to: existingLogsContractAddress, - from: sendAccountAddress, - maxPriorityFeePerGas: gasPrice, - maxFeePerGas: gasPrice, - gasLimit: gasLimit, - type: 2, - data: '0xd05285d4000000000000000000000000000000000000000000000000000000000000160c', + before(async () => { + const deployCallerContractTx = await signAndSendRawTransaction({ + chainId: 0x12a, + to: null, + from: sendAccountAddress, + maxPriorityFeePerGas: gasPrice, + maxFeePerGas: gasPrice, + gasLimit: gasLimit, + type: 2, + data: CallerContract.bytecode, + }); + + const deployLogsContractTx = await signAndSendRawTransaction({ + chainId: 0x12a, + to: null, + from: sendAccountAddress, + maxPriorityFeePerGas: gasPrice, + maxFeePerGas: gasPrice, + gasLimit: gasLimit, + type: 2, + data: LogsContract.bytecode, + }); + + existingCallerContractAddress = deployCallerContractTx.contractAddress; + existingLogsContractAddress = deployLogsContractTx.contractAddress; + + const log0ContractCall = await signAndSendRawTransaction({ + chainId: 0x12a, + to: existingLogsContractAddress, + from: sendAccountAddress, + maxPriorityFeePerGas: gasPrice, + maxFeePerGas: gasPrice, + gasLimit: gasLimit, + type: 2, + data: '0xd05285d4000000000000000000000000000000000000000000000000000000000000160c', + }); + + fromBlockForLogs = log0ContractCall.blockNumber; }); - fromBlockForLogs = log0ContractCall.blockNumber; - }); - - const TEST_CASES_BATCH_4 = require('./data/conformity-tests-batch-4.json'); - - const updateParamIfNeeded = (testName, request) => { - switch (testName) { - case 'eth_call - existing contract view function and existing from': - request.params = [ - { - from: sendAccountAddress, - to: existingCallerContractAddress, - data: '0x0ec1551d', - }, - 'latest', - ]; - break; - case 'eth_call - existing contract tx and existing from': - request.params = [ - { - from: sendAccountAddress, - to: existingCallerContractAddress, - data: '0xddf363d7', - }, - 'latest', - ]; - break; - case 'eth_call - existing contract tx, existing from and positive value': - request.params = [ - { - from: sendAccountAddress, - to: existingCallerContractAddress, - data: '0xddf363d7', - value: '0x2540be400', - }, - 'latest', - ]; - break; - case 'eth_call - existing contract view function and non-existing from': - request.params = [ - { - from: '0x6b175474e89094c44da98b954eedeac495271d0f', - to: existingCallerContractAddress, - data: '0x0ec1551d', - }, - 'latest', - ]; - break; - case 'eth_call - existing contract tx and non-existing from': - request.params = [ - { - from: '0x6b175474e89094c44da98b954eedeac495271d0f', - to: existingCallerContractAddress, - data: '0xddf363d7', - }, - 'latest', - ]; - break; - case 'eth_call - existing contract tx, non-existing from and positive value': - request.params = [ - { - from: '0x6b175474e89094c44da98b954eedeac495271d0f', - to: existingCallerContractAddress, - data: '0xddf363d7', - value: '0x2540be400', - }, - 'latest', - ]; - break; - case 'eth_estimateGas - existing contract view function and existing from': - request.params = [ - { - from: sendAccountAddress, - to: existingCallerContractAddress, - data: '0x0ec1551d', - }, - 'latest', - ]; - break; - case 'eth_estimateGas - existing contract tx and existing from': - request.params = [ - { - from: sendAccountAddress, - to: existingCallerContractAddress, - data: '0xddf363d7', - }, - 'latest', - ]; - break; - case 'eth_estimateGas - existing contract tx, existing from and positive value': - request.params = [ - { - from: sendAccountAddress, - to: existingCallerContractAddress, - data: '0xddf363d7', - value: '0x2540be400', - }, - 'latest', - ]; - break; - case 'eth_estimateGas - existing contract view function and non-existing from': - request.params = [ - { - from: '0x6b175474e89094c44da98b954eedeac495271d0f', - to: existingCallerContractAddress, - data: '0x0ec1551d', - }, - 'latest', - ]; - break; - case 'eth_estimateGas - existing contract tx and non-existing from': - request.params = [ - { - from: '0x6b175474e89094c44da98b954eedeac495271d0f', - to: existingCallerContractAddress, - data: '0xddf363d7', - }, - 'latest', - ]; - break; - case 'eth_estimateGas - existing contract tx, non-existing from and positive value': - request.params = [ - { - from: '0x6b175474e89094c44da98b954eedeac495271d0f', - to: existingCallerContractAddress, - data: '0xddf363d7', - value: '0x2540be400', - }, - 'latest', - ]; - break; - case 'eth_getLogs - existing contract': - request.params = [ - { - address: existingLogsContractAddress, - }, - ]; - break; - case 'eth_getLogs - existing contract and from/to block': - request.params = [ - { - fromBlock: fromBlockForLogs, - toBlock: 'latest', - address: existingLogsContractAddress, - }, - ]; - break; - } + const TEST_CASES_BATCH_4 = require('./data/conformity-tests-batch-4.json'); - return request; - }; + const updateParamIfNeeded = (testName, request) => { + switch (testName) { + case 'eth_call - existing contract view function and existing from': + request.params = [ + { + from: sendAccountAddress, + to: existingCallerContractAddress, + data: '0x0ec1551d', + }, + 'latest', + ]; + break; + case 'eth_call - existing contract tx and existing from': + request.params = [ + { + from: sendAccountAddress, + to: existingCallerContractAddress, + data: '0xddf363d7', + }, + 'latest', + ]; + break; + case 'eth_call - existing contract tx, existing from and positive value': + request.params = [ + { + from: sendAccountAddress, + to: existingCallerContractAddress, + data: '0xddf363d7', + value: '0x2540be400', + }, + 'latest', + ]; + break; + case 'eth_call - existing contract view function and non-existing from': + request.params = [ + { + from: '0x6b175474e89094c44da98b954eedeac495271d0f', + to: existingCallerContractAddress, + data: '0x0ec1551d', + }, + 'latest', + ]; + break; + case 'eth_call - existing contract tx and non-existing from': + request.params = [ + { + from: '0x6b175474e89094c44da98b954eedeac495271d0f', + to: existingCallerContractAddress, + data: '0xddf363d7', + }, + 'latest', + ]; + break; + case 'eth_call - existing contract tx, non-existing from and positive value': + request.params = [ + { + from: '0x6b175474e89094c44da98b954eedeac495271d0f', + to: existingCallerContractAddress, + data: '0xddf363d7', + value: '0x2540be400', + }, + 'latest', + ]; + break; + case 'eth_estimateGas - existing contract view function and existing from': + request.params = [ + { + from: sendAccountAddress, + to: existingCallerContractAddress, + data: '0x0ec1551d', + }, + 'latest', + ]; + break; + case 'eth_estimateGas - existing contract tx and existing from': + request.params = [ + { + from: sendAccountAddress, + to: existingCallerContractAddress, + data: '0xddf363d7', + }, + 'latest', + ]; + break; + case 'eth_estimateGas - existing contract tx, existing from and positive value': + request.params = [ + { + from: sendAccountAddress, + to: existingCallerContractAddress, + data: '0xddf363d7', + value: '0x2540be400', + }, + 'latest', + ]; + break; + case 'eth_estimateGas - existing contract view function and non-existing from': + request.params = [ + { + from: '0x6b175474e89094c44da98b954eedeac495271d0f', + to: existingCallerContractAddress, + data: '0x0ec1551d', + }, + 'latest', + ]; + break; + case 'eth_estimateGas - existing contract tx and non-existing from': + request.params = [ + { + from: '0x6b175474e89094c44da98b954eedeac495271d0f', + to: existingCallerContractAddress, + data: '0xddf363d7', + }, + 'latest', + ]; + break; + case 'eth_estimateGas - existing contract tx, non-existing from and positive value': + request.params = [ + { + from: '0x6b175474e89094c44da98b954eedeac495271d0f', + to: existingCallerContractAddress, + data: '0xddf363d7', + value: '0x2540be400', + }, + 'latest', + ]; + break; + case 'eth_getLogs - existing contract': + request.params = [ + { + address: existingLogsContractAddress, + }, + ]; + break; + case 'eth_getLogs - existing contract and from/to block': + request.params = [ + { + fromBlock: fromBlockForLogs, + toBlock: 'latest', + address: existingLogsContractAddress, + }, + ]; + break; + } - synthesizeTestCases(TEST_CASES_BATCH_4, updateParamIfNeeded); -}); + return request; + }; -describe('@api-conformity @conformity-batch-5 Ethereum execution apis tests', async function () { - this.timeout(240 * 1000); + synthesizeTestCases(TEST_CASES_BATCH_4, updateParamIfNeeded); + }); - const TEST_CASES_BATCH_5 = require('./data/conformity-tests-batch-5.json'); + describe('@conformity-batch-5 Ethereum execution apis tests', async function () { + this.timeout(240 * 1000); + const TEST_CASES_BATCH_5 = require('./data/conformity-tests-batch-5.json'); - const updateParamIfNeeded = (_testName, request) => request; - synthesizeTestCases(TEST_CASES_BATCH_5, updateParamIfNeeded); + const updateParamIfNeeded = (_testName, request) => request; + synthesizeTestCases(TEST_CASES_BATCH_5, updateParamIfNeeded); + }); }); diff --git a/packages/server/tests/acceptance/data/conformity-tests-batch-2.json b/packages/server/tests/acceptance/data/conformity-tests-batch-2.json index d0ef5c046..604173739 100644 --- a/packages/server/tests/acceptance/data/conformity-tests-batch-2.json +++ b/packages/server/tests/acceptance/data/conformity-tests-batch-2.json @@ -24,6 +24,16 @@ "request": "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"eth_protocolVersion\"}", "response": "{\"jsonrpc\":\"2.0\",\"id\":1,\"error\":{\"code\":-32601}}" }, + "eth_coinbase": { + "status": 400, + "request": "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"eth_coinbase\"}", + "response": "{\"jsonrpc\":\"2.0\",\"id\":1,\"error\":{\"code\":-32601}}" + }, + "eth_getWork": { + "status": 400, + "request": "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"eth_getWork\"}", + "response": "{\"jsonrpc\":\"2.0\",\"id\":1,\"error\":{\"code\":-32601}}" + }, "eth_newPendingTransactionFilter": { "status": 400, "request": "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"eth_newPendingTransactionFilter\"}",