feat: add LND containers for testing #252
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Integration Tests | |
on: | |
push: | |
branches: | |
- dev | |
pull_request: | |
branches: | |
- dev | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
services: | |
docker: | |
image: docker:24.0.5 | |
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: | | |
sudo curl -L "https://github.com/docker/compose/releases/download/v2.5.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
sudo chmod +x /usr/local/bin/docker-compose | |
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 and create wallet | |
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: Wait for services to be ready | |
run: | | |
sleep 60 # Wait for lnd to sync with latest block | |
- name: Verify LND nodes and create a channel between them | |
run: | | |
container_id_alice=$(docker ps -qf "name=mercurylayer_alice_1") | |
echo "Container ID: $container_id_alice" | |
container_id_bob=$(docker ps -qf "name=mercurylayer_bob_1") | |
echo "Container ID: $container_id_bob" | |
docker logs $container_id_alice | |
docker logs $container_id_bob | |
identity_pubkey_bob=$(docker exec $container_id_bob lncli -n regtest getinfo | jq -r '.identity_pubkey') | |
echo "Pubkey: $identity_pubkey_bob" | |
docker exec $container_id_alice lncli -n regtest connect $identity_pubkey_bob@bob:9735 | |
docker exec $container_id_alice lncli -n regtest listpeers | |
address=$(docker exec $container_id_bob lncli -n regtest newaddress p2wkh | jq -r '.address') | |
container_id_bitcoind=$(docker ps -qf "name=mercurylayer_bitcoind_1") | |
docker exec $container_id_bitcoind bitcoin-cli -regtest -rpcuser=user -rpcpassword=pass sendtoaddress $address 0.5 | |
docker exec $(docker ps -qf "name=mercurylayer_bitcoind_1") bitcoin-cli -regtest -rpcuser=user -rpcpassword=pass -generate 6 | |
identity_pubkey_alice=$(docker exec $container_id_alice lncli -n regtest getinfo | jq -r '.identity_pubkey') | |
docker exec $container_id_bob lncli -n regtest openchannel $identity_pubkey_alice 100000 | |
docker exec $(docker ps -qf "name=mercurylayer_bitcoind_1") bitcoin-cli -regtest -rpcuser=user -rpcpassword=pass -generate 5 | |
docker logs $container_id_alice | |
docker logs $container_id_bob | |
- 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 http://0.0.0.0:8000/info/config | |
- 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 | |
npm install mocha -g | |
- 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 | |
node test_atomic_swap.js | |
mocha ./test/tb04-simple-lightning-latch.mjs --exit | |
- name: Tear Down | |
run: | | |
docker-compose -f docker-compose-test.yml down |