diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1faf9161..5e0ab794 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -164,17 +164,17 @@ jobs: run: | cd clients/libs/web npm install - - name: Run web client Tests - run: | - cd clients/tests/web - sudo chmod -R 755 ./data_bitcoin_regtest - npx vitest --browser.name=chromium --browser.headless - name: Run Client-Side Tests run: | cd clients/apps/nodejs node test_basic_workflow2.js node test_atomic_swap.js mocha ./test/tb04-simple-lightning-latch.mjs --exit + - name: Run web client Tests + run: | + cd clients/tests/web + sudo chmod -R 755 ./data_bitcoin_regtest + npx vitest --browser.name=chromium --browser.headless - name: Tear Down run: | docker-compose -f docker-compose-test.yml down diff --git a/clients/libs/web/main.js b/clients/libs/web/main.js index bf7cf692..6418940f 100644 --- a/clients/libs/web/main.js +++ b/clients/libs/web/main.js @@ -132,7 +132,7 @@ const verifyInvoice = async (clientConfig, batchId, paymentRequest) => { const decodedInvoice = await decodeInvoice(paymentRequest); let paymentHash = await getPaymentHash(clientConfig, batchId); - console.log("Decoded Invoice: ", decodeInvoice); + console.log("Decoded Invoice: ", decodedInvoice); return paymentHash === decodedInvoice.tagsObject.payment_hash; } diff --git a/clients/tests/web/server-regtest.cjs b/clients/tests/web/server-regtest.cjs index de77656b..fe19506e 100644 --- a/clients/tests/web/server-regtest.cjs +++ b/clients/tests/web/server-regtest.cjs @@ -47,9 +47,9 @@ const payInvoice = async (paymentRequest) => { await exec(payInvoiceCommand); } -const payHoldInvoice = (paymentRequest) => { +const payHoldInvoice = async (paymentRequest) => { const payInvoiceCommand = `docker exec $(docker ps -qf "name=mercurylayer-bob-1") lncli -n regtest payinvoice --force ${paymentRequest}`; - exec(payInvoiceCommand); + await exec(payInvoiceCommand); } const settleInvoice = async (preimage) => { @@ -135,7 +135,7 @@ app.post('/pay_holdinvoice', async (req, res) => { console.log(`Paying invoice ...`) try { - payHoldInvoice(paymentRequest); + await payHoldInvoice(paymentRequest); } catch (error) { console.log(error.message); res.status(500).send({ message: error.message }) diff --git a/clients/tests/web/test/tb04-simple-lightning-latch.test.js b/clients/tests/web/test/tb04-simple-lightning-latch.test.js index 7f62a4ea..3b0ce3c6 100644 --- a/clients/tests/web/test/tb04-simple-lightning-latch.test.js +++ b/clients/tests/web/test/tb04-simple-lightning-latch.test.js @@ -448,9 +448,9 @@ describe('TB04 - Receiver tries to transfer invoice amount to another invoice be const paymentHash = await mercuryweblib.paymentHash(clientConfig, wallet1.name, statechainId); const invoice = await generateInvoice(paymentHash.hash, amount); - console.log(invoice); await payHoldInvoice(invoice.payment_request); + console.log(invoice); let transferAddress = await mercuryweblib.newTransferAddress(wallet2.name); @@ -480,7 +480,7 @@ describe('TB04 - Receiver tries to transfer invoice amount to another invoice be expect(hashPreImage).toEqual(paymentHash.hash); - const paymentHashSecond = "f768c404215f9fb5731c32c00fe7a057fc181d7695de447b334380d90674db34" + const paymentHashSecond = "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" const invoiceSecond = await generateInvoice(paymentHashSecond, amount); try { @@ -696,7 +696,7 @@ describe('Coin receiver creates a non hold invoice, and sends to sender (i.e. an const paymentHash = await mercuryweblib.paymentHash(clientConfig, wallet1.name, statechainId); - const paymentHashSecond = "ddddf1cd1e2ca1986e29b20401b555fbaa4a8502626a7afc37c47ae06a46d918" + const paymentHashSecond = "1f1e1d1c1b1a19181716151413121110100f0e0d0c0b0a09080706050403020100" const invoiceSecond = await generateInvoice(paymentHashSecond, amount); const isInvoiceValid = await mercuryweblib.verifyInvoice(clientConfig, paymentHash.batchId, invoiceSecond.payment_request);