Skip to content

Commit

Permalink
chore: resolve comments
Browse files Browse the repository at this point in the history
Signed-off-by: nikolay <[email protected]>
  • Loading branch information
natanasow committed Nov 27, 2024
1 parent bc8267d commit 59dd3be
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
12 changes: 7 additions & 5 deletions packages/relay/src/lib/eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1593,6 +1593,13 @@ export class EthImpl implements Eth {
}

if (e instanceof SDKClientError) {
if (e.nodeAccountId) {

Check warning on line 1596 in packages/relay/src/lib/eth.ts

View check run for this annotation

Codecov / codecov/patch

packages/relay/src/lib/eth.ts#L1596

Added line #L1596 was not covered by tests
// Log the target node account ID, right now, it's populated only for MaxAttemptsOrTimeout error
this.logger.info(
`${requestDetails.formattedRequestId} Transaction failed to execute against node with id: ${e.nodeAccountId}`,
);
}

this.hapiService.decrementErrorCounter(e.statusCode);
if (e.status.toString() === constants.TRANSACTION_RESULT_STATUS.WRONG_NONCE) {
const mirrorNodeGetContractResultRetries = this.mirrorNodeClient.getMirrorNodeRequestRetryCount();
Expand Down Expand Up @@ -1698,11 +1705,6 @@ export class EthImpl implements Eth {
} catch (e: any) {
if (e instanceof SDKClientError && (e.isConnectionDropped() || e.isTimeoutExceeded())) {
submittedTransactionId = e.transactionId || '';

// Log the target node account ID, right now, it's populated only for MaxAttemptsOrTimeout error
this.logger.info(
`${requestDetails.formattedRequestId} Transaction failed to execute against node with id: ${e.nodeAccountId}`
);
}

sendRawTransactionError = e;
Expand Down
9 changes: 8 additions & 1 deletion packages/relay/tests/lib/errors/SDKClientError.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
*
*/

import { expect } from 'chai';
import { Status } from '@hashgraph/sdk';
import { expect } from 'chai';

import { SDKClientError } from '../../../src/lib/errors/SDKClientError'; // Update the path to point to the SDKClientError file

describe('SDKClientError', () => {
Expand Down Expand Up @@ -115,4 +116,10 @@ describe('SDKClientError', () => {
expect(error.statusCode).to.equal(invalidStatus._code);
expect(error.isValidNetworkError()).to.be.true;
});

it('should be able to get nodeAccountId', () => {
const nodeId = '0.0.3';
const error = new SDKClientError({}, undefined, undefined, nodeId);
expect(error.nodeAccountId).to.equal(nodeId);
});
});

0 comments on commit 59dd3be

Please sign in to comment.