Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gudnuf committed Dec 29, 2024
1 parent 69ee478 commit 5c89404
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/model/Errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class MintOperationError extends Error {
20006: 'Invoice already paid',
20007: 'Quote is expired'
};
super(messages[code] || 'Unknown mint operation error');
super(messages[code] || detail || 'Unknown mint operation error');
this.code = code;
this.detail = detail;
this.name = 'MintOperationError';
Expand Down
3 changes: 2 additions & 1 deletion test/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
ProofState,
Token
} from '../src/model/types/index.js';
import { MintOperationError } from '../src/model/Errors.js';
import ws from 'ws';
import { injectWebSocketImpl } from '../src/ws.js';
import {
Expand Down Expand Up @@ -239,7 +240,7 @@ describe('mint api', () => {
const result = await wallet
.receive(encoded, { privkey: bytesToHex(privKeyAlice) })
.catch((e) => e);
expect(result).toEqual(new Error('no valid signature provided for input.'));
expect(result).toEqual(new MintOperationError(0, 'no valid signature provided for input.'));

const proofs = await wallet.receive(encoded, { privkey: bytesToHex(privKeyBob) });

Expand Down
15 changes: 5 additions & 10 deletions test/request.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { beforeAll, beforeEach, test, describe, expect, afterAll, afterEach } from 'vitest';
import { beforeAll, test, describe, expect, afterAll, afterEach } from 'vitest';
import { CashuMint } from '../src/CashuMint.js';
import { CashuWallet } from '../src/CashuWallet.js';
import { HttpResponse, http } from 'msw';
import { setupServer } from 'msw/node';
import { setGlobalRequestOptions } from '../src/request.js';
import { MeltQuoteResponse } from '../src/model/types/index.js';
import { HttpResponseError, NetworkError, MintOperationError } from '../src/model/Errors';

const mintUrl = 'https://localhost:3338';
Expand Down Expand Up @@ -78,10 +77,7 @@ describe('requests', () => {
const mint = new CashuMint(mintUrl);
server.use(
http.get(mintUrl + '/v1/melt/quote/bolt11/test', () => {
return new HttpResponse(
JSON.stringify({ error: 'Not Found' }),
{ status: 404 }
);
return new HttpResponse(JSON.stringify({ error: 'Not Found' }), { status: 404 });
})
);

Expand All @@ -105,10 +101,9 @@ describe('requests', () => {
const mint = new CashuMint(mintUrl);
server.use(
http.get(mintUrl + '/v1/melt/quote/bolt11/test', () => {
return new HttpResponse(
JSON.stringify({ code: 20003, detail: 'Minting disabled' }),
{ status: 400 }
);
return new HttpResponse(JSON.stringify({ code: 20003, detail: 'Minting disabled' }), {
status: 400
});
})
);

Expand Down

0 comments on commit 5c89404

Please sign in to comment.