Skip to content

Commit

Permalink
Fixed odd error when sending transaction to the chain fails
Browse files Browse the repository at this point in the history
  • Loading branch information
marcvelmer committed Sep 4, 2024
1 parent 320a3cc commit d6449d1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,13 @@ export abstract class API {
case 5000:
throw new ErrVochainEmptyReply(err['error']);
case 5001:
try {
return API.isVochainError(err['error']);
} catch (e) {
if (!(e instanceof ErrVochainReturnedErrorCode)) {
throw e;
}
}
throw new ErrVochainSendTxFailed(err['error']);
case 5002:
throw new ErrVochainGetTxFailed(err['error']);
Expand Down
4 changes: 2 additions & 2 deletions test/api/chain.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { ChainAPI, ErrAPI, ErrTransactionNotFound } from '../../src';
import { ChainAPI, ErrCantParseHexString, ErrTransactionNotFound } from '../../src';
// @ts-ignore
import { URL } from './util/client.params';

describe('Chain API tests', () => {
it('should throw when asking for an invalid transaction', async () => {
await expect(async () => {
await ChainAPI.txInfo(URL, '0xReallyBad');
}).rejects.toThrow(ErrAPI);
}).rejects.toThrow(ErrCantParseHexString);
}, 5000);
it('should throw when asking for a non existent transaction', async () => {
await expect(async () => {
Expand Down

0 comments on commit d6449d1

Please sign in to comment.