Skip to content

Commit

Permalink
adjusted tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Egge21M committed Nov 13, 2024
1 parent 2e53143 commit dc3f507
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
46 changes: 23 additions & 23 deletions test/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ describe('mint api', () => {
const request = await wallet.createMintQuote(1337);
expect(request).toBeDefined();
expect(request.request).toContain('lnbc1337');
const tokens = await wallet.mintProofs(1337, request.quote);
expect(tokens).toBeDefined();
const proofs = await wallet.mintProofs(1337, request.quote);
expect(proofs).toBeDefined();
// expect that the sum of all tokens.proofs.amount is equal to the requested amount
expect(tokens.proofs.reduce((a, b) => a + b.amount, 0)).toBe(1337);
expect(sumProofs(proofs)).toBe(1337);
});
test('get fee for local invoice', async () => {
const mint = new CashuMint(mintUrl);
Expand Down Expand Up @@ -88,7 +88,7 @@ describe('mint api', () => {
const mint = new CashuMint(mintUrl);
const wallet = new CashuWallet(mint, { unit });
const request = await wallet.createMintQuote(100);
const tokens = await wallet.mintProofs(100, request.quote);
const proofs = await wallet.mintProofs(100, request.quote);

// expect no fee because local invoice
const mintQuote = await wallet.createMintQuote(10);
Expand All @@ -100,7 +100,7 @@ describe('mint api', () => {
const quote_ = await wallet.checkMeltQuote(quote.quote);
expect(quote_).toBeDefined();

const sendResponse = await wallet.send(10, tokens.proofs, { includeFees: true });
const sendResponse = await wallet.send(10, proofs, { includeFees: true });
const response = await wallet.meltProofs(quote, sendResponse.send);
expect(response).toBeDefined();
// expect that we have received the fee back, since it was internal
Expand All @@ -126,7 +126,7 @@ describe('mint api', () => {
const mint = new CashuMint(mintUrl);
const wallet = new CashuWallet(mint, { unit });
const request = await wallet.createMintQuote(3000);
const tokens = await wallet.mintProofs(3000, request.quote);
const proofs = await wallet.mintProofs(3000, request.quote);

const meltQuote = await wallet.createMeltQuote(externalInvoice);
const fee = meltQuote.fee_reserve;
Expand All @@ -136,7 +136,7 @@ describe('mint api', () => {
const quote_ = await wallet.checkMeltQuote(meltQuote.quote);
expect(quote_).toBeDefined();

const sendResponse = await wallet.send(2000 + fee, tokens.proofs, { includeFees: true });
const sendResponse = await wallet.send(2000 + fee, proofs, { includeFees: true });
const response = await wallet.meltProofs(meltQuote, sendResponse.send);

expect(response).toBeDefined();
Expand All @@ -163,9 +163,9 @@ describe('mint api', () => {
const mint = new CashuMint(mintUrl);
const wallet = new CashuWallet(mint, { unit });
const request = await wallet.createMintQuote(64);
const tokens = await wallet.mintProofs(64, request.quote);
const proofs = await wallet.mintProofs(64, request.quote);

const sendResponse = await wallet.send(64, tokens.proofs);
const sendResponse = await wallet.send(64, proofs);
expect(sendResponse).toBeDefined();
expect(sendResponse.send).toBeDefined();
expect(sendResponse.keep).toBeDefined();
Expand All @@ -177,9 +177,9 @@ describe('mint api', () => {
const mint = new CashuMint(mintUrl);
const wallet = new CashuWallet(mint, { unit });
const request = await wallet.createMintQuote(100);
const tokens = await wallet.mintProofs(100, request.quote);
const proofs = await wallet.mintProofs(100, request.quote);

const sendResponse = await wallet.send(10, tokens.proofs, { includeFees: false });
const sendResponse = await wallet.send(10, proofs, { includeFees: false });
expect(sendResponse).toBeDefined();
expect(sendResponse.send).toBeDefined();
expect(sendResponse.keep).toBeDefined();
Expand All @@ -192,9 +192,9 @@ describe('mint api', () => {
const mint = new CashuMint(mintUrl);
const wallet = new CashuWallet(mint, { unit });
const request = await wallet.createMintQuote(100);
const tokens = await wallet.mintProofs(100, request.quote);
const proofs = await wallet.mintProofs(100, request.quote);

const sendResponse = await wallet.send(10, tokens.proofs);
const sendResponse = await wallet.send(10, proofs);
const encoded = getEncodedToken({ mint: mintUrl, proofs: sendResponse.send });
const response = await wallet.receive(encoded);
expect(response).toBeDefined();
Expand All @@ -203,8 +203,8 @@ describe('mint api', () => {
const mint = new CashuMint(mintUrl);
const wallet = new CashuWallet(mint, { unit });
const request = await wallet.createMintQuote(64);
const tokens = await wallet.mintProofs(64, request.quote);
const encoded = getEncodedToken({ mint: mintUrl, proofs: tokens.proofs });
const proofs = await wallet.mintProofs(64, request.quote);
const encoded = getEncodedToken({ mint: mintUrl, proofs: proofs });
const response = await wallet.receive(encoded);
expect(response).toBeDefined();
});
Expand All @@ -219,9 +219,9 @@ describe('mint api', () => {
const pubKeyBob = secp256k1.getPublicKey(privKeyBob);

const request = await wallet.createMintQuote(128);
const tokens = await wallet.mintProofs(128, request.quote);
const mintedProofs = await wallet.mintProofs(128, request.quote);

const { send } = await wallet.send(64, tokens.proofs, { pubkey: bytesToHex(pubKeyBob) });
const { send } = await wallet.send(64, mintedProofs, { pubkey: bytesToHex(pubKeyBob) });
const encoded = getEncodedToken({ mint: mintUrl, proofs: send });

const result = await wallet
Expand Down Expand Up @@ -254,7 +254,7 @@ describe('mint api', () => {
const meltRequest = await wallet.createMeltQuote(externalInvoice);
const fee = meltRequest.fee_reserve;
expect(fee).toBeGreaterThan(0);
const response = await wallet.meltProofs(meltRequest, proofs.proofs, {
const response = await wallet.meltProofs(meltRequest, proofs, {
privkey: bytesToHex(privKeyBob)
});
expect(response).toBeDefined();
Expand All @@ -271,7 +271,7 @@ describe('dleq', () => {
const wallet = new CashuWallet(mint);

const mintRequest = await wallet.createMintQuote(3000);
const { proofs } = await wallet.mintProofs(3000, mintRequest.quote);
const proofs = await wallet.mintProofs(3000, mintRequest.quote);

proofs.forEach((p) => {
expect(p).toHaveProperty('dleq');
Expand All @@ -290,7 +290,7 @@ describe('dleq', () => {
}

const mintRequest = await wallet.createMintQuote(8);
const { proofs } = await wallet.mintProofs(8, mintRequest.quote);
const proofs = await wallet.mintProofs(8, mintRequest.quote);

const { keep, send } = await wallet.send(4, proofs, { includeDleq: true });

Expand All @@ -317,7 +317,7 @@ describe('dleq', () => {
}

const mintRequest = await wallet.createMintQuote(8);
const { proofs } = await wallet.mintProofs(8, mintRequest.quote);
const proofs = await wallet.mintProofs(8, mintRequest.quote);

const { keep, send } = await wallet.send(4, proofs, { includeDleq: false });
send.forEach((p) => {
Expand All @@ -337,7 +337,7 @@ describe('dleq', () => {
}

const mintRequest = await wallet.createMintQuote(8);
let { proofs } = await wallet.mintProofs(8, mintRequest.quote);
let proofs = await wallet.mintProofs(8, mintRequest.quote);

// strip dleq
proofs = proofs.map((p) => {
Expand All @@ -357,7 +357,7 @@ describe('dleq', () => {
}

const mintRequest = await wallet.createMintQuote(8);
let { proofs } = await wallet.mintProofs(8, mintRequest.quote);
let proofs = await wallet.mintProofs(8, mintRequest.quote);

// alter dleq signature
proofs.forEach((p) => {
Expand Down
2 changes: 1 addition & 1 deletion test/wallet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ describe('requestTokens', () => {
});
const wallet = new CashuWallet(mint, { unit });

const { proofs } = await wallet.mintProofs(1, '');
const proofs = await wallet.mintProofs(1, '');

expect(proofs).toHaveLength(1);
expect(proofs[0]).toMatchObject({ amount: 1, id: '009a1f293253e41e' });
Expand Down

0 comments on commit dc3f507

Please sign in to comment.