From 175e42fc47cb6cd2772cccb7ac3ff59fd2d1a4dd Mon Sep 17 00:00:00 2001 From: Qinxuan Chen Date: Mon, 4 Jul 2022 10:59:56 +0800 Subject: [PATCH] Add missing config for ts-tests (#730) * Add BLOCK_TIMESTAMP config for ts-tests Signed-off-by: koushiro * Add NODE_BINARY_NAME Signed-off-by: koushiro * Improve test-balances Signed-off-by: koushiro * Some nits Signed-off-by: koushiro * Add RUNTIME_SPEC_NAME, RUNTIME_SPEC_VERSION, RUNTIME_IMPL_VERSION Signed-off-by: koushiro * Some nits Signed-off-by: koushiro * Use CHAIN_ID Signed-off-by: koushiro * Some nits Signed-off-by: koushiro * Improve test-revert-receipt Signed-off-by: koushiro * Use camelCase Signed-off-by: koushiro * Use tabs Signed-off-by: koushiro --- ts-tests/.prettierrc.js | 1 + ts-tests/tests/config.ts | 9 ++++ ts-tests/tests/test-balance.ts | 22 ++++++--- ts-tests/tests/test-block.ts | 6 +-- ts-tests/tests/test-contract-methods.ts | 6 +-- ts-tests/tests/test-fee-history.ts | 48 +++++++++---------- ts-tests/tests/test-filter-api.ts | 46 +++++++++--------- ts-tests/tests/test-gas.ts | 48 +++++++++---------- ts-tests/tests/test-log-filtering.ts | 14 +++--- .../test-max-priority-fee-per-gas-rpc.ts | 12 ----- ts-tests/tests/test-netapi.ts | 5 +- ts-tests/tests/test-nonce.ts | 2 +- ts-tests/tests/test-pending-pool.ts | 44 ++++++++--------- ts-tests/tests/test-revert-receipt.ts | 35 ++++---------- ts-tests/tests/test-rpc-constants.ts | 5 +- ts-tests/tests/test-subscription.ts | 23 ++++----- ts-tests/tests/test-transaction-version.ts | 30 ++++++------ ts-tests/tests/test-web3api.ts | 9 ++-- ts-tests/tests/util.ts | 4 +- 19 files changed, 181 insertions(+), 188 deletions(-) diff --git a/ts-tests/.prettierrc.js b/ts-tests/.prettierrc.js index 72fd95a720..502c7f7407 100644 --- a/ts-tests/.prettierrc.js +++ b/ts-tests/.prettierrc.js @@ -1,4 +1,5 @@ module.exports = { printWidth: 120, + useTabs: true, tabWidth: 4 } diff --git a/ts-tests/tests/config.ts b/ts-tests/tests/config.ts index 90f396c38f..6b95af6eb0 100644 --- a/ts-tests/tests/config.ts +++ b/ts-tests/tests/config.ts @@ -1,8 +1,17 @@ export const GENESIS_ACCOUNT = "0x6be02d1d3665660d22ff9624b7be0551ee1ac91b"; export const GENESIS_ACCOUNT_PRIVATE_KEY = "0x99B3C12287537E38C90A9219D4CB074A89A16E9CDB20BF85728EBD97C343E342"; +export const GENESIS_ACCOUNT_BALANCE = "340282366920938463463374607431768210955"; export const FIRST_CONTRACT_ADDRESS = "0xc2bf5f29a4384b1ab0c063e1c666f02121b6084a"; +export const NODE_BINARY_NAME = "frontier-template-node"; + +export const RUNTIME_SPEC_NAME = "node-frontier-template"; +export const RUNTIME_SPEC_VERSION = 1; +export const RUNTIME_IMPL_VERSION = 1; + export const CHAIN_ID = 42; +export const BLOCK_TIMESTAMP = 6; // 6 seconds per block export const BLOCK_HASH_COUNT = 256; +export const EXISTENTIAL_DEPOSIT = 500; // The minimum amount required to keep an account open export const BLOCK_GAS_LIMIT = 75000000; diff --git a/ts-tests/tests/test-balance.ts b/ts-tests/tests/test-balance.ts index 4cc80126e5..ac39b9b136 100644 --- a/ts-tests/tests/test-balance.ts +++ b/ts-tests/tests/test-balance.ts @@ -1,11 +1,10 @@ import { expect } from "chai"; import { step } from "mocha-steps"; -import { GENESIS_ACCOUNT, GENESIS_ACCOUNT_PRIVATE_KEY } from "./config"; +import { GENESIS_ACCOUNT, GENESIS_ACCOUNT_PRIVATE_KEY, GENESIS_ACCOUNT_BALANCE, EXISTENTIAL_DEPOSIT } from "./config"; import { createAndFinalizeBlock, describeWithFrontier, customRequest } from "./util"; describeWithFrontier("Frontier RPC (Balance)", (context) => { - const GENESIS_ACCOUNT_BALANCE = "340282366920938463463374607431768210955"; const TEST_ACCOUNT = "0x1111111111111111111111111111111111111111"; step("genesis balance is setup correctly", async function () { @@ -15,23 +14,32 @@ describeWithFrontier("Frontier RPC (Balance)", (context) => { step("balance to be updated after transfer", async function () { this.timeout(15000); + const value = "0x200"; // 512, must be higher than ExistentialDeposit + const gasPrice = "0x3B9ACA00"; // 1000000000 const tx = await context.web3.eth.accounts.signTransaction( { from: GENESIS_ACCOUNT, to: TEST_ACCOUNT, - value: "0x200", // Must be higher than ExistentialDeposit (500) - gasPrice: "0x3B9ACA00", + value: value, + gasPrice: gasPrice, gas: "0x100000", }, GENESIS_ACCOUNT_PRIVATE_KEY ); await customRequest(context.web3, "eth_sendRawTransaction", [tx.rawTransaction]); - const expectedGenesisBalance = "340282366920938463463374586431768210443"; - const expectedTestBalance = "12"; + + // GENESIS_ACCOUNT_BALANCE - (21000 * gasPrice) - value; + const expectedGenesisBalance = ( + BigInt(GENESIS_ACCOUNT_BALANCE) - + BigInt(21000) * BigInt(gasPrice) - + BigInt(value) + ).toString(); + const expectedTestBalance = (Number(value) - EXISTENTIAL_DEPOSIT).toString(); expect(await context.web3.eth.getBalance(GENESIS_ACCOUNT, "pending")).to.equal(expectedGenesisBalance); expect(await context.web3.eth.getBalance(TEST_ACCOUNT, "pending")).to.equal(expectedTestBalance); + await createAndFinalizeBlock(context.web3); - // 340282366920938463463374607431768210955 - (21000 * 1000000000) + 512; + expect(await context.web3.eth.getBalance(GENESIS_ACCOUNT)).to.equal(expectedGenesisBalance); expect(await context.web3.eth.getBalance(TEST_ACCOUNT)).to.equal(expectedTestBalance); }); diff --git a/ts-tests/tests/test-block.ts b/ts-tests/tests/test-block.ts index c89cf686bd..455bb0be21 100644 --- a/ts-tests/tests/test-block.ts +++ b/ts-tests/tests/test-block.ts @@ -1,7 +1,7 @@ import { expect } from "chai"; import { step } from "mocha-steps"; -import { BLOCK_GAS_LIMIT } from "./config"; +import { BLOCK_TIMESTAMP, BLOCK_GAS_LIMIT } from "./config"; import { createAndFinalizeBlock, describeWithFrontier } from "./util"; describeWithFrontier("Frontier RPC (Block)", (context) => { @@ -65,7 +65,7 @@ describeWithFrontier("Frontier RPC (Block)", (context) => { step("should have valid timestamp after block production", async function () { const block = await context.web3.eth.getBlock("latest"); - expect(block.timestamp).to.be.eq(6); + expect(block.timestamp).to.be.eq(BLOCK_TIMESTAMP); }); it("genesis block should be already available by hash", async function () { @@ -110,7 +110,7 @@ describeWithFrontier("Frontier RPC (Block)", (context) => { //parentHash: "0x04540257811b46d103d9896e7807040e7de5080e285841c5430d1a81588a0ce4", receiptsRoot: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", size: 507, - timestamp: 6, + timestamp: BLOCK_TIMESTAMP, totalDifficulty: "0", //transactions: [], transactionsRoot: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", diff --git a/ts-tests/tests/test-contract-methods.ts b/ts-tests/tests/test-contract-methods.ts index 6e3da410af..aecdc2221a 100644 --- a/ts-tests/tests/test-contract-methods.ts +++ b/ts-tests/tests/test-contract-methods.ts @@ -38,9 +38,9 @@ describeWithFrontier("Frontier RPC (Contract Methods)", (context) => { const latestBlock = await context.web3.eth.getBlock("latest"); expect(latestBlock.transactions.length).to.equal(1); - const tx_hash = latestBlock.transactions[0]; - const tx = await context.web3.eth.getTransaction(tx_hash); - expect(tx.hash).to.equal(tx_hash); + const txHash = latestBlock.transactions[0]; + const tx = await context.web3.eth.getTransaction(txHash); + expect(tx.hash).to.equal(txHash); }); it("should return contract method result", async function () { diff --git a/ts-tests/tests/test-fee-history.ts b/ts-tests/tests/test-fee-history.ts index c4f31c0e87..fce8908171 100644 --- a/ts-tests/tests/test-fee-history.ts +++ b/ts-tests/tests/test-fee-history.ts @@ -20,7 +20,7 @@ describeWithFrontier("Frontier RPC (Fee History)", (context) => { let nonce = 0; - function get_percentile(percentile, array) { + function getPercentile(percentile, array) { array.sort(function (a, b) { return a - b; }); @@ -63,46 +63,44 @@ describeWithFrontier("Frontier RPC (Fee History)", (context) => { .catch((err) => expect(err.message).to.equal("Error getting header at BlockId::Number(1)")); }); - step("result lenght should match spec", async function () { + step("result length should match spec", async function () { this.timeout(100000); - let block_count = 2; - let reward_percentiles = [20, 50, 70]; - let priority_fees = [1, 2, 3]; - await createBlocks(block_count, priority_fees); - let result = (await customRequest(context.web3, "eth_feeHistory", ["0x2", "latest", reward_percentiles])) - .result; + let blockCount = 2; + let rewardPercentiles = [20, 50, 70]; + let priorityFees = [1, 2, 3]; + await createBlocks(blockCount, priorityFees); + let result = (await customRequest(context.web3, "eth_feeHistory", ["0x2", "latest", rewardPercentiles])).result; // baseFeePerGas is always the requested block range + 1 (the next derived base fee). - expect(result.baseFeePerGas.length).to.be.eq(block_count + 1); + expect(result.baseFeePerGas.length).to.be.eq(blockCount + 1); // gasUsedRatio for the requested block range. - expect(result.gasUsedRatio.length).to.be.eq(block_count); + expect(result.gasUsedRatio.length).to.be.eq(blockCount); // two-dimensional reward list for the requested block range. - expect(result.reward.length).to.be.eq(block_count); + expect(result.reward.length).to.be.eq(blockCount); // each block has a reward list which's size is the requested percentile list. - for (let i = 0; i < block_count; i++) { - expect(result.reward[i].length).to.be.eq(reward_percentiles.length); + for (let i = 0; i < blockCount; i++) { + expect(result.reward[i].length).to.be.eq(rewardPercentiles.length); } }); step("should calculate percentiles", async function () { this.timeout(100000); - let block_count = 11; - let reward_percentiles = [20, 50, 70, 85, 100]; - let priority_fees = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; - await createBlocks(block_count, priority_fees); - let result = (await customRequest(context.web3, "eth_feeHistory", ["0xA", "latest", reward_percentiles])) - .result; + let blockCount = 11; + let rewardPercentiles = [20, 50, 70, 85, 100]; + let priorityFees = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + await createBlocks(blockCount, priorityFees); + let result = (await customRequest(context.web3, "eth_feeHistory", ["0xA", "latest", rewardPercentiles])).result; // Calculate the percentiles in javascript. - let local_rewards = []; - for (let i = 0; i < reward_percentiles.length; i++) { - local_rewards.push(get_percentile(reward_percentiles[i], priority_fees)); + let localRewards = []; + for (let i = 0; i < rewardPercentiles.length; i++) { + localRewards.push(getPercentile(rewardPercentiles[i], priorityFees)); } // Compare the rpc result with the javascript percentiles. for (let i = 0; i < result.reward.length; i++) { - expect(result.reward[i].length).to.be.eq(local_rewards.length); - for (let j = 0; j < local_rewards.length; j++) { - expect(context.web3.utils.hexToNumber(result.reward[i][j])).to.be.eq(local_rewards[j]); + expect(result.reward[i].length).to.be.eq(localRewards.length); + for (let j = 0; j < localRewards.length; j++) { + expect(context.web3.utils.hexToNumber(result.reward[i][j])).to.be.eq(localRewards[j]); } } }); diff --git a/ts-tests/tests/test-filter-api.ts b/ts-tests/tests/test-filter-api.ts index 9a4f57bb7a..f321a83621 100644 --- a/ts-tests/tests/test-filter-api.ts +++ b/ts-tests/tests/test-filter-api.ts @@ -25,7 +25,7 @@ describeWithFrontier("Frontier RPC (EthFilterApi)", (context) => { } step("should create a Log filter and return the ID", async function () { - let create_filter = await customRequest(context.web3, "eth_newFilter", [ + let createFilter = await customRequest(context.web3, "eth_newFilter", [ { fromBlock: "0x0", toBlock: "latest", @@ -33,11 +33,11 @@ describeWithFrontier("Frontier RPC (EthFilterApi)", (context) => { topics: ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"], }, ]); - expect(create_filter.result).to.be.eq("0x1"); + expect(createFilter.result).to.be.eq("0x1"); }); step("should increment filter ID", async function () { - let create_filter = await customRequest(context.web3, "eth_newFilter", [ + let createFilter = await customRequest(context.web3, "eth_newFilter", [ { fromBlock: "0x1", toBlock: "0x2", @@ -45,12 +45,12 @@ describeWithFrontier("Frontier RPC (EthFilterApi)", (context) => { topics: ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"], }, ]); - expect(create_filter.result).to.be.eq("0x2"); + expect(createFilter.result).to.be.eq("0x2"); }); step("should create a Block filter and return the ID", async function () { - let create_filter = await customRequest(context.web3, "eth_newBlockFilter", []); - expect(create_filter.result).to.be.eq("0x3"); + let createFilter = await customRequest(context.web3, "eth_newBlockFilter", []); + expect(createFilter.result).to.be.eq("0x3"); }); step("should return unsupported error for Pending Transaction filter creation", async function () { @@ -96,7 +96,7 @@ describeWithFrontier("Frontier RPC (EthFilterApi)", (context) => { expect(receipt.logs.length).to.be.eq(1); // Create a filter for the created contract. - let create_filter = await customRequest(context.web3, "eth_newFilter", [ + let createFilter = await customRequest(context.web3, "eth_newFilter", [ { fromBlock: "0x0", toBlock: "latest", @@ -104,14 +104,14 @@ describeWithFrontier("Frontier RPC (EthFilterApi)", (context) => { topics: receipt.logs[0].topics, }, ]); - let poll = await customRequest(context.web3, "eth_getFilterChanges", [create_filter.result]); + let poll = await customRequest(context.web3, "eth_getFilterChanges", [createFilter.result]); expect(poll.result.length).to.be.eq(1); expect(poll.result[0].address.toLowerCase()).to.be.eq(receipt.contractAddress.toLowerCase()); expect(poll.result[0].topics).to.be.deep.eq(receipt.logs[0].topics); // A subsequent request must be empty. - poll = await customRequest(context.web3, "eth_getFilterChanges", [create_filter.result]); + poll = await customRequest(context.web3, "eth_getFilterChanges", [createFilter.result]); expect(poll.result.length).to.be.eq(0); }); @@ -124,7 +124,7 @@ describeWithFrontier("Frontier RPC (EthFilterApi)", (context) => { expect(receipt.logs.length).to.be.eq(1); // Create a filter for the created contract. - let create_filter = await customRequest(context.web3, "eth_newFilter", [ + let createFilter = await customRequest(context.web3, "eth_newFilter", [ { fromBlock: "0x0", toBlock: "latest", @@ -132,14 +132,14 @@ describeWithFrontier("Frontier RPC (EthFilterApi)", (context) => { topics: receipt.logs[0].topics, }, ]); - let poll = await customRequest(context.web3, "eth_getFilterLogs", [create_filter.result]); + let poll = await customRequest(context.web3, "eth_getFilterLogs", [createFilter.result]); expect(poll.result.length).to.be.eq(1); expect(poll.result[0].address.toLowerCase()).to.be.eq(receipt.contractAddress.toLowerCase()); expect(poll.result[0].topics).to.be.deep.eq(receipt.logs[0].topics); // A subsequent request must return the same response. - poll = await customRequest(context.web3, "eth_getFilterLogs", [create_filter.result]); + poll = await customRequest(context.web3, "eth_getFilterLogs", [createFilter.result]); expect(poll.result.length).to.be.eq(1); expect(poll.result[0].address.toLowerCase()).to.be.eq(receipt.contractAddress.toLowerCase()); @@ -147,15 +147,15 @@ describeWithFrontier("Frontier RPC (EthFilterApi)", (context) => { }); step("should uninstall created filters.", async function () { - let create_filter = await customRequest(context.web3, "eth_newBlockFilter", []); - let filter_id = create_filter.result; + let createFilter = await customRequest(context.web3, "eth_newBlockFilter", []); + let filterId = createFilter.result; // Should return true when removed from the filter pool. - let uninstall = await customRequest(context.web3, "eth_uninstallFilter", [filter_id]); + let uninstall = await customRequest(context.web3, "eth_uninstallFilter", [filterId]); expect(uninstall.result).to.be.eq(true); // Should return error if does not exist. - let r = await customRequest(context.web3, "eth_uninstallFilter", [filter_id]); + let r = await customRequest(context.web3, "eth_uninstallFilter", [filterId]); expect(r.error).to.include({ message: "Filter id 6 does not exist.", }); @@ -163,25 +163,25 @@ describeWithFrontier("Frontier RPC (EthFilterApi)", (context) => { step("should drain the filter pool.", async function () { this.timeout(15000); - const block_lifespan_threshold = 100; + const blockLifespanThreshold = 100; - let create_filter = await customRequest(context.web3, "eth_newBlockFilter", []); - let filter_id = create_filter.result; + let createFilter = await customRequest(context.web3, "eth_newBlockFilter", []); + let filterId = createFilter.result; - for (let i = 0; i <= block_lifespan_threshold; i++) { + for (let i = 0; i <= blockLifespanThreshold; i++) { await createAndFinalizeBlockNowait(context.web3); } - let r = await customRequest(context.web3, "eth_getFilterChanges", [filter_id]); + let r = await customRequest(context.web3, "eth_getFilterChanges", [filterId]); expect(r.error).to.include({ message: "Filter id 6 does not exist.", }); }); step("should have a filter pool max size of 500.", async function () { - const max_filter_pool = 500; + const maxFilterPool = 500; - for (let i = 0; i < max_filter_pool; i++) { + for (let i = 0; i < maxFilterPool; i++) { await customRequest(context.web3, "eth_newBlockFilter", []); } diff --git a/ts-tests/tests/test-gas.ts b/ts-tests/tests/test-gas.ts index ecccd51a5b..a7d52a4e19 100644 --- a/ts-tests/tests/test-gas.ts +++ b/ts-tests/tests/test-gas.ts @@ -9,18 +9,18 @@ import { describeWithFrontier, createAndFinalizeBlock, customRequest } from "./u // If the variation in the estimate is less than 10%, // then the estimate is considered sufficiently accurate. const ESTIMATION_VARIANCE = 10; -function binary_search(one_off_estimation) { +function binarySearch(oneOffEstimation) { let highest = 4_294_967_295; // max(u32) let lowest = 21000; - let mid = Math.min(one_off_estimation * 3, (highest + lowest) / 2); - let previous_highest = highest; + let mid = Math.min(oneOffEstimation * 3, (highest + lowest) / 2); + let previousHighest = highest; while (true) { - if (mid >= one_off_estimation) { + if (mid >= oneOffEstimation) { highest = mid; - if (((previous_highest - highest) * ESTIMATION_VARIANCE) / previous_highest < 1) { + if (((previousHighest - highest) * ESTIMATION_VARIANCE) / previousHighest < 1) { break; } - previous_highest = highest; + previousHighest = highest; } else { lowest = mid; } @@ -29,8 +29,8 @@ function binary_search(one_off_estimation) { return highest; } -function estimation_variance(binary_search_estimation, one_off_estimation) { - return ((binary_search_estimation - one_off_estimation) * ESTIMATION_VARIANCE) / binary_search_estimation; +function estimationVariance(binarySearchEstimation, oneOffEstimation) { + return ((binarySearchEstimation - oneOffEstimation) * ESTIMATION_VARIANCE) / binarySearchEstimation; } describeWithFrontier("Frontier RPC (Gas)", (context) => { @@ -44,16 +44,16 @@ describeWithFrontier("Frontier RPC (Gas)", (context) => { it("eth_estimateGas for contract creation", async function () { // The value returned as an estimation by the evm with estimate mode ON. - let one_off_estimation = 196657; - let binary_search_estimation = binary_search(one_off_estimation); + let oneOffEstimation = 196657; + let binarySearchEstimation = binarySearch(oneOffEstimation); // Sanity check expect a variance of 10%. - expect(estimation_variance(binary_search_estimation, one_off_estimation)).to.be.lessThan(1); + expect(estimationVariance(binarySearchEstimation, oneOffEstimation)).to.be.lessThan(1); expect( await context.web3.eth.estimateGas({ from: GENESIS_ACCOUNT, data: Test.bytecode, }) - ).to.equal(binary_search_estimation); + ).to.equal(binarySearchEstimation); }); it.skip("block gas limit over 5M", async function () { @@ -79,38 +79,38 @@ describeWithFrontier("Frontier RPC (Gas)", (context) => { it("eth_estimateGas for contract call", async function () { // The value returned as an estimation by the evm with estimate mode ON. - let one_off_estimation = 21204; - let binary_search_estimation = binary_search(one_off_estimation); + let oneOffEstimation = 21204; + let binarySearchEstimation = binarySearch(oneOffEstimation); // Sanity check expect a variance of 10%. - expect(estimation_variance(binary_search_estimation, one_off_estimation)).to.be.lessThan(1); + expect(estimationVariance(binarySearchEstimation, oneOffEstimation)).to.be.lessThan(1); const contract = new context.web3.eth.Contract(TEST_CONTRACT_ABI, FIRST_CONTRACT_ADDRESS, { from: GENESIS_ACCOUNT, gasPrice: "0x3B9ACA00", }); - expect(await contract.methods.multiply(3).estimateGas()).to.equal(binary_search_estimation); + expect(await contract.methods.multiply(3).estimateGas()).to.equal(binarySearchEstimation); }); it("eth_estimateGas without gas_limit should pass", async function () { // The value returned as an estimation by the evm with estimate mode ON. - let one_off_estimation = 21204; - let binary_search_estimation = binary_search(one_off_estimation); + let oneOffEstimation = 21204; + let binarySearchEstimation = binarySearch(oneOffEstimation); // Sanity check expect a variance of 10%. - expect(estimation_variance(binary_search_estimation, one_off_estimation)).to.be.lessThan(1); + expect(estimationVariance(binarySearchEstimation, oneOffEstimation)).to.be.lessThan(1); const contract = new context.web3.eth.Contract(TEST_CONTRACT_ABI, FIRST_CONTRACT_ADDRESS, { from: GENESIS_ACCOUNT, }); - expect(await contract.methods.multiply(3).estimateGas()).to.equal(binary_search_estimation); + expect(await contract.methods.multiply(3).estimateGas()).to.equal(binarySearchEstimation); }); it("eth_estimateGas should handle AccessList alias", async function () { // The value returned as an estimation by the evm with estimate mode ON. // 4300 == 1900 for one key and 2400 for one storage. - let one_off_estimation = 196657 + 4300; - let binary_search_estimation = binary_search(one_off_estimation); + let oneOffEstimation = 196657 + 4300; + let binarySearchEstimation = binarySearch(oneOffEstimation); // Sanity check expect a variance of 10%. - expect(estimation_variance(binary_search_estimation, one_off_estimation)).to.be.lessThan(1); + expect(estimationVariance(binarySearchEstimation, oneOffEstimation)).to.be.lessThan(1); let result = ( await customRequest(context.web3, "eth_estimateGas", [ { @@ -125,7 +125,7 @@ describeWithFrontier("Frontier RPC (Gas)", (context) => { }, ]) ).result; - expect(result).to.equal(context.web3.utils.numberToHex(binary_search_estimation)); + expect(result).to.equal(context.web3.utils.numberToHex(binarySearchEstimation)); }); it("eth_estimateGas 0x0 gasPrice is equivalent to not setting one", async function () { diff --git a/ts-tests/tests/test-log-filtering.ts b/ts-tests/tests/test-log-filtering.ts index 545c1ccb46..d44c2beab4 100644 --- a/ts-tests/tests/test-log-filtering.ts +++ b/ts-tests/tests/test-log-filtering.ts @@ -61,12 +61,12 @@ describeWithFrontier("Frontier RPC (Log filtering)", (context) => { await createAndFinalizeBlock(context.web3); let receipt = await context.web3.eth.getTransactionReceipt(tx.transactionHash); - const non_matching_cases = getNonMatchingCases(receipt); + const nonMatchingCases = getNonMatchingCases(receipt); - let create_filter; - for (var item of non_matching_cases) { - create_filter = await customRequest(context.web3, "eth_newFilter", [item]); - let poll = await customRequest(context.web3, "eth_getFilterLogs", [create_filter.result]); + let createFilter; + for (var item of nonMatchingCases) { + createFilter = await customRequest(context.web3, "eth_newFilter", [item]); + let poll = await customRequest(context.web3, "eth_getFilterLogs", [createFilter.result]); expect(poll.result.length).to.be.eq(0); } }); @@ -76,9 +76,9 @@ describeWithFrontier("Frontier RPC (Log filtering)", (context) => { await createAndFinalizeBlock(context.web3); let receipt = await context.web3.eth.getTransactionReceipt(tx.transactionHash); - const non_matching_cases = getNonMatchingCases(receipt); + const nonMatchingCases = getNonMatchingCases(receipt); - for (var item of non_matching_cases) { + for (var item of nonMatchingCases) { let request = await customRequest(context.web3, "eth_getLogs", [item]); expect(request.result.length).to.be.eq(0); } diff --git a/ts-tests/tests/test-max-priority-fee-per-gas-rpc.ts b/ts-tests/tests/test-max-priority-fee-per-gas-rpc.ts index 3d02dd1d00..8a181ef8f2 100644 --- a/ts-tests/tests/test-max-priority-fee-per-gas-rpc.ts +++ b/ts-tests/tests/test-max-priority-fee-per-gas-rpc.ts @@ -17,18 +17,6 @@ describeWithFrontier("Frontier RPC (Max Priority Fee Per Gas)", (context) => { let nonce = 0; - function get_percentile(percentile, array) { - array.sort(function (a, b) { - return a - b; - }); - let index = (percentile / 100) * array.length - 1; - if (Math.floor(index) == index) { - return array[index]; - } else { - return Math.ceil((array[Math.floor(index)] + array[Math.ceil(index)]) / 2); - } - } - async function createBlocks(block_count, priority_fees) { for (var b = 0; b < block_count; b++) { for (var p = 0; p < priority_fees.length; p++) { diff --git a/ts-tests/tests/test-netapi.ts b/ts-tests/tests/test-netapi.ts index e019cfa2fe..98c4c1e110 100644 --- a/ts-tests/tests/test-netapi.ts +++ b/ts-tests/tests/test-netapi.ts @@ -1,11 +1,12 @@ import { expect } from "chai"; import { step } from "mocha-steps"; +import { CHAIN_ID } from "./config"; import { describeWithFrontier, customRequest } from "./util"; describeWithFrontier("Frontier RPC (Net)", (context) => { - step("should return `net_version` 42", async function () { - expect(await context.web3.eth.net.getId()).to.equal(42); + step("should return `net_version`", async function () { + expect(await context.web3.eth.net.getId()).to.equal(CHAIN_ID); }); step("should return `peer_count` in hex directly using the provider", async function () { expect((await customRequest(context.web3, "net_peerCount", [])).result).to.be.eq("0x0"); diff --git a/ts-tests/tests/test-nonce.ts b/ts-tests/tests/test-nonce.ts index d278f2d398..7d3b5c9ab9 100644 --- a/ts-tests/tests/test-nonce.ts +++ b/ts-tests/tests/test-nonce.ts @@ -13,7 +13,7 @@ describeWithFrontier("Frontier RPC (Nonce)", (context) => { { from: GENESIS_ACCOUNT, to: TEST_ACCOUNT, - value: "0x200", // Must be higher than ExistentialDeposit (500) + value: "0x200", // Must be higher than ExistentialDeposit gasPrice: "0x3B9ACA00", gas: "0x100000", }, diff --git a/ts-tests/tests/test-pending-pool.ts b/ts-tests/tests/test-pending-pool.ts index 4611e76573..809ad0aa9b 100644 --- a/ts-tests/tests/test-pending-pool.ts +++ b/ts-tests/tests/test-pending-pool.ts @@ -21,13 +21,13 @@ describeWithFrontier("Frontier RPC (Pending Pool)", (context) => { GENESIS_ACCOUNT_PRIVATE_KEY ); - const tx_hash = (await customRequest(context.web3, "eth_sendRawTransaction", [tx.rawTransaction])).result; + const txHash = (await customRequest(context.web3, "eth_sendRawTransaction", [tx.rawTransaction])).result; - const pending_transaction = (await customRequest(context.web3, "eth_getTransactionByHash", [tx_hash])).result; + const pendingTransaction = (await customRequest(context.web3, "eth_getTransactionByHash", [txHash])).result; // pending transactions do not know yet to which block they belong to - expect(pending_transaction).to.include({ + expect(pendingTransaction).to.include({ blockNumber: null, - hash: tx_hash, + hash: txHash, publicKey: "0x624f720eae676a04111631c9ca338c11d0f5a80ee42210c6be72983ceb620fbf645a96f951529fa2d70750432d11b7caba5270c4d677255be90b3871c8c58069", r: "0x8e3759de96b00f8a05a95c24fa905963f86a82a0038cca0fde035762fb2d24f7", @@ -37,9 +37,9 @@ describeWithFrontier("Frontier RPC (Pending Pool)", (context) => { await createAndFinalizeBlock(context.web3); - const processed_transaction = (await customRequest(context.web3, "eth_getTransactionByHash", [tx_hash])).result; - expect(processed_transaction).to.include({ - hash: tx_hash, + const processedTransaction = (await customRequest(context.web3, "eth_getTransactionByHash", [txHash])).result; + expect(processedTransaction).to.include({ + hash: txHash, publicKey: "0x624f720eae676a04111631c9ca338c11d0f5a80ee42210c6be72983ceb620fbf645a96f951529fa2d70750432d11b7caba5270c4d677255be90b3871c8c58069", r: "0x8e3759de96b00f8a05a95c24fa905963f86a82a0038cca0fde035762fb2d24f7", @@ -64,7 +64,7 @@ describeWithFrontier("Frontier RPC (Pending Transaction Count)", (context) => { { from: GENESIS_ACCOUNT, to: TEST_ACCOUNT, - value: "0x200", // Must be higher than ExistentialDeposit (500) + value: "0x200", // Must be higher than ExistentialDeposit gasPrice: "0x3B9ACA00", gas: "0x100000", nonce: nonce, @@ -76,32 +76,32 @@ describeWithFrontier("Frontier RPC (Pending Transaction Count)", (context) => { }; { - const pending_transaction_count = ( + const pendingTransactionCount = ( await customRequest(context.web3, "eth_getBlockTransactionCountByNumber", ["pending"]) ).result; - expect(pending_transaction_count).to.eq("0x0"); + expect(pendingTransactionCount).to.eq("0x0"); } // block 1 should have 1 transaction await sendTransaction(); { - const pending_transaction_count = ( + const pendingTransactionCount = ( await customRequest(context.web3, "eth_getBlockTransactionCountByNumber", ["pending"]) ).result; - expect(pending_transaction_count).to.eq("0x1"); + expect(pendingTransactionCount).to.eq("0x1"); } await createAndFinalizeBlock(context.web3); { - const pending_transaction_count = ( + const pendingTransactionCount = ( await customRequest(context.web3, "eth_getBlockTransactionCountByNumber", ["pending"]) ).result; - expect(pending_transaction_count).to.eq("0x0"); - const processed_transaction_count = ( + expect(pendingTransactionCount).to.eq("0x0"); + const processedTransactionCount = ( await customRequest(context.web3, "eth_getBlockTransactionCountByNumber", [1]) ).result; - expect(processed_transaction_count).to.eq("0x1"); + expect(processedTransactionCount).to.eq("0x1"); } // block 2 should have 5 transactions @@ -110,23 +110,23 @@ describeWithFrontier("Frontier RPC (Pending Transaction Count)", (context) => { } { - const pending_transaction_count = ( + const pendingTransactionCount = ( await customRequest(context.web3, "eth_getBlockTransactionCountByNumber", ["pending"]) ).result; - expect(pending_transaction_count).to.eq("0x5"); + expect(pendingTransactionCount).to.eq("0x5"); } await createAndFinalizeBlock(context.web3); { - const pending_transaction_count = ( + const pendingTransactionCount = ( await customRequest(context.web3, "eth_getBlockTransactionCountByNumber", ["pending"]) ).result; - expect(pending_transaction_count).to.eq("0x0"); - const processed_transaction_count = ( + expect(pendingTransactionCount).to.eq("0x0"); + const processedTransactionCount = ( await customRequest(context.web3, "eth_getBlockTransactionCountByNumber", [2]) ).result; - expect(processed_transaction_count).to.eq("0x5"); + expect(processedTransactionCount).to.eq("0x5"); } }); }); diff --git a/ts-tests/tests/test-revert-receipt.ts b/ts-tests/tests/test-revert-receipt.ts index 8b384dfd3c..0b5458988e 100644 --- a/ts-tests/tests/test-revert-receipt.ts +++ b/ts-tests/tests/test-revert-receipt.ts @@ -20,7 +20,6 @@ describeWithFrontier("Frontier RPC (Constructor Revert)", (context) => { it("should provide a tx receipt after successful deployment", async function () { this.timeout(15000); - const GOOD_TX_HASH = "0xe73cae1b1105e805ec524b7ffdc4144041e72ff5fb539757ab2d4eef255bfe2d"; const tx = await context.web3.eth.accounts.signTransaction( { @@ -33,22 +32,15 @@ describeWithFrontier("Frontier RPC (Constructor Revert)", (context) => { GENESIS_ACCOUNT_PRIVATE_KEY ); - expect(await customRequest(context.web3, "eth_sendRawTransaction", [tx.rawTransaction])).to.deep.equal({ - id: 1, - jsonrpc: "2.0", - result: GOOD_TX_HASH, - }); + const txHash = (await customRequest(context.web3, "eth_sendRawTransaction", [tx.rawTransaction])).result; // Verify the receipt exists after the block is created await createAndFinalizeBlock(context.web3); - const receipt = await context.web3.eth.getTransactionReceipt(GOOD_TX_HASH); + const receipt = await context.web3.eth.getTransactionReceipt(txHash); expect(receipt).to.include({ - contractAddress: "0xC2Bf5F29a4384b1aB0C063e1c666f02121B6084a", - cumulativeGasUsed: 67231, - from: "0x6be02d1d3665660d22ff9624b7be0551ee1ac91b", - gasUsed: 67231, + from: GENESIS_ACCOUNT, to: null, - transactionHash: GOOD_TX_HASH, + transactionHash: txHash, transactionIndex: 0, status: true, }); @@ -56,9 +48,6 @@ describeWithFrontier("Frontier RPC (Constructor Revert)", (context) => { it("should provide a tx receipt after failed deployment", async function () { this.timeout(15000); - // Transaction hash depends on which nonce we're using - //const FAIL_TX_HASH = '0x89a956c4631822f407b3af11f9251796c276655860c892919f848699ed570a8d'; //nonce 1 - const FAIL_TX_HASH = "0x0aad023a79ccfe0290b8cb47a807720bf4ffcf60225f3fa786eefd95b538d87d"; //nonce 2 const tx = await context.web3.eth.accounts.signTransaction( { @@ -71,21 +60,15 @@ describeWithFrontier("Frontier RPC (Constructor Revert)", (context) => { GENESIS_ACCOUNT_PRIVATE_KEY ); - expect(await customRequest(context.web3, "eth_sendRawTransaction", [tx.rawTransaction])).to.deep.equal({ - id: 1, - jsonrpc: "2.0", - result: FAIL_TX_HASH, - }); + const txHash = (await customRequest(context.web3, "eth_sendRawTransaction", [tx.rawTransaction])).result; + // Verify the receipt exists after the block is created await createAndFinalizeBlock(context.web3); - const receipt = await context.web3.eth.getTransactionReceipt(FAIL_TX_HASH); + const receipt = await context.web3.eth.getTransactionReceipt(txHash); expect(receipt).to.include({ - contractAddress: "0x5c4242beB94dE30b922f57241f1D02f36e906915", - cumulativeGasUsed: 54600, - from: "0x6be02d1d3665660d22ff9624b7be0551ee1ac91b", - gasUsed: 54600, + from: GENESIS_ACCOUNT, to: null, - transactionHash: FAIL_TX_HASH, + transactionHash: txHash, transactionIndex: 0, status: false, }); diff --git a/ts-tests/tests/test-rpc-constants.ts b/ts-tests/tests/test-rpc-constants.ts index cede2cc237..c4dae0ab63 100644 --- a/ts-tests/tests/test-rpc-constants.ts +++ b/ts-tests/tests/test-rpc-constants.ts @@ -1,5 +1,6 @@ import { expect } from "chai"; +import { CHAIN_ID } from "./config"; import { describeWithFrontier } from "./util"; // All test for the RPC @@ -9,9 +10,9 @@ describeWithFrontier("Frontier RPC (Constant)", (context) => { expect(await context.web3.eth.getHashrate()).to.equal(0); }); - it("should have chainId 42", async function () { + it("should have chainId", async function () { // The chainId is defined by the Substrate Chain Id, default to 42 - expect(await context.web3.eth.getChainId()).to.equal(42); + expect(await context.web3.eth.getChainId()).to.equal(CHAIN_ID); }); it("should have no account", async function () { diff --git a/ts-tests/tests/test-subscription.ts b/ts-tests/tests/test-subscription.ts index 7f7430f830..c139fbe7a4 100644 --- a/ts-tests/tests/test-subscription.ts +++ b/ts-tests/tests/test-subscription.ts @@ -6,7 +6,7 @@ import { createAndFinalizeBlock, customRequest, describeWithFrontierWs } from ". describeWithFrontierWs("Frontier RPC (Subscription)", (context) => { let subscription; - let logs_generated = 0; + let logsGenerated = 0; const TEST_CONTRACT_BYTECODE = "0x608060405234801561001057600080fd5b50610041337fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61004660201b60201c565b610291565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156100e9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b6101028160025461020960201b610c7c1790919060201c565b60028190555061015d816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461020960201b610c7c1790919060201c565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600080828401905083811015610287576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b610e3a806102a06000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c806370a082311161005b57806370a08231146101fd578063a457c2d714610255578063a9059cbb146102bb578063dd62ed3e1461032157610088565b8063095ea7b31461008d57806318160ddd146100f357806323b872dd146101115780633950935114610197575b600080fd5b6100d9600480360360408110156100a357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610399565b604051808215151515815260200191505060405180910390f35b6100fb6103b7565b6040518082815260200191505060405180910390f35b61017d6004803603606081101561012757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506103c1565b604051808215151515815260200191505060405180910390f35b6101e3600480360360408110156101ad57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061049a565b604051808215151515815260200191505060405180910390f35b61023f6004803603602081101561021357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061054d565b6040518082815260200191505060405180910390f35b6102a16004803603604081101561026b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610595565b604051808215151515815260200191505060405180910390f35b610307600480360360408110156102d157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610662565b604051808215151515815260200191505060405180910390f35b6103836004803603604081101561033757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610680565b6040518082815260200191505060405180910390f35b60006103ad6103a6610707565b848461070f565b6001905092915050565b6000600254905090565b60006103ce848484610906565b61048f846103da610707565b61048a85604051806060016040528060288152602001610d7060289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610440610707565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610bbc9092919063ffffffff16565b61070f565b600190509392505050565b60006105436104a7610707565b8461053e85600160006104b8610707565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c7c90919063ffffffff16565b61070f565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60006106586105a2610707565b8461065385604051806060016040528060258152602001610de160259139600160006105cc610707565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610bbc9092919063ffffffff16565b61070f565b6001905092915050565b600061067661066f610707565b8484610906565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610795576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180610dbd6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561081b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180610d286022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561098c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180610d986025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a12576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180610d056023913960400191505060405180910390fd5b610a7d81604051806060016040528060268152602001610d4a602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610bbc9092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b10816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c7c90919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610c69576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610c2e578082015181840152602081019050610c13565b50505050905090810190601f168015610c5b5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015610cfa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa265627a7a72315820c7a5ffabf642bda14700b2de42f8c57b36621af020441df825de45fd2b3e1c5c64736f6c63430005100032"; @@ -39,6 +39,7 @@ describeWithFrontierWs("Frontier RPC (Subscription)", (context) => { let connected = false; let subscriptionId = ""; + expect(subscriptionId).is.empty; await new Promise((resolve) => { subscription.on("connected", function (d: any) { connected = true; @@ -49,7 +50,7 @@ describeWithFrontierWs("Frontier RPC (Subscription)", (context) => { subscription.unsubscribe(); expect(connected).to.equal(true); - expect(subscriptionId).to.have.lengthOf(34); + expect(subscriptionId).not.empty; }).timeout(20000); step("should get newHeads stream", async function (done) { @@ -99,7 +100,7 @@ describeWithFrontierWs("Frontier RPC (Subscription)", (context) => { await new Promise((resolve) => { subscription.on("data", function (d: any) { data = d; - logs_generated += 1; + logsGenerated += 1; resolve(); }); }); @@ -128,7 +129,7 @@ describeWithFrontierWs("Frontier RPC (Subscription)", (context) => { }); subscription.on("data", function (d: any) { data = d; - logs_generated += 1; + logsGenerated += 1; dataResolve(); }); @@ -178,7 +179,7 @@ describeWithFrontierWs("Frontier RPC (Subscription)", (context) => { }); subscription.on("data", function (d: any) { data = d; - logs_generated += 1; + logsGenerated += 1; dataResolve(); }); @@ -214,7 +215,7 @@ describeWithFrontierWs("Frontier RPC (Subscription)", (context) => { subscription.on("data", function (d: any) { data = d; - logs_generated += 1; + logsGenerated += 1; dataResolve(); }); @@ -350,7 +351,7 @@ describeWithFrontierWs("Frontier RPC (Subscription)", (context) => { subscription.on("data", function (d: any) { data = d; - logs_generated += 1; + logsGenerated += 1; dataResolve(); }); @@ -389,7 +390,7 @@ describeWithFrontierWs("Frontier RPC (Subscription)", (context) => { subscription.on("data", function (d: any) { data = d; - logs_generated += 1; + logsGenerated += 1; dataResolve(); }); @@ -431,7 +432,7 @@ describeWithFrontierWs("Frontier RPC (Subscription)", (context) => { subscription.on("data", function (d: any) { data = d; - logs_generated += 1; + logsGenerated += 1; dataResolve(); }); @@ -476,7 +477,7 @@ describeWithFrontierWs("Frontier RPC (Subscription)", (context) => { }); subscription.on("data", function (d: any) { data = d; - logs_generated += 1; + logsGenerated += 1; dataResolve(); }); @@ -518,7 +519,7 @@ describeWithFrontierWs("Frontier RPC (Subscription)", (context) => { }); subscription.on("data", function (d: any) { data = d; - logs_generated += 1; + logsGenerated += 1; dataResolve(); }); diff --git a/ts-tests/tests/test-transaction-version.ts b/ts-tests/tests/test-transaction-version.ts index 815674cb30..4cbfdec57a 100644 --- a/ts-tests/tests/test-transaction-version.ts +++ b/ts-tests/tests/test-transaction-version.ts @@ -29,16 +29,16 @@ describeWithFrontier("Frontier RPC (Transaction Version)", (context) => { gasLimit: "0x100000", chainId: CHAIN_ID, }; - const tx_hash = (await sendTransaction(context, tx)).hash; + const txHash = (await sendTransaction(context, tx)).hash; await createAndFinalizeBlock(context.web3); const latest = await context.web3.eth.getBlock("latest"); expect(latest.transactions.length).to.be.eq(1); - expect(latest.transactions[0]).to.be.eq(tx_hash); + expect(latest.transactions[0]).to.be.eq(txHash); - let receipt = await context.web3.eth.getTransactionReceipt(tx_hash); - expect(receipt.transactionHash).to.be.eq(tx_hash); + let receipt = await context.web3.eth.getTransactionReceipt(txHash); + expect(receipt.transactionHash).to.be.eq(txHash); - let transaction_data = await context.web3.eth.getTransaction(tx_hash); + let transaction_data = await context.web3.eth.getTransaction(txHash); expect(transaction_data).to.have.own.property("type"); expect(transaction_data).to.not.have.own.property("maxFeePerGas"); expect(transaction_data).to.not.have.own.property("maxPriorityFeePerGas"); @@ -56,16 +56,16 @@ describeWithFrontier("Frontier RPC (Transaction Version)", (context) => { gasLimit: "0x100000", chainId: CHAIN_ID, }; - const tx_hash = (await sendTransaction(context, tx)).hash; + const txHash = (await sendTransaction(context, tx)).hash; await createAndFinalizeBlock(context.web3); const latest = await context.web3.eth.getBlock("latest"); expect(latest.transactions.length).to.be.eq(1); - expect(latest.transactions[0]).to.be.eq(tx_hash); + expect(latest.transactions[0]).to.be.eq(txHash); - let receipt = await context.web3.eth.getTransactionReceipt(tx_hash); - expect(receipt.transactionHash).to.be.eq(tx_hash); + let receipt = await context.web3.eth.getTransactionReceipt(txHash); + expect(receipt.transactionHash).to.be.eq(txHash); - let transaction_data = await context.web3.eth.getTransaction(tx_hash); + let transaction_data = await context.web3.eth.getTransaction(txHash); expect(transaction_data).to.have.own.property("type"); expect(transaction_data).to.not.have.own.property("maxFeePerGas"); expect(transaction_data).to.not.have.own.property("maxPriorityFeePerGas"); @@ -84,16 +84,16 @@ describeWithFrontier("Frontier RPC (Transaction Version)", (context) => { gasLimit: "0x100000", chainId: CHAIN_ID, }; - const tx_hash = (await sendTransaction(context, tx)).hash; + const txHash = (await sendTransaction(context, tx)).hash; await createAndFinalizeBlock(context.web3); const latest = await context.web3.eth.getBlock("latest"); expect(latest.transactions.length).to.be.eq(1); - expect(latest.transactions[0]).to.be.eq(tx_hash); + expect(latest.transactions[0]).to.be.eq(txHash); - let receipt = await context.web3.eth.getTransactionReceipt(tx_hash); - expect(receipt.transactionHash).to.be.eq(tx_hash); + let receipt = await context.web3.eth.getTransactionReceipt(txHash); + expect(receipt.transactionHash).to.be.eq(txHash); - let transaction_data = await context.web3.eth.getTransaction(tx_hash); + let transaction_data = await context.web3.eth.getTransaction(txHash); expect(transaction_data).to.have.own.property("type"); expect(transaction_data).to.have.own.property("maxFeePerGas"); expect(transaction_data).to.have.own.property("maxPriorityFeePerGas"); diff --git a/ts-tests/tests/test-web3api.ts b/ts-tests/tests/test-web3api.ts index 67208d6219..8eaa4c21c3 100644 --- a/ts-tests/tests/test-web3api.ts +++ b/ts-tests/tests/test-web3api.ts @@ -1,18 +1,21 @@ import { expect } from "chai"; import { step } from "mocha-steps"; +import { RUNTIME_SPEC_NAME, RUNTIME_SPEC_VERSION, RUNTIME_IMPL_VERSION } from "./config"; import { describeWithFrontier, customRequest } from "./util"; describeWithFrontier("Frontier RPC (Web3Api)", (context) => { step("should get client version", async function () { const version = await context.web3.eth.getNodeInfo(); - expect(version).to.be.equal("node-frontier-template/v1.1/fc-rpc-2.0.0-dev"); + expect(version).to.be.equal( + `${RUNTIME_SPEC_NAME}/v${RUNTIME_SPEC_VERSION}.${RUNTIME_IMPL_VERSION}/fc-rpc-2.0.0-dev` + ); }); step("should remote sha3", async function () { const data = context.web3.utils.stringToHex("hello"); const hash = await customRequest(context.web3, "web3_sha3", [data]); - const local_hash = context.web3.utils.sha3("hello"); - expect(hash.result).to.be.equal(local_hash); + const localHash = context.web3.utils.sha3("hello"); + expect(hash.result).to.be.equal(localHash); }); }); diff --git a/ts-tests/tests/util.ts b/ts-tests/tests/util.ts index 76df4d6ede..9099dca964 100644 --- a/ts-tests/tests/util.ts +++ b/ts-tests/tests/util.ts @@ -3,7 +3,7 @@ import { ethers } from "ethers"; import { JsonRpcResponse } from "web3-core-helpers"; import { spawn, ChildProcess } from "child_process"; -import { CHAIN_ID } from "./config"; +import { NODE_BINARY_NAME, CHAIN_ID } from "./config"; export const PORT = 19931; export const RPC_PORT = 19932; @@ -13,7 +13,7 @@ export const DISPLAY_LOG = process.env.FRONTIER_LOG || false; export const FRONTIER_LOG = process.env.FRONTIER_LOG || "info"; export const FRONTIER_BUILD = process.env.FRONTIER_BUILD || "release"; -export const BINARY_PATH = `../target/${FRONTIER_BUILD}/frontier-template-node`; +export const BINARY_PATH = `../target/${FRONTIER_BUILD}/${NODE_BINARY_NAME}`; export const SPAWNING_TIME = 60000; export async function customRequest(web3: Web3, method: string, params: any[]) {