Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: unit tests failing in CI #2258

Merged
merged 8 commits into from
Jun 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fixes tests that were not being executed due to error
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
  • Loading branch information
konstantinabl committed Jun 3, 2024
commit 327ed58b27e12daa9bb7ae201abfd9dbd4b68ed6
2 changes: 1 addition & 1 deletion packages/relay/src/lib/precheck.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*-
/* -
*
* Hedera JSON RPC Relay
*
39 changes: 21 additions & 18 deletions packages/relay/tests/lib/precheck.spec.ts
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
*
*/

import { Assertion, expect } from 'chai';
import { expect } from 'chai';
import { Registry } from 'prom-client';
import { Hbar, HbarUnit } from '@hashgraph/sdk';
const registry = new Registry();
@@ -450,25 +450,28 @@ describe('Precheck', async function () {
});

describe('account', async function () {
const defaultNonce = 3;
const defaultTx = {
value: oneTinyBar,
gasPrice: defaultGasPrice,
chainId: defaultChainId,
nonce: defaultNonce,
from: mockData.accountEvmAddress,
};
let defaultNonce, defaultTx, signed, parsedTx, mirrorAccount, wallet;
before(async () => {
defaultNonce = 3;
defaultTx = {
value: oneTinyBar,
gasPrice: defaultGasPrice,
chainId: defaultChainId,
nonce: defaultNonce,
};

const signed = await signTransaction(defaultTx);
const parsedTx = ethers.Transaction.from(signed);
wallet = ethers.Wallet.createRandom();
signed = await wallet.signTransaction({ ...defaultTx, from: wallet.address });
parsedTx = ethers.Transaction.from(signed);

const mirrorAccount = {
evm_address: mockData.accountEvmAddress,
ethereum_nonce: defaultNonce,
};
mirrorAccount = {
evm_address: parsedTx.from,
ethereum_nonce: defaultNonce,
};
});

it(`should fail for missing account`, async function () {
mock.onGet(`accounts/${mockData.accountEvmAddress}${limitOrderPostFix}`).reply(404, mockData.notFound);
mock.onGet(`accounts/${parsedTx.from}${limitOrderPostFix}`).reply(404, mockData.notFound);

try {
await precheck.verifyAccount(parsedTx);
@@ -477,12 +480,12 @@ describe('Precheck', async function () {
expect(e).to.exist;
expect(e.code).to.eq(-32001);
expect(e.name).to.eq('Resource not found');
expect(e.message).to.contain(mockData.accountEvmAddress);
expect(e.message).to.contain(parsedTx.from);
}
});

it(`should not fail for matched account`, async function () {
mock.onGet(`accounts/${mockData.accountEvmAddress}${limitOrderPostFix}`).reply(200, mirrorAccount);
mock.onGet(`accounts/${parsedTx.from}?transactions=false`).reply(200, mirrorAccount);
const account = await precheck.verifyAccount(parsedTx);

expect(account.ethereum_nonce).to.eq(defaultNonce);