diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a75be86a..014b8889 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -37,20 +37,7 @@ jobs: docker-compose -f docker-compose-test.yml up --build -d - name: Wait for services to be ready run: | - sleep 60 # Adjust time as necessary for services to initialize - - name: Verify Mercury Service with Curl - run: | - container_id=$(docker ps -qf "name=mercurylayer_mercury_1") - echo "Container ID: $container_id" - docker logs $container_id - docker exec $container_id \ - curl -X POST http://0.0.0.0:8000/deposit/init/pod \ - -H "Content-Type: application/json" \ - -d '{ - "auth_key": "f461775606ffc86e3f6e3115ff425d371b0f68cc59ad8cf71375c0e08c2ee8e9", - "token_id": "616f505d-b94c-45cf-b251-833e4fa14fa1", - "signed_token_id": "7401ac1f792f56d5357997f9846b5045656758f4afece4c51b73472bd338e97da3d167733502cf62d77c1169bd89bfaa0c9c5fcc26d75190e7a3a3fd2f83ae0a" - }' + sleep 80 # Adjust time as necessary for services to initialize - name: Verify Bitcoin core Service with Curl run: | container_id=$(docker ps -qf "name=mercurylayer_bitcoin_1") @@ -72,6 +59,19 @@ jobs: container_id=$(docker ps -qf "name=mercurylayer_enclave-sgx_1") echo "Container ID: $container_id" docker logs $container_id + - name: Verify Mercury Service with Curl + run: | + container_id=$(docker ps -qf "name=mercurylayer_mercury_1") + echo "Container ID: $container_id" + docker logs $container_id + docker exec $container_id \ + curl -X POST http://0.0.0.0:8000/deposit/init/pod \ + -H "Content-Type: application/json" \ + -d '{ + "auth_key": "f461775606ffc86e3f6e3115ff425d371b0f68cc59ad8cf71375c0e08c2ee8e9", + "token_id": "616f505d-b94c-45cf-b251-833e4fa14fa1", + "signed_token_id": "7401ac1f792f56d5357997f9846b5045656758f4afece4c51b73472bd338e97da3d167733502cf62d77c1169bd89bfaa0c9c5fcc26d75190e7a3a3fd2f83ae0a" + }' - name: Get Public Key run: | docker exec $(docker ps -qf "name=enclave") \ diff --git a/clients/apps/nodejs/test_basic_workflow2.js b/clients/apps/nodejs/test_basic_workflow2.js index 2d3daa69..63b8cd7d 100644 --- a/clients/apps/nodejs/test_basic_workflow2.js +++ b/clients/apps/nodejs/test_basic_workflow2.js @@ -125,6 +125,21 @@ async function walletTransfersToItselfTillLocktimeReachesBlockHeightAndWithdraw( deposit_info["amount"] = amount; console.log("deposit_coin: ", deposit_info); + const amountInBtc = 0.0001; + + // Sending Bitcoin using bitcoin-cli + try { + const sendBitcoinCommand = `docker exec $(docker ps -qf "name=mercurylayer_bitcoin_1") bitcoin-cli -regtest -rpcuser=user -rpcpassword=pass sendtoaddress ${deposit_info.deposit_address} ${amountInBtc}`; + exec(sendBitcoinCommand); + console.log(`Sent ${amountInBtc} BTC to ${deposit_info.deposit_address}`); + const generateBlockCommand = `docker exec $(docker ps -qf "name=mercurylayer_bitcoin_1") bitcoin-cli -regtest -rpcuser=user -rpcpassword=pass generatetoaddress ${clientConfig.confirmationTarget} "bcrt1qgh48u8aj4jvjkalc28lqujyx2wveck4jsm59x9"`; + exec(generateBlockCommand); + console.log(`Generated a block`); + } catch (error) { + console.error('Error sending Bitcoin:', error.message); + return; + } + let coin = undefined; while (!coin) { @@ -175,7 +190,7 @@ async function walletTransfersToItselfTillLocktimeReachesBlockHeightAndWithdraw( console.log("Updated coin: ", coin); } - let withdraw_address = "tb1qwrujs6f4gyexsextpf9p50smjtht7p7ypknteu"; + let withdraw_address = "bcrt1qgh48u8aj4jvjkalc28lqujyx2wveck4jsm59x9"; let txid = await mercurynodejslib.withdrawCoin(clientConfig, wallet_name, coin.statechain_id, withdraw_address, null); @@ -200,6 +215,21 @@ async function walletTransfersToAnotherAndBroadcastsBackupTx(clientConfig, walle deposit_info["amount"] = amount; console.log("deposit_coin: ", deposit_info); + const amountInBtc = 0.0001; + + // Sending Bitcoin using bitcoin-cli + try { + const sendBitcoinCommand = `docker exec $(docker ps -qf "name=mercurylayer_bitcoin_1") bitcoin-cli -regtest -rpcuser=user -rpcpassword=pass sendtoaddress ${deposit_info.deposit_address} ${amountInBtc}`; + exec(sendBitcoinCommand); + console.log(`Sent ${amountInBtc} BTC to ${deposit_info.deposit_address}`); + const generateBlockCommand = `docker exec $(docker ps -qf "name=mercurylayer_bitcoin_1") bitcoin-cli -regtest -rpcuser=user -rpcpassword=pass generatetoaddress ${clientConfig.confirmationTarget} "bcrt1qgh48u8aj4jvjkalc28lqujyx2wveck4jsm59x9"`; + exec(generateBlockCommand); + console.log(`Generated a block`); + } catch (error) { + console.error('Error sending Bitcoin:', error.message); + return; + } + let coin = undefined; console.log("coin: ", coin); @@ -236,7 +266,7 @@ async function walletTransfersToAnotherAndBroadcastsBackupTx(clientConfig, walle assert(received_statechain_ids.length > 0); assert(received_statechain_ids[0] == coin.statechain_id); - let withdraw_address = "tb1qwrujs6f4gyexsextpf9p50smjtht7p7ypknteu"; + let withdraw_address = "bcrt1qgh48u8aj4jvjkalc28lqujyx2wveck4jsm59x9"; let txid = await mercurynodejslib.broadcastBackupTransaction(clientConfig, wallet_2_name, coin.statechain_id, withdraw_address, null); @@ -259,6 +289,21 @@ async function depositAndRepeatSend(clientConfig, wallet_1_name) { deposit_info["amount"] = amount; console.log("deposit_coin: ", deposit_info); + const amountInBtc = 0.0001; + + // Sending Bitcoin using bitcoin-cli + try { + const sendBitcoinCommand = `docker exec $(docker ps -qf "name=mercurylayer_bitcoin_1") bitcoin-cli -regtest -rpcuser=user -rpcpassword=pass sendtoaddress ${deposit_info.deposit_address} ${amountInBtc}`; + exec(sendBitcoinCommand); + console.log(`Sent ${amountInBtc} BTC to ${deposit_info.deposit_address}`); + const generateBlockCommand = `docker exec $(docker ps -qf "name=mercurylayer_bitcoin_1") bitcoin-cli -regtest -rpcuser=user -rpcpassword=pass generatetoaddress ${clientConfig.confirmationTarget} "bcrt1qgh48u8aj4jvjkalc28lqujyx2wveck4jsm59x9"`; + exec(generateBlockCommand); + console.log(`Generated a block`); + } catch (error) { + console.error('Error sending Bitcoin:', error.message); + return; + } + let coin = undefined; console.log("coin: ", coin);