Skip to content

Commit

Permalink
limit a unit test to geth
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammad-Altabba committed Feb 13, 2024
1 parent cd83ff4 commit fc92fc8
Showing 1 changed file with 65 additions and 65 deletions.
130 changes: 65 additions & 65 deletions packages/web3-eth/test/integration/web3_eth/send_transaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ import {
createTempAccount,
getSystemTestBackend,
getSystemTestProvider,
isGeth,
itIf,
BACKEND
BACKEND,
} from '../../fixtures/system_test_utils';
import { SimpleRevertAbi, SimpleRevertDeploymentData } from '../../fixtures/simple_revert';

Expand Down Expand Up @@ -89,9 +90,7 @@ describe('Web3Eth.sendTransaction', () => {
expect(response.status).toBe(BigInt(1));
expect(response.events).toBeUndefined();

const minedTransactionData = await web3EthWithWallet.getTransaction(
response.transactionHash,
);
const minedTransactionData = await web3EthWithWallet.getTransaction(response.transactionHash);

expect(minedTransactionData).toMatchObject({
from: tempAcc.address,
Expand Down Expand Up @@ -120,9 +119,7 @@ describe('Web3Eth.sendTransaction', () => {
expect(response.status).toBe(BigInt(1));
expect(response.events).toBeUndefined();

const minedTransactionData = await web3EthWithWallet.getTransaction(
response.transactionHash,
);
const minedTransactionData = await web3EthWithWallet.getTransaction(response.transactionHash);

expect(minedTransactionData).toMatchObject({
from: tempAcc.address,
Expand Down Expand Up @@ -155,9 +152,7 @@ describe('Web3Eth.sendTransaction', () => {
expect(response.status).toBe(BigInt(1));
expect(response.events).toBeUndefined();

const minedTransactionData = await web3EthWithWallet.getTransaction(
response.transactionHash,
);
const minedTransactionData = await web3EthWithWallet.getTransaction(response.transactionHash);

expect(minedTransactionData).toMatchObject({
from: tempAcc.address,
Expand Down Expand Up @@ -371,20 +366,28 @@ describe('Web3Eth.sendTransaction', () => {
expect(minedTransactionData).toMatchObject(transaction);
});

it('should send type 0x2 transaction with maxPriorityFeePerGas got from await web3Eth.getMaxPriorityFeePerGas()', async () => {
const transaction: Transaction = {
from: tempAcc.address,
to: '0x0000000000000000000000000000000000000000',
value: BigInt(1),
maxPriorityFeePerGas: await web3Eth.getMaxPriorityFeePerGas(),
};
const response = await web3Eth.sendTransaction(transaction);
expect(response.events).toBeUndefined();
expect(response.type).toBe(BigInt(2));
expect(response.status).toBe(BigInt(1));
const minedTransactionData = await web3Eth.getTransaction(response.transactionHash);
expect(minedTransactionData).toMatchObject(transaction);
});
itIf(isGeth)(
'should send type 0x2 transaction with maxPriorityFeePerGas got from await web3Eth.getMaxPriorityFeePerGas()',
async () => {
const transaction: Transaction = {
from: tempAcc.address,
to: '0x0000000000000000000000000000000000000000',
value: BigInt(1),
maxPriorityFeePerGas: await web3Eth.getMaxPriorityFeePerGas(),
};
const response = await web3Eth.sendTransaction(transaction);

// eslint-disable-next-line jest/no-standalone-expect
expect(response.events).toBeUndefined();
// eslint-disable-next-line jest/no-standalone-expect
expect(response.type).toBe(BigInt(2));
// eslint-disable-next-line jest/no-standalone-expect
expect(response.status).toBe(BigInt(1));
const minedTransactionData = await web3Eth.getTransaction(response.transactionHash);
// eslint-disable-next-line jest/no-standalone-expect
expect(minedTransactionData).toMatchObject(transaction);
},
);

describe('Transaction PromiEvents', () => {
let transaction: Transaction;
Expand Down Expand Up @@ -491,12 +494,9 @@ describe('Web3Eth.sendTransaction', () => {
from: tempAcc.address,
data: SimpleRevertDeploymentData,
};
simpleRevertDeployTransaction.gas = await web3Eth.estimateGas(
simpleRevertDeployTransaction,
);
simpleRevertContractAddress = (
await web3Eth.sendTransaction(simpleRevertDeployTransaction)
).contractAddress as Address;
simpleRevertDeployTransaction.gas = await web3Eth.estimateGas(simpleRevertDeployTransaction);
simpleRevertContractAddress = (await web3Eth.sendTransaction(simpleRevertDeployTransaction))
.contractAddress as Address;
});

it('Should throw TransactionRevertInstructionError because gas too low', async () => {
Expand All @@ -515,51 +515,51 @@ describe('Web3Eth.sendTransaction', () => {
? 'err: intrinsic gas too low: have 1, want 21000 (supplied gas 1)'
: 'base fee exceeds gas limit',
};
if(getSystemTestBackend() !== BACKEND.HARDHAT){

if (getSystemTestBackend() !== BACKEND.HARDHAT) {
await expect(
web3Eth
.sendTransaction(transaction)
.on('error', error => expect(error).toMatchObject(expectedThrownError)),
).rejects.toMatchObject(expectedThrownError);
} else {

try {
await web3Eth.sendTransaction(transaction);
} catch (error) {
} catch (error) {
expect((error as any).name).toEqual(expectedThrownError.name);
expect((error as any).code).toEqual(expectedThrownError.code);
expect((error as any).reason).toContain(expectedThrownError.reason);
}
}
}
});
itIf(getSystemTestBackend() !== BACKEND.HARDHAT)('Should throw TransactionRevertInstructionError because insufficient funds', async () => {
const transaction: Transaction = {
from: tempAcc.address,
to: '0x0000000000000000000000000000000000000000',
value: BigInt('99999999999999999999999999999999999999999999999999999999999999999'),
};

const expectedThrownError = {
name: 'TransactionRevertInstructionError',
message: 'Transaction has been reverted by the EVM',
code: 402,
reason:
getSystemTestBackend() === BACKEND.GETH
? expect.stringContaining(
'err: insufficient funds for gas * price + value: address',
)
: 'VM Exception while processing transaction: insufficient balance',
};

// eslint-disable-next-line jest/no-standalone-expect
await expect(
web3Eth
.sendTransaction(transaction)
// eslint-disable-next-line jest/no-standalone-expect
.on('error', error => expect(error).toMatchObject(expectedThrownError)),
).rejects.toMatchObject(expectedThrownError);
});
itIf(getSystemTestBackend() !== BACKEND.HARDHAT)(
'Should throw TransactionRevertInstructionError because insufficient funds',
async () => {
const transaction: Transaction = {
from: tempAcc.address,
to: '0x0000000000000000000000000000000000000000',
value: BigInt('99999999999999999999999999999999999999999999999999999999999999999'),
};

const expectedThrownError = {
name: 'TransactionRevertInstructionError',
message: 'Transaction has been reverted by the EVM',
code: 402,
reason:
getSystemTestBackend() === BACKEND.GETH
? expect.stringContaining('err: insufficient funds for gas * price + value: address')
: 'VM Exception while processing transaction: insufficient balance',
};

// eslint-disable-next-line jest/no-standalone-expect
await expect(
web3Eth
.sendTransaction(transaction)
// eslint-disable-next-line jest/no-standalone-expect
.on('error', error => expect(error).toMatchObject(expectedThrownError)),
).rejects.toMatchObject(expectedThrownError);
},
);

it('Should throw TransactionRevertInstructionError because of contract revert and return revert reason', async () => {
const transaction: Transaction = {
Expand Down Expand Up @@ -604,7 +604,7 @@ describe('Web3Eth.sendTransaction', () => {
reason:
getSystemTestBackend() === BACKEND.GETH
? 'execution reverted'
: "Error: VM Exception while processing transaction: reverted with an unrecognized custom error (return data: 0x72090e4d)",
: 'Error: VM Exception while processing transaction: reverted with an unrecognized custom error (return data: 0x72090e4d)',
signature: '0x72090e4d',
customErrorName: 'ErrorWithNoParams',
customErrorDecodedSignature: 'ErrorWithNoParams()',
Expand Down Expand Up @@ -634,7 +634,7 @@ describe('Web3Eth.sendTransaction', () => {
reason:
getSystemTestBackend() === BACKEND.GETH
? 'execution reverted'
: "Error: VM Exception while processing transaction: reverted with an unrecognized custom error (return data: 0xc85bda60000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001c5468697320697320616e206572726f72207769746820706172616d7300000000)",
: 'Error: VM Exception while processing transaction: reverted with an unrecognized custom error (return data: 0xc85bda60000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001c5468697320697320616e206572726f72207769746820706172616d7300000000)',
signature: '0xc85bda60',
data: '000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001c5468697320697320616e206572726f72207769746820706172616d7300000000',
customErrorName: 'ErrorWithParams',
Expand Down Expand Up @@ -672,7 +672,7 @@ describe('Web3Eth.sendTransaction', () => {
signature: '0x08c379a0',
data: '000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000155468697320697320612073656e64207265766572740000000000000000000000',
};

await expect(
web3Eth
.sendTransaction(transaction)
Expand Down

1 comment on commit fc92fc8

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: fc92fc8 Previous: 6c075db Ratio
processingTx 9378 ops/sec (±4.46%) 9301 ops/sec (±4.81%) 0.99
processingContractDeploy 38567 ops/sec (±8.45%) 39129 ops/sec (±7.62%) 1.01
processingContractMethodSend 20288 ops/sec (±6.28%) 19443 ops/sec (±5.19%) 0.96
processingContractMethodCall 39758 ops/sec (±5.72%) 38971 ops/sec (±6.34%) 0.98
abiEncode 46472 ops/sec (±7.38%) 44252 ops/sec (±6.92%) 0.95
abiDecode 31731 ops/sec (±8.25%) 30419 ops/sec (±8.89%) 0.96
sign 1630 ops/sec (±3.29%) 1656 ops/sec (±4.08%) 1.02
verify 384 ops/sec (±0.57%) 373 ops/sec (±0.78%) 0.97

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.