Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/integration tests on actions #62

Closed
wants to merge 115 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
5108125
feat: add integration tests to actions
DhananjayPurohit May 30, 2024
758bf73
fix: nodejs dependency installation
DhananjayPurohit May 30, 2024
8603248
fix: path in dependency installation for client
DhananjayPurohit May 30, 2024
b047a39
fix: linking of dependency mercurynodejslib
DhananjayPurohit May 30, 2024
a610913
fix: port issue with mercury server
DhananjayPurohit May 30, 2024
42a8939
fix: host of mercury server
DhananjayPurohit May 30, 2024
6e8e781
debug: services on actions
DhananjayPurohit May 30, 2024
610e3a8
debug: mercury server availability
DhananjayPurohit May 30, 2024
456d937
debug: mercury server through curl
DhananjayPurohit May 30, 2024
683f754
debug: mercury server though curl
DhananjayPurohit May 30, 2024
69527e6
debug: running containers
DhananjayPurohit May 30, 2024
58a1d96
debug: mercury server through exec and curl
DhananjayPurohit May 30, 2024
bf7ced1
debug: mercury server through curl
DhananjayPurohit May 30, 2024
b91be75
debug: test with mercurylayer.com
DhananjayPurohit May 30, 2024
7ee3ff0
fix: mercurylayer api url
DhananjayPurohit May 30, 2024
49394cb
fix: remove mercury logs
DhananjayPurohit May 30, 2024
66ed164
feat: add test for iterative self transfer
DhananjayPurohit May 30, 2024
558d37d
debug: mercury server through curl
DhananjayPurohit May 30, 2024
e6d607d
debug: mercury server container
DhananjayPurohit May 30, 2024
6340d46
debug: mercury server
DhananjayPurohit May 31, 2024
e77b67c
debug: list all containers
DhananjayPurohit May 31, 2024
90c8c7a
debug: mercury server through container id
DhananjayPurohit May 31, 2024
75adfec
debug: fix mercury server container name
DhananjayPurohit May 31, 2024
3dcb0d3
debug: docker logs
DhananjayPurohit May 31, 2024
be69652
debug: increase wait time for service to be ready
DhananjayPurohit May 31, 2024
cb8aa7b
debug: sql error
DhananjayPurohit May 31, 2024
fa83139
debug: mercury server post request
DhananjayPurohit May 31, 2024
82eb65e
debug: electrum client
DhananjayPurohit May 31, 2024
e4b365f
debug: test failure
DhananjayPurohit May 31, 2024
3b31ed2
debug: post request /deposit/init/pod
DhananjayPurohit May 31, 2024
198a12b
debug: internal server error for mercury server
DhananjayPurohit May 31, 2024
f62bcd9
fix: expose port for ssl of electrum server
DhananjayPurohit May 31, 2024
67665b6
debug: electrum server
DhananjayPurohit May 31, 2024
c11e642
debug: bitcoin core
DhananjayPurohit May 31, 2024
413e4be
fix: increase wait time to service ready for bitcoin core
DhananjayPurohit May 31, 2024
7dabdb0
fix: command args for bitcoin core
DhananjayPurohit May 31, 2024
81756d9
debug: enclave
DhananjayPurohit May 31, 2024
a2efc6d
debug: enclave /get_public_key
DhananjayPurohit May 31, 2024
47adaf6
fix: add port for enclave to docker-compose
DhananjayPurohit May 31, 2024
3800f29
debug: get public key from enclave
DhananjayPurohit Jun 3, 2024
eabb350
debug: use lockbox url of testnet
DhananjayPurohit Jun 3, 2024
a1ec824
fix: enclave dockerfile cmd
DhananjayPurohit Jun 3, 2024
37609d0
fix: cmd for enclave server
DhananjayPurohit Jun 3, 2024
1d39b20
debug: deposit msg
DhananjayPurohit Jun 3, 2024
4a8e0a5
debug: depositMsg for /deposit/init/pod
DhananjayPurohit Jun 3, 2024
81b1cc1
debug: statechain_id in pod_deposit
DhananjayPurohit Jun 3, 2024
ca6041f
debug: enclave logs
DhananjayPurohit Jun 3, 2024
e31cd50
debig: network connectivity between containers
DhananjayPurohit Jun 3, 2024
7f9213e
debug: lockbox url
DhananjayPurohit Jun 3, 2024
6d8d210
fix: mercury server in docker compose
DhananjayPurohit Jun 3, 2024
5b33c3d
fix: dockerfile location in docker compose
DhananjayPurohit Jun 3, 2024
3771341
fix: dockerfile location in mercury server docker compose
DhananjayPurohit Jun 3, 2024
1ccdebc
fix: lockbox env name
DhananjayPurohit Jun 3, 2024
931eee0
fix: env name for lockbox
DhananjayPurohit Jun 3, 2024
d9358e0
feat: add deposit using bitcoin-cli
DhananjayPurohit Jun 3, 2024
b49db0b
debug: bitcoin-cli for deposit
DhananjayPurohit Jun 4, 2024
2240137
fix: bitcoin-cli cmd execution
DhananjayPurohit Jun 4, 2024
17c2fb5
fix: create wallet before send to address
DhananjayPurohit Jun 4, 2024
9daa884
fix: address in deposit
DhananjayPurohit Jun 4, 2024
a47f194
fix: address in generatetoaddress
DhananjayPurohit Jun 4, 2024
d7e4b6a
fix: add rpcfee field to sendtoaddress cmd
DhananjayPurohit Jun 4, 2024
5d6d3c2
fix: increase rpcfee
DhananjayPurohit Jun 4, 2024
80a8506
fix: add fallbackfee to bitcoin core
DhananjayPurohit Jun 4, 2024
69a1183
fix: generate block after deposit
DhananjayPurohit Jun 4, 2024
211fa40
fix: increase generate block to confirmation target
DhananjayPurohit Jun 4, 2024
b1daf77
fix: change withdraw address to regtest
DhananjayPurohit Jun 4, 2024
03c9048
fix: adjust sleep time for services to be ready
DhananjayPurohit Jun 4, 2024
c65dfcc
debug: wallet database deletion
DhananjayPurohit Jun 4, 2024
050d008
fix: change wallet name to fix sql error
DhananjayPurohit Jun 4, 2024
0617e78
fix: db lock error
DhananjayPurohit Jun 4, 2024
7bda298
fix: path in removeDatabase fn
DhananjayPurohit Jun 4, 2024
a54ccd1
fix: databaseFile variable
DhananjayPurohit Jun 4, 2024
7e5b3af
fix: blockheight from electrum server
DhananjayPurohit Jun 4, 2024
03401cc
fix: getElectrumClient import
DhananjayPurohit Jun 4, 2024
afc3bd4
debug: db file location
DhananjayPurohit Jun 5, 2024
7af8e79
debug: find wallet.db file
DhananjayPurohit Jun 5, 2024
d8fb7e3
fix: removeDb fn
DhananjayPurohit Jun 5, 2024
cfaf3ce
fix: wallet names in tests
DhananjayPurohit Jun 5, 2024
1010580
fix: lockheight of mercury server
DhananjayPurohit Jun 5, 2024
3b41107
fix: initial blocks generation
DhananjayPurohit Jun 5, 2024
1c729c6
fix: path import
DhananjayPurohit Jun 5, 2024
5277ea8
fix: path in removeDatabase fn
DhananjayPurohit Jun 5, 2024
d972f1b
fix: path import in removeDatabase fn
DhananjayPurohit Jun 5, 2024
f906c18
fix: unit test for iterative self transfer
DhananjayPurohit Jun 5, 2024
7191335
fix: locktime for mercury server
DhananjayPurohit Jun 5, 2024
6e8edeb
fix: lockheight_init for mercury server
DhananjayPurohit Jun 5, 2024
e8d4a52
debug: lockheight_init for mercury server
DhananjayPurohit Jun 5, 2024
196c47f
fix: lh_decrement and lockheight_init
DhananjayPurohit Jun 5, 2024
9ad4c15
chore: add test for transfer sender after transfer receiver
DhananjayPurohit Jun 6, 2024
c410177
chore: refactor depositCoin
DhananjayPurohit Jun 6, 2024
e085e20
chore: add test for deposit and transfer
DhananjayPurohit Jun 6, 2024
56ed7e2
fix: token generation
DhananjayPurohit Jun 6, 2024
1eed92d
fix: assert error
DhananjayPurohit Jun 6, 2024
5d5303d
fix: typos for wallet name
DhananjayPurohit Jun 6, 2024
761e00e
fix: variable type
DhananjayPurohit Jun 6, 2024
08b164a
chore: add test for interruption of transfer-send in sign first
DhananjayPurohit Jun 7, 2024
6f7398c
fix: increase block generation for deposit coin step
DhananjayPurohit Jun 7, 2024
70acfb7
fix: generateBlock
DhananjayPurohit Jun 7, 2024
8e97af5
fix: wait for coin confirmed
DhananjayPurohit Jun 7, 2024
5867699
fix: increase block after coin deposit
DhananjayPurohit Jun 7, 2024
82cae28
chore: add test for transferSend signSecond interruption
DhananjayPurohit Jun 10, 2024
6ee4ce7
fix: block unblock port of mercury server for test
DhananjayPurohit Jun 10, 2024
d218a87
debug: network name for mercury server
DhananjayPurohit Jun 11, 2024
89e9874
fix: disconnect network for test
DhananjayPurohit Jun 11, 2024
eeeae6c
fix: enclose post request of sign into try catch
DhananjayPurohit Jun 11, 2024
7c09e96
fix: enclose transfer/sender request in try catch
DhananjayPurohit Jun 11, 2024
433da97
fix: get_new_x1 fn
DhananjayPurohit Jun 11, 2024
0a90a70
fix: error handling for mercury server post request
DhananjayPurohit Jun 11, 2024
62ad355
fix: variable error
DhananjayPurohit Jun 11, 2024
32d7cb1
fix: handle the case if response undefined
DhananjayPurohit Jun 11, 2024
e1e2f70
fix: error handling for signFirst and signSecond
DhananjayPurohit Jun 11, 2024
88a7ddf
fix: assert errors in test
DhananjayPurohit Jun 12, 2024
8567f77
fix: add test for electrum unavailability
DhananjayPurohit Jun 12, 2024
63b68de
chore: add test for transfer receive for electrum unavailability
DhananjayPurohit Jun 12, 2024
1faa17f
chore: uncomment all test
DhananjayPurohit Jun 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: Integration Tests

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

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 core Service with Curl
run: |
container_id=$(docker ps -qf "name=mercurylayer_bitcoin_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_electrumx_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 npm link
run: |
cd clients/libs/nodejs
npm link --save

- name: Link mercurynodejslib
run: |
cd clients/apps/nodejs
npm link mercurynodejslib
- name: Run Client-Side Tests
run: |
cd clients/apps/nodejs
node test_basic_workflow2.js
- name: Print environment variables
run: printenv
- name: Print working directory
run: pwd
- name: List files in working directory
run: ls -al
- name: Tear Down
run: |
docker-compose 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://127.0.0.1:50001",
"electrumServer": "ssl://127.0.0.1:50002",
"electrumType": "electrs",
"_electrumServer": "tcp://localhost:50001",
"network": "signet",
"_electrumServer": "tcp://127.0.0.1:50001",
"network": "regtest",
"feeRateTolerance": 5,
"databaseFile": "wallet.db",
"confirmationTarget": 2,
Expand Down
Loading
Loading