Skip to content

Commit

Permalink
fix: adjust sleep time for services to be ready
Browse files Browse the repository at this point in the history
  • Loading branch information
DhananjayPurohit committed Jun 4, 2024
1 parent b1daf77 commit 03c9048
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 16 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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") \
Expand Down
49 changes: 47 additions & 2 deletions clients/apps/nodejs/test_basic_workflow2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);

Expand All @@ -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);
Expand Down Expand Up @@ -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);

Expand All @@ -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);
Expand Down

0 comments on commit 03c9048

Please sign in to comment.