Skip to content

Commit b476a02

Browse files
Refactor ETH test spec (#1925)
--------- Signed-off-by: Stefan Stefanov <[email protected]>
1 parent db24ab3 commit b476a02

25 files changed

+6513
-6125
lines changed

packages/relay/package.json

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,26 @@
2525
"lint": "npx eslint --ext .js,.ts .",
2626
"format": "npx prettier --ignore-path ../../.gitignore --write \"**/*.+(js|ts|json)\"",
2727
"test": "nyc ts-mocha --recursive './tests/**/*.spec.ts' './tests/**/**/*.spec.ts' --exit",
28-
"test:balance": "nyc ts-mocha --recursive './tests/**/*.spec.ts' './tests/**/**/*.spec.ts' -g '@balance' --exit"
28+
"test-eth": "nyc ts-mocha --recursive './tests/lib/eth/**/*.spec.ts' --exit",
29+
"test:eth-get-block-by-number": "nyc ts-mocha --recursive './tests/**/*.spec.ts' './tests/**/**/*.spec.ts' -g '@ethGetBlockByNumber' --exit",
30+
"test:eth-get-block-by-hash": "nyc ts-mocha --recursive './tests/**/*.spec.ts' './tests/**/**/*.spec.ts' -g '@ethGetBlockByHash' --exit",
31+
"test:eth-get-block-transaction-count-by-number": "nyc ts-mocha --recursive './tests/**/*.spec.ts' './tests/**/**/*.spec.ts' -g '@ethGetBlockTransactionCountByNumber' --exit",
32+
"test:eth-get-block-transaction-count-by-hash": "nyc ts-mocha --recursive './tests/**/*.spec.ts' './tests/**/**/*.spec.ts' -g '@ethGetBlockTransactionCountByHash' --exit",
33+
"test:eth-get-transaction-by-block-number-and-index": "nyc ts-mocha --recursive './tests/**/*.spec.ts' './tests/**/**/*.spec.ts' -g '@ethGetTransactionByBlockNumberAndIndex' --exit",
34+
"test:eth-get-transaction-by-block-hash-and-index": "nyc ts-mocha --recursive './tests/**/*.spec.ts' './tests/**/**/*.spec.ts' -g '@ethGetTransactionByBlockHashAndIndex' --exit",
35+
"test:eth-get-balance": "nyc ts-mocha --recursive './tests/**/*.spec.ts' './tests/**/**/*.spec.ts' -g '@ethGetBalance' --exit",
36+
"test:eth-get-code": "nyc ts-mocha --recursive './tests/**/*.spec.ts' './tests/**/**/*.spec.ts' -g '@ethGetCode' --exit",
37+
"test:eth-fee-history": "nyc ts-mocha --recursive './tests/**/*.spec.ts' './tests/**/**/*.spec.ts' -g '@ethFeeHistory' --exit",
38+
"test:eth-estimate-gas": "nyc ts-mocha --recursive './tests/**/*.spec.ts' './tests/**/**/*.spec.ts' -g '@ethEstimateGas' --exit",
39+
"test:eth-gas-price": "nyc ts-mocha --recursive './tests/**/*.spec.ts' './tests/**/**/*.spec.ts' -g '@ethGasPrice' --exit",
40+
"test:eth-call": "nyc ts-mocha --recursive './tests/**/*.spec.ts' './tests/**/**/*.spec.ts' -g '@ethCall' --exit",
41+
"test:eth-send-raw-transaction": "nyc ts-mocha --recursive './tests/**/*.spec.ts' './tests/**/**/*.spec.ts' -g '@ethSendRawTransaction' --exit",
42+
"test:eth-get-storage-at": "nyc ts-mocha --recursive './tests/**/*.spec.ts' './tests/**/**/*.spec.ts' -g '@ethGetStorageAt' --exit",
43+
"test:eth-get-transaction-count": "nyc ts-mocha --recursive './tests/**/*.spec.ts' './tests/**/**/*.spec.ts' -g '@ethGetTransactionCount' --exit",
44+
"test:eth-common": "nyc ts-mocha --recursive './tests/**/*.spec.ts' './tests/**/**/*.spec.ts' -g '@ethCommon' --exit",
45+
"test:eth-get-transaction-receipt": "nyc ts-mocha --recursive './tests/**/*.spec.ts' './tests/**/**/*.spec.ts' -g '@ethGetTransactionReceipt' --exit",
46+
"test:eth-get-transaction-by-hash": "nyc ts-mocha --recursive './tests/**/*.spec.ts' './tests/**/**/*.spec.ts' -g '@ethGetTransactionByHash' --exit",
47+
"test:eth-get-logs": "nyc ts-mocha --recursive './tests/**/*.spec.ts' './tests/**/**/*.spec.ts' -g '@ethGetLogs' --exit"
2948
},
3049
"dependencies": {
3150
"@ethersproject/asm": "^5.7.0",

packages/relay/tests/assertions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { JsonRpcError } from '../src';
33
import { EthImpl } from '../src/lib/eth';
44
import { Block, Transaction } from '../src/lib/model';
55
import { numberTo0x } from '../src/formatters';
6+
import { BASE_FEE_PER_GAS_DEFAULT } from './lib/eth/eth-config';
67

78
export default class RelayAssertions {
89
static assertRejection = async (
@@ -123,7 +124,7 @@ export default class RelayAssertions {
123124

124125
static verifyBlockConstants = (block: Block) => {
125126
expect(block.gasLimit).equal(numberTo0x(15000000));
126-
expect(block.baseFeePerGas).equal('0x84b6a5c400');
127+
expect(block.baseFeePerGas).equal(BASE_FEE_PER_GAS_DEFAULT);
127128
expect(block.difficulty).equal(EthImpl.zeroHex);
128129
expect(block.extraData).equal(EthImpl.emptyHex);
129130
expect(block.miner).equal(EthImpl.zeroAddressHex);

packages/relay/tests/helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const ethCallFailing = async (ethImpl, args, block, assertFunc) => {
6868
expect(hasError).to.eq(true);
6969
};
7070

71-
export const ethGetLogsFailing = async (ethImpl, args, assertFunc) => {
71+
export async function ethGetLogsFailing(ethImpl, args, assertFunc) {
7272
let hasError = false;
7373
try {
7474
await ethImpl.getLogs(...args);
@@ -78,7 +78,7 @@ export const ethGetLogsFailing = async (ethImpl, args, assertFunc) => {
7878
assertFunc(error);
7979
}
8080
expect(hasError).to.eq(true);
81-
};
81+
}
8282

8383
export const expectLogData = (res, log, tx) => {
8484
expect(res.address).to.eq(log.address);

0 commit comments

Comments
 (0)