Skip to content

Commit

Permalink
fix: tests for block cumultive gas calculation
Browse files Browse the repository at this point in the history
Signed-off-by: 0x00000002 <[email protected]>
  • Loading branch information
0x00000002 committed Jul 4, 2024
1 parent fa13468 commit 7b0a091
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion ts-tests/tests/test-fee-history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describeWithFrontier("Frontier RPC (Fee History)", (context) => {
// baseFeePerGas is always the requested block range + 1 (the next derived base fee).
expect(result.baseFeePerGas.length).to.be.eq(blockCount + 1);
// gasUsedRatio for the requested block range.
expect(result.gasUsedRatio).to.be.deep.eq(Array(blockCount).fill(0.03576792));
expect(result.gasUsedRatio).to.be.deep.eq(Array(blockCount).fill(0.07153584));
// two-dimensional reward list for the requested block range.
expect(result.reward.length).to.be.eq(blockCount);
// each block has a reward list which's size is the requested percentile list.
Expand Down
30 changes: 15 additions & 15 deletions ts-tests/tests/test-gas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describeWithFrontier("Frontier RPC (Gas)", (context) => {
await context.web3.eth.estimateGas({
from: GENESIS_ACCOUNT,
data: Test.bytecode,
})
}),
).to.equal(binarySearchEstimation);
});

Expand Down Expand Up @@ -140,7 +140,7 @@ describeWithFrontier("Frontier RPC (Gas)", (context) => {
gas: ETH_BLOCK_GAS_LIMIT - 1,
gasPrice: "0x3B9ACA00",
},
GENESIS_ACCOUNT_PRIVATE_KEY
GENESIS_ACCOUNT_PRIVATE_KEY,
);
const createReceipt = await customRequest(context.web3, "eth_sendRawTransaction", [tx.rawTransaction]);
await createAndFinalizeBlock(context.web3);
Expand All @@ -155,7 +155,7 @@ describeWithFrontier("Frontier RPC (Gas)", (context) => {
gas: ETH_BLOCK_GAS_LIMIT,
gasPrice: "0x3B9ACA00",
},
GENESIS_ACCOUNT_PRIVATE_KEY
GENESIS_ACCOUNT_PRIVATE_KEY,
);
const createReceipt = await customRequest(context.web3, "eth_sendRawTransaction", [tx.rawTransaction]);
await createAndFinalizeBlock(context.web3);
Expand All @@ -170,7 +170,7 @@ describeWithFrontier("Frontier RPC (Gas)", (context) => {
gas: ETH_BLOCK_GAS_LIMIT + 1,
gasPrice: "0x3B9ACA00",
},
GENESIS_ACCOUNT_PRIVATE_KEY
GENESIS_ACCOUNT_PRIVATE_KEY,
);
const createReceipt = await customRequest(context.web3, "eth_sendRawTransaction", [tx.rawTransaction]);
await createAndFinalizeBlock(context.web3);
Expand Down Expand Up @@ -204,7 +204,7 @@ describeWithFrontier("Frontier RPC (Gas limit Weightv2 ref time)", (context) =>
gasPrice: "0x3B9ACA00",
gas: "0x100000",
},
GENESIS_ACCOUNT_PRIVATE_KEY
GENESIS_ACCOUNT_PRIVATE_KEY,
);
await customRequest(context.web3, "eth_sendRawTransaction", [tx.rawTransaction]);
await createAndFinalizeBlock(context.web3);
Expand All @@ -221,7 +221,7 @@ describeWithFrontier("Frontier RPC (Gas limit Weightv2 ref time)", (context) =>
let nonce = await context.web3.eth.getTransactionCount(GENESIS_ACCOUNT);

for (var i = 0; i < CALLS_PER_BLOCK; i++) {
let data = contract.methods.storageLoop(1000, TEST_ACCOUNT, i);
let data = contract.methods.storageLoop(100, TEST_ACCOUNT, i);
let tx = await context.web3.eth.accounts.signTransaction(
{
from: GENESIS_ACCOUNT,
Expand All @@ -231,7 +231,7 @@ describeWithFrontier("Frontier RPC (Gas limit Weightv2 ref time)", (context) =>
gas: "0x100000",
nonce,
},
GENESIS_ACCOUNT_PRIVATE_KEY
GENESIS_ACCOUNT_PRIVATE_KEY,
);
await customRequest(context.web3, "eth_sendRawTransaction", [tx.rawTransaction]);
nonce++;
Expand All @@ -248,7 +248,7 @@ describeWithFrontier("Frontier RPC (Gas limit Weightv2 ref time)", (context) =>
gas: "0x5208",
nonce,
},
GENESIS_ACCOUNT_PRIVATE_KEY
GENESIS_ACCOUNT_PRIVATE_KEY,
);
let r = await customRequest(context.web3, "eth_sendRawTransaction", [tx.rawTransaction]);
nonce++;
Expand Down Expand Up @@ -292,7 +292,7 @@ describeWithFrontier("Frontier RPC (Gas limit Weightv2 pov size)", (context) =>
gasPrice: "0x3B9ACA00",
gas: "0x100000",
},
GENESIS_ACCOUNT_PRIVATE_KEY
GENESIS_ACCOUNT_PRIVATE_KEY,
);
await customRequest(context.web3, "eth_sendRawTransaction", [tx1.rawTransaction]);
const tx2 = await context.web3.eth.accounts.signTransaction(
Expand All @@ -303,7 +303,7 @@ describeWithFrontier("Frontier RPC (Gas limit Weightv2 pov size)", (context) =>
gasPrice: "0x3B9ACA00",
nonce: 1,
},
GENESIS_ACCOUNT_PRIVATE_KEY
GENESIS_ACCOUNT_PRIVATE_KEY,
);
const { result } = await customRequest(context.web3, "eth_sendRawTransaction", [tx2.rawTransaction]);
await createAndFinalizeBlock(context.web3);
Expand Down Expand Up @@ -331,15 +331,15 @@ describeWithFrontier("Frontier RPC (Gas limit Weightv2 pov size)", (context) =>
gas: "0xF4240",
nonce,
},
GENESIS_ACCOUNT_PRIVATE_KEY
GENESIS_ACCOUNT_PRIVATE_KEY,
);
let contract_transfer_hash = await (
await customRequest(context.web3, "eth_sendRawTransaction", [tx.rawTransaction])
).result;
nonce++;

for (var i = 0; i < CALLS_PER_BLOCK; i++) {
let data = contract.methods.storageLoop(1000, TEST_ACCOUNT, i);
let data = contract.methods.storageLoop(100, TEST_ACCOUNT, i);
let tx = await context.web3.eth.accounts.signTransaction(
{
from: GENESIS_ACCOUNT,
Expand All @@ -349,7 +349,7 @@ describeWithFrontier("Frontier RPC (Gas limit Weightv2 pov size)", (context) =>
gas: "0x100000",
nonce,
},
GENESIS_ACCOUNT_PRIVATE_KEY
GENESIS_ACCOUNT_PRIVATE_KEY,
);
await customRequest(context.web3, "eth_sendRawTransaction", [tx.rawTransaction]);
nonce++;
Expand All @@ -366,7 +366,7 @@ describeWithFrontier("Frontier RPC (Gas limit Weightv2 pov size)", (context) =>
gas: "0x5208",
nonce,
},
GENESIS_ACCOUNT_PRIVATE_KEY
GENESIS_ACCOUNT_PRIVATE_KEY,
);
let r = await customRequest(context.web3, "eth_sendRawTransaction", [tx.rawTransaction]);
nonce++;
Expand Down Expand Up @@ -396,7 +396,7 @@ describeWithFrontier("Frontier RPC (Invalid opcode estimate gas)", (context) =>
gasPrice: "0x3B9ACA00",
gas: "0x100000",
},
GENESIS_ACCOUNT_PRIVATE_KEY
GENESIS_ACCOUNT_PRIVATE_KEY,
);
const txHash = (await customRequest(context.web3, "eth_sendRawTransaction", [tx.rawTransaction])).result;
await createAndFinalizeBlock(context.web3);
Expand Down

0 comments on commit 7b0a091

Please sign in to comment.