Skip to content

Commit

Permalink
lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
avkos committed Apr 1, 2024
1 parent 50f18b5 commit 95de1c7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
12 changes: 6 additions & 6 deletions packages/web3-eth/test/integration/format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { SupportedProviders, FMT_BYTES, FMT_NUMBER, DEFAULT_RETURN_FORMAT } from
import { Contract } from 'web3-eth-contract';
import { numberToHex } from 'web3-utils';
// eslint-disable-next-line import/no-extraneous-dependencies
import { describe } from 'node:test';
import { Web3Eth } from '../../src';

import {
Expand All @@ -30,7 +31,6 @@ import {
mapFormatToType,
} from '../fixtures/system_test_utils';
import { BasicAbi, BasicBytecode } from '../shared_fixtures/build/Basic';
import { describe } from 'node:test';

describe('format', () => {
let web3Eth: Web3Eth;
Expand Down Expand Up @@ -71,21 +71,21 @@ describe('format', () => {
});

describe('methods', () => {
it.each(Object.values(FMT_NUMBER))('getBlockNumber', async format => {
test.each(Object.values(FMT_NUMBER))('getBlockNumber', async format => {
web3Eth.defaultReturnFormat = { number: format as FMT_NUMBER, bytes: FMT_BYTES.HEX };
const res = await web3Eth.getBlockNumber();
expect(typeof res).toBe(mapFormatToType[format as string]);
expect(parseInt(String(res), 16)).toBeGreaterThan(0);
});

it.each(Object.values(FMT_NUMBER))('getGasPrice', async format => {
test.each(Object.values(FMT_NUMBER))('getGasPrice', async format => {
web3Eth.defaultReturnFormat = { number: format as FMT_NUMBER, bytes: FMT_BYTES.HEX };
const res = await web3Eth.getGasPrice();
expect(typeof res).toBe(mapFormatToType[format as string]);
expect(parseInt(String(res), 16)).toBeGreaterThan(0);
});

it.each(Object.values(FMT_NUMBER))('getBalance', async format => {
test.each(Object.values(FMT_NUMBER))('getBalance', async format => {
web3Eth.defaultReturnFormat = { number: format as FMT_NUMBER, bytes: FMT_BYTES.HEX };
const value = '0xa';
const newAccount = await createNewAccount();
Expand All @@ -99,14 +99,14 @@ describe('format', () => {
expect(numberToHex(res)).toBe(value);
});

it.each(Object.values(FMT_BYTES))('getCode', async format => {
test.each(Object.values(FMT_BYTES))('getCode', async format => {
web3Eth.defaultReturnFormat = { number: FMT_NUMBER.BIGINT, bytes: format };
const code = await web3Eth.getCode(contractDeployed?.options?.address as string);
expect(code).toBeDefined();
expect(typeof code).toBe(mapFormatToType[format as string]);
});

it.each(Object.values(FMT_NUMBER))('getChainId', async format => {
test.each(Object.values(FMT_NUMBER))('getChainId', async format => {
web3Eth.defaultReturnFormat = { number: format as FMT_NUMBER, bytes: FMT_BYTES.HEX };
const res = await web3Eth.getChainId();
expect(typeof res).toBe(mapFormatToType[format as string]);
Expand Down
32 changes: 16 additions & 16 deletions packages/web3-eth/test/integration/rpc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
import { Contract, decodeEventABI } from 'web3-eth-contract';
import { hexToNumber, hexToString, numberToHex, getStorageSlotNumForLongString } from 'web3-utils';
// eslint-disable-next-line import/no-extraneous-dependencies
import { describe } from 'node:test';
import { Web3Eth } from '../../src';

import {
Expand All @@ -42,7 +43,6 @@ import {
} from '../fixtures/system_test_utils';
import { BasicAbi, BasicBytecode } from '../shared_fixtures/build/Basic';
import { eventAbi, sendFewTxes, validateReceipt, validateTransaction } from './helper';
import { describe } from 'node:test';

describe('rpc', () => {
let web3Eth: Web3Eth;
Expand Down Expand Up @@ -92,13 +92,13 @@ describe('rpc', () => {
);

// TODO:in beta, test eth_syncing during sync mode with return obj having ( startingblock, currentBlock, heighestBlock )
it('isSyncing', async () => {
test('isSyncing', async () => {
const isSyncing = await web3Eth.isSyncing();
expect(isSyncing).toBe(false);
});

// TODO: in future release, set coinbase account in node and match actual address here
it('getCoinbase', async () => {
test('getCoinbase', async () => {
const coinbase = await web3Eth.getCoinbase();
expect(coinbase.startsWith('0x')).toBe(true);
expect(coinbase).toHaveLength(42);
Expand All @@ -113,7 +113,7 @@ describe('rpc', () => {
});

describeIf(getSystemTestBackend() !== BACKEND.HARDHAT)('getHashRate', () => {
it.each(Object.values(FMT_NUMBER))('getHashRate', async format => {
test.each(Object.values(FMT_NUMBER))('getHashRate', async format => {
const hashRate = await web3Eth.getHashRate({
number: format as FMT_NUMBER,
bytes: FMT_BYTES.HEX,
Expand All @@ -123,7 +123,7 @@ describe('rpc', () => {
});
});

it('getAccounts', async () => {
test('getAccounts', async () => {
// hardhat does not have support importrawkey, so we can't add new accounts rather just check the default 20 accounts
if (getSystemTestBackend() !== BACKEND.HARDHAT) {
const account = await createNewAccount({ unlock: true });
Expand All @@ -138,7 +138,7 @@ describe('rpc', () => {
}
});

it.each(Object.values(FMT_NUMBER))('getBlockNumber', async format => {
test.each(Object.values(FMT_NUMBER))('getBlockNumber', async format => {
const res = await web3Eth.getBlockNumber({
number: format as FMT_NUMBER,
bytes: FMT_BYTES.HEX,
Expand All @@ -147,7 +147,7 @@ describe('rpc', () => {
expect(parseInt(String(res), 16)).toBeGreaterThan(0);
});

it.each(Object.values(FMT_NUMBER))('getGasPrice', async format => {
test.each(Object.values(FMT_NUMBER))('getGasPrice', async format => {
const res = await web3Eth.getGasPrice({
number: format as FMT_NUMBER,
bytes: FMT_BYTES.HEX,
Expand All @@ -156,7 +156,7 @@ describe('rpc', () => {
expect(parseInt(String(res), 16)).toBeGreaterThan(0);
});

it.each(Object.values(FMT_NUMBER))('getBalance', async format => {
test.each(Object.values(FMT_NUMBER))('getBalance', async format => {
const value = '0xa';
const newAccount = await createNewAccount();
await web3Eth.sendTransaction({
Expand All @@ -173,7 +173,7 @@ describe('rpc', () => {
expect(numberToHex(res)).toBe(value);
});

it('getStorageAt', async () => {
test('getStorageAt', async () => {
const numberData = 10;
const stringData = 'str';
const boolData = true;
Expand Down Expand Up @@ -247,7 +247,7 @@ describe('rpc', () => {
expect(stringDataLong).toBe(str);
});

it.each(Object.values(FMT_NUMBER))('getCode', async format => {
test.each(Object.values(FMT_NUMBER))('getCode', async format => {
const code = await web3Eth.getCode(
contractDeployed?.options?.address as string,
undefined,
Expand All @@ -260,7 +260,7 @@ describe('rpc', () => {
expect(BasicBytecode.slice(-100)).toBe(code.slice(-100));
});

it('getTransaction', async () => {
test('getTransaction', async () => {
const [receipt] = await sendFewTxes({
from: tempAcc.address,
value: '0x1',
Expand All @@ -276,7 +276,7 @@ describe('rpc', () => {
validateTransaction(res as TransactionInfo);
expect(res?.hash).toBe(receipt.transactionHash);
});
it('check get transaction fields', async () => {
test('check get transaction fields', async () => {
const receipt0 = await web3Eth.sendTransaction({
from: tempAcc.address,
value: '0x1',
Expand Down Expand Up @@ -375,7 +375,7 @@ describe('rpc', () => {
expect(res).toBeDefined();
});

it('getTransactionReceipt', async () => {
test('getTransactionReceipt', async () => {
const [receipt] = await sendFewTxes({
from: tempAcc.address,
value: '0x1',
Expand All @@ -390,7 +390,7 @@ describe('rpc', () => {
expect(res?.transactionHash).toBe(receipt.transactionHash);
});

it('getChainId', async () => {
test('getChainId', async () => {
const res = await web3Eth.getChainId({
number: FMT_NUMBER.NUMBER,
bytes: FMT_BYTES.HEX,
Expand All @@ -399,7 +399,7 @@ describe('rpc', () => {
expect(Number(res)).toBeGreaterThan(0);
});

it('getNodeInfo', async () => {
test('getNodeInfo', async () => {
const res = await web3Eth.getNodeInfo();
// TODO: in next release, it should also be validated
expect(res).toBeDefined();
Expand Down Expand Up @@ -432,7 +432,7 @@ describe('rpc', () => {
expect(res.storageProof[0].value).toBe(numberData);
});

it('getPastLogs', async () => {
test('getPastLogs', async () => {
const listOfStrings = ['t1', 't2', 't3'];
const resTx = [];
for (const l of listOfStrings) {
Expand Down
12 changes: 6 additions & 6 deletions packages/web3/test/integration/web3.format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ along with web3.js. If not, see <http://www.gnu.org/licenses/>.

import { SupportedProviders, FMT_BYTES, FMT_NUMBER, DEFAULT_RETURN_FORMAT } from 'web3-types';
import { numberToHex } from 'web3-utils';
import { describe } from 'node:test';
import { Web3, Contract } from '../../src';

import {
Expand All @@ -27,7 +28,6 @@ import {
mapFormatToType,
} from '../shared_fixtures/system_tests_utils';
import { BasicAbi, BasicBytecode } from '../shared_fixtures/build/Basic';
import { describe } from 'node:test';

describe('format', () => {
let web3: Web3;
Expand Down Expand Up @@ -65,21 +65,21 @@ describe('format', () => {
});

describe('methods', () => {
it.each(Object.values(FMT_NUMBER))('getBlockNumber', async format => {
test.each(Object.values(FMT_NUMBER))('getBlockNumber', async format => {
web3.defaultReturnFormat = { number: format as FMT_NUMBER, bytes: FMT_BYTES.HEX };
const res = await web3.eth.getBlockNumber();
expect(typeof res).toBe(mapFormatToType[format as string]);
expect(parseInt(String(res), 16)).toBeGreaterThan(0);
});

it.each(Object.values(FMT_NUMBER))('getGasPrice', async format => {
test.each(Object.values(FMT_NUMBER))('getGasPrice', async format => {
web3.defaultReturnFormat = { number: format as FMT_NUMBER, bytes: FMT_BYTES.HEX };
const res = await web3.eth.getGasPrice();
expect(typeof res).toBe(mapFormatToType[format as string]);
expect(parseInt(String(res), 16)).toBeGreaterThan(0);
});

it.each(Object.values(FMT_NUMBER))('getBalance', async format => {
test.each(Object.values(FMT_NUMBER))('getBalance', async format => {
web3.defaultReturnFormat = { number: format as FMT_NUMBER, bytes: FMT_BYTES.HEX };
const value = '0xa';
const newAccount = await createNewAccount();
Expand All @@ -93,14 +93,14 @@ describe('format', () => {
expect(numberToHex(res)).toBe(value);
});

it.each(Object.values(FMT_BYTES))('getCode', async format => {
test.each(Object.values(FMT_BYTES))('getCode', async format => {
web3.defaultReturnFormat = { number: FMT_NUMBER.BIGINT, bytes: format };
const code = await web3.eth.getCode(contractDeployed?.options?.address as string);
expect(code).toBeDefined();
expect(typeof code).toBe(mapFormatToType[format as string]);
});

it.each(Object.values(FMT_NUMBER))('getChainId', async format => {
test.each(Object.values(FMT_NUMBER))('getChainId', async format => {
web3.defaultReturnFormat = { number: format as FMT_NUMBER, bytes: FMT_BYTES.HEX };

const res = await web3.eth.getChainId();
Expand Down

1 comment on commit 95de1c7

@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: 95de1c7 Previous: 6c075db Ratio
processingTx 9676 ops/sec (±3.81%) 9301 ops/sec (±4.81%) 0.96
processingContractDeploy 39208 ops/sec (±6.77%) 39129 ops/sec (±7.62%) 1.00
processingContractMethodSend 19092 ops/sec (±8.89%) 19443 ops/sec (±5.19%) 1.02
processingContractMethodCall 40440 ops/sec (±5.59%) 38971 ops/sec (±6.34%) 0.96
abiEncode 45526 ops/sec (±6.58%) 44252 ops/sec (±6.92%) 0.97
abiDecode 31395 ops/sec (±7.78%) 30419 ops/sec (±8.89%) 0.97
sign 1604 ops/sec (±3.36%) 1656 ops/sec (±4.08%) 1.03
verify 380 ops/sec (±0.39%) 373 ops/sec (±0.78%) 0.98

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

Please sign in to comment.