Skip to content

Commit

Permalink
test: added UT
Browse files Browse the repository at this point in the history
Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
  • Loading branch information
quiet-node committed May 14, 2024
1 parent 5e8858d commit beea682
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/relay/src/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const formatContractResult = (cr: any) => {
const commonFields = {
blockHash: toHash32(cr.block_hash),
blockNumber: nullableNumberTo0x(cr.block_number),
chainId: cr.chain_id === '0x' ? undefined : cr.chain_id,
chainId: cr.chain_id === EMPTY_HEX ? undefined : cr.chain_id,
from: cr.from.substring(0, 42),
gas: nanOrNumberTo0x(cr.gas_used),
gasPrice: toNullIfEmptyHex(cr.gas_price),
Expand Down
5 changes: 5 additions & 0 deletions packages/relay/tests/lib/formatters.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ describe('Formatters', () => {
expect(formattedResult.yParity).to.equal('0x0');
expect(formattedResult.value).to.equal('0x0');
});

it('Should not include chainId field for legacy EIP155 transaction (tx.chainId=0x0)', () => {
const formattedResult: any = formatContractResult({ ...contractResult, chain_id: '0x' });
expect(formattedResult.chainId).to.be.undefined;
});
});

describe('prepend0x', () => {
Expand Down

0 comments on commit beea682

Please sign in to comment.