diff --git a/clients/apps/nodejs/test/tb04-simple-lightning-latch.mjs b/clients/apps/nodejs/test/tb04-simple-lightning-latch.mjs index 1d296b3b..93631765 100644 --- a/clients/apps/nodejs/test/tb04-simple-lightning-latch.mjs +++ b/clients/apps/nodejs/test/tb04-simple-lightning-latch.mjs @@ -3,7 +3,7 @@ import client_config from '../client_config.js'; import mercurynodejslib from 'mercurynodejslib'; import { CoinStatus } from 'mercurynodejslib/coin_enum.js'; import crypto from 'crypto'; -import { createWallet, removeDatabase, getnewaddress, generateBlock, depositCoin } from './test-utils.mjs'; +import { createWallet, depositCoin, generateInvoice } from '../test_utils.js'; describe('TB04 - Lightning Latch', function() { this.timeout(30000); @@ -312,6 +312,8 @@ describe('TB04 - Lightning Latch', function() { const paymentHash = await mercurynodejslib.paymentHash(clientConfig, wallet_1_name, coin.statechain_id); + const invoice = await generateInvoice(paymentHash.hash, amount); + const transferAddress = await mercurynodejslib.newTransferAddress(clientConfig, wallet_2_name, null); await mercurynodejslib.transferSend(clientConfig, wallet_1_name, coin.statechain_id, transferAddress.transfer_receive, false, paymentHash.batchId); diff --git a/clients/apps/nodejs/test_utils.js b/clients/apps/nodejs/test_utils.js index e6972cc0..211a3022 100644 --- a/clients/apps/nodejs/test_utils.js +++ b/clients/apps/nodejs/test_utils.js @@ -100,6 +100,17 @@ const connectElectr = async () => { await exec("docker network connect mercurylayer_default mercurylayer_electrs_1"); } +async function generateInvoice(paymentHash, amountInSats) { + + const generateInvoiceCommand = `docker exec $(docker ps -qf "name=mercurylayer_alice_1") lncli addinvoice ${paymentHash} --amt ${amountInSats}`; + const { stdout, stderr } = await exec(generateInvoiceCommand); + if (stderr) { + console.error('Error:', stderr); + return null; + } + return stdout.trim(); +} + module.exports = { removeDatabase, getDatabase, @@ -111,5 +122,6 @@ module.exports = { connectElectr, disconnectElectr, connectMercuryServer, - disconnectMercuryServer + disconnectMercuryServer , + generateInvoice };