Skip to content

Commit

Permalink
Add the same tests as PR #64 (#67)
Browse files Browse the repository at this point in the history
* feat: add integration tests to actions

* fix: nodejs dependency installation

* fix: path in dependency installation for client

* fix: linking of dependency mercurynodejslib

* fix: port issue with mercury server

* fix: host of mercury server

* debug: services on actions

* debug: mercury server availability

* debug: mercury server through curl

* debug: mercury server though curl

* debug: running containers

* debug: mercury server through exec and curl

* debug: mercury server through curl

* debug: test with mercurylayer.com

* fix: mercurylayer api url

* fix: remove mercury logs

* feat: add test for iterative self transfer

* debug: mercury server through curl

* debug: mercury server container

* debug: mercury server

* debug: list all containers

* debug: mercury server through container id

* debug: fix mercury server container name

* debug: docker logs

* debug: increase wait time for service to be ready

* debug: sql error

* debug: mercury server post request

* debug: electrum client

* debug: test failure

* debug: post request /deposit/init/pod

* debug: internal server error for mercury server

* fix: expose port for ssl of electrum server

* debug: electrum server

* debug: bitcoin core

* fix: increase wait time to service ready for bitcoin core

* fix: command args for bitcoin core

* debug: enclave

* debug: enclave /get_public_key

* fix: add port for enclave to docker-compose

* debug: get public key from enclave

* debug: use lockbox url of testnet

* fix: enclave dockerfile cmd

* fix: cmd for enclave server

* debug: deposit msg

* debug: depositMsg for /deposit/init/pod

* debug: statechain_id in pod_deposit

* debug: enclave logs

* debig: network connectivity between containers

* debug: lockbox url

* fix: mercury server in docker compose

* fix: dockerfile location in docker compose

* fix: dockerfile location in mercury server docker compose

* fix: lockbox env name

* fix: env name for lockbox

* feat: add deposit using bitcoin-cli

* debug: bitcoin-cli for deposit

* fix: bitcoin-cli cmd execution

* fix: create wallet before send to address

* fix: address in deposit

* fix: address in generatetoaddress

* fix: add rpcfee field to sendtoaddress cmd

* fix: increase rpcfee

* fix: add fallbackfee to bitcoin core

* fix: generate block after deposit

* fix: increase generate block to confirmation target

* fix: change withdraw address to regtest

* fix: adjust sleep time for services to be ready

* debug: wallet database deletion

* fix: change wallet name to fix sql error

* fix: db lock error

* fix: path in removeDatabase fn

* fix: databaseFile variable

* fix: blockheight from electrum server

* fix: getElectrumClient import

* debug: db file location

* debug: find wallet.db file

* fix: removeDb fn

* fix: wallet names in tests

* fix: lockheight of mercury server

* fix: initial blocks generation

* fix: path import

* fix: path in removeDatabase fn

* fix: path import in removeDatabase fn

* fix: unit test for iterative self transfer

* fix: locktime for mercury server

* fix: lockheight_init for mercury server

* debug: lockheight_init for mercury server

* fix: lh_decrement and lockheight_init

* chore: add test for transfer sender after transfer receiver

* chore: refactor depositCoin

* chore: add test for deposit and transfer

* fix: token generation

* fix: assert error

* fix: typos for wallet name

* fix: variable type

* chore: add test for interruption of transfer-send in sign first

* fix: increase block generation for deposit coin step

* fix: generateBlock

* fix: wait for coin confirmed

* fix: increase block after coin deposit

* chore: add test for transferSend signSecond interruption

* fix: block unblock port of mercury server for test

* debug: network name for mercury server

* fix: disconnect network for test

* fix: enclose post request of sign into try catch

* fix: enclose transfer/sender request in try catch

* fix: get_new_x1 fn

* fix: error handling for mercury server post request

* fix: variable error

* fix: handle the case if response undefined

* fix: error handling for signFirst and signSecond

* fix: assert errors in test

* fix: add test for electrum unavailability

* chore: add test for transfer receive for electrum unavailability

* chore: add test for transfer receive for mercury server unavailability

* fix: mercury and electrum unavailability tests

* debug: coin deposition

* debug: coin deposit verification

* debug: listStatecoins

* fix: get_new_x1

* fix: add generateBlock if coin status in mempool

* fix: generateBlock for coins in mempool

* debug: fee rate

* debug: coin confirmation

* debug: coin status

* debug: checkDeposit

* fix: typos

* debug: network disconnect

* debug: fee_rate

* debug: blockheight

* fix: getElectrumClient error

* fix: ElectrumCli import

* debug: running all tests

* fix: remove generateBlock if coin waiting to be confirmed

* fix: replace electrumx with electrs

* fix: electrs volume mount

* fix: get_new_x1

* fix: add entrypoint file for electrs

* fix: add volume to docker compose

* fix: electrs configs

* fix: add generateBlock if coin stuck in mempool

* fix: signSecond test for interruption

* fix: error message for electrs unavailability

* fix: assertions for server unavailability

* fix: exit test on completion

* fix: tear down of docker compose

* fix: remove npm link

* fix: replace lockbox_url to enclaves in env variables

* fix: assert statement for mercury server unavailability

* fix: remove build.yml from actions

* chore: remove unused imports and logs

* fix: add regtest and signet to config

* fix: getElectrumClient import

---------

Co-authored-by: DhananjayPurohit <[email protected]>
  • Loading branch information
ssantos21 and DhananjayPurohit authored Jul 1, 2024
1 parent dc40ef1 commit 7fd81b2
Show file tree
Hide file tree
Showing 15 changed files with 1,093 additions and 109 deletions.
62 changes: 0 additions & 62 deletions .github/workflows/build.yml

This file was deleted.

117 changes: 117 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Integration Tests

on:
push:
branches:
- dev
pull_request:
branches:
- dev

jobs:
test:
runs-on: ubuntu-latest

services:
docker:
image: docker:19.03.12
options: --privileged
ports:
- 5432:5432
- 18443:18443
- 50002:50002
- 50001:50001
- 8000:8000
- 18080:18080
volumes:
- /var/run/docker.sock:/var/run/docker.sock

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Docker Compose
run: |
docker-compose -f docker-compose-test.yml up --build -d
- name: Wait for services to be ready
run: |
sleep 80 # Adjust time as necessary for services to initialize
- name: Verify Bitcoin daemon Service with Curl
run: |
container_id=$(docker ps -qf "name=mercurylayer_bitcoind_1")
echo "Container ID: $container_id"
docker logs $container_id
wallet_name="new_wallet"
docker exec $container_id bitcoin-cli -regtest -rpcuser=user -rpcpassword=pass createwallet $wallet_name
address=$(docker exec $container_id bitcoin-cli -regtest -rpcuser=user -rpcpassword=pass getnewaddress $wallet_name)
echo "New Wallet Address: $address"
docker exec $container_id bitcoin-cli -regtest -rpcuser=user -rpcpassword=pass generatetoaddress 101 "$address"
docker exec $container_id bitcoin-cli -regtest -rpcuser=user -rpcpassword=pass sendtoaddress bcrt1pcngfxjdkf4r2h26k52dh5nunxg8m68uf4lkfhmfjvjj6agfkm5jqmftw4e 0.0001
- name: Verify ElectrumX Service with Curl
run: |
container_id=$(docker ps -qf "name=mercurylayer_electrs_1")
echo "Container ID: $container_id"
docker logs $container_id
- name: Verify Enclave Service with Curl
run: |
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") \
curl -X POST http://0.0.0.0:18080/get_public_key \
-H "Content-Type: application/json" \
-d '{"statechain_id":"550e8400e29b41d4a716446655440000"}'
docker logs $(docker ps -qf "name=enclave")
- name: Check connectivity between containers
run: |
# Get container IDs
enclave_container=$(docker ps -qf "name=mercurylayer_enclave-sgx_1")
mercury_container=$(docker ps -qf "name=mercurylayer_mercury_1")
# Check if mercurylayer_mercury_1 can reach mercurylayer_enclave-sgx_1
docker exec $mercury_container curl -v http://mercurylayer_enclave-sgx_1:18080/get_public_key \
-H "Content-Type: application/json" \
-d '{"statechain_id":"550e8400e29b41d4a716446655440000"}'
# Alternatively, using IP address if service name resolution fails
enclave_ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $enclave_container)
docker exec $mercury_container curl -v http://$enclave_ip:18080/get_public_key \
-H "Content-Type: application/json" \
-d '{"statechain_id":"550e8400e29b41d4a716446655440000"}'
docker inspect mercurylayer_mercury_1
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20.12.2'

- name: Install Node.js dependencies for client
run: |
cd clients/apps/nodejs
npm install
- name: Install Node.js dependencies for lib
run: |
cd clients/libs/nodejs
npm install
- name: Run Client-Side Tests
run: |
cd clients/apps/nodejs
node test_basic_workflow2.js
- name: Tear Down
run: |
docker-compose -f docker-compose-test.yml down
10 changes: 5 additions & 5 deletions clients/apps/nodejs/config/default.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"statechainEntity": "http://127.0.0.1:8000",
"statechainEntity": "http://0.0.0.0:8000",
"__statechainEntity": "http://j23wevaeducxuy3zahd6bpn4x76cymwz2j3bdixv7ow4awjrg5p6jaid.onion",
"_statechainEntity": "http://45.76.136.11:8500/",
"__electrumServer": "tcp://signet-electrumx.wakiyamap.dev:50001",
"electrumServer": "ssl://mempool.space:60602",
"__electrumServer": "tcp://0.0.0.0:50001",
"electrumServer": "tcp://0.0.0.0:50001",
"electrumType": "electrs",
"_electrumServer": "tcp://localhost:50001",
"network": "signet",
"_electrumServer": "tcp://0.0.0.0:50001",
"network": "regtest",
"feeRateTolerance": 5,
"databaseFile": "wallet.db",
"confirmationTarget": 2,
Expand Down
16 changes: 16 additions & 0 deletions clients/apps/nodejs/config/regtest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"statechainEntity": "http://0.0.0.0:8000",
"__statechainEntity": "http://j23wevaeducxuy3zahd6bpn4x76cymwz2j3bdixv7ow4awjrg5p6jaid.onion",
"_statechainEntity": "http://45.76.136.11:8500/",
"__electrumServer": "tcp://0.0.0.0:50001",
"electrumServer": "tcp://0.0.0.0:50001",
"electrumType": "electrs",
"_electrumServer": "tcp://0.0.0.0:50001",
"network": "regtest",
"feeRateTolerance": 5,
"databaseFile": "wallet.db",
"confirmationTarget": 2,
"_torProxy": "socks5h://localhost:9050",
"torProxy": null,
"maxFeeRate": 1
}
16 changes: 16 additions & 0 deletions clients/apps/nodejs/config/signet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"statechainEntity": "http://127.0.0.1:8000",
"__statechainEntity": "http://j23wevaeducxuy3zahd6bpn4x76cymwz2j3bdixv7ow4awjrg5p6jaid.onion",
"_statechainEntity": "http://45.76.136.11:8500/",
"__electrumServer": "tcp://signet-electrumx.wakiyamap.dev:50001",
"electrumServer": "ssl://mempool.space:60602",
"electrumType": "electrs",
"_electrumServer": "tcp://localhost:50001",
"network": "signet",
"feeRateTolerance": 5,
"databaseFile": "wallet.db",
"confirmationTarget": 2,
"_torProxy": "socks5h://localhost:9050",
"torProxy": null,
"maxFeeRate": 1
}
Loading

0 comments on commit 7fd81b2

Please sign in to comment.