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(core): tx error mapping fix #210

Merged
merged 1 commit into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions packages/core/src/Cardano/types/TxSubmissionErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const TxSubmissionErrors = {
ExpiredUtxoError: TxSubmission.errors.ExpiredUtxo.Error,
ExtraDataMismatchError: TxSubmission.errors.ExtraDataMismatch.Error,
ExtraRedeemersError: TxSubmission.errors.ExtraRedeemers.Error,
ExtraScriptWitnessesError: TxSubmission.errors.ExtraScriptWitnesses.Error,
FeeTooSmallError: TxSubmission.errors.FeeTooSmall.Error,
InsufficientFundsForMirError: TxSubmission.errors.InsufficientFundsForMir.Error,
InsufficientGenesisSignaturesError: TxSubmission.errors.InsufficientGenesisSignatures.Error,
Expand Down
10 changes: 10 additions & 0 deletions packages/core/test/Cardano/types/TxSubmissionErrors.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Cardano } from '../../../src';
import { TxSubmission } from '@cardano-ogmios/client';
import { TxSubmissionErrors } from '../../../dist/Cardano';

describe('Cardano/types/TxSuubmissionErrors', () => {
test('TxSubmissionError can be narrowed down with "instanceof"', () => {
Expand All @@ -7,4 +9,12 @@ describe('Cardano/types/TxSuubmissionErrors', () => {
});
expect(error).toBeInstanceOf(Cardano.TxSubmissionErrors.FeeTooSmallError);
});
test('maps all errors from Ogmios', () => {
const ogmiosErrors = Object.keys(TxSubmission.errors).sort();
const sdkErrors = Object.keys(TxSubmissionErrors)
.filter((e) => e !== 'UnknownTxSubmissionError')
.map((e) => e.slice(0, Math.max(0, e.length - 5))) // drop 'Error' suffix
.sort();
expect(sdkErrors).toEqual(ogmiosErrors);
});
});