feat: add integration tests to actions #80
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 | |
- 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 90 # 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" | |
}' | |
- 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: 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"}' | |
- 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: Tear Down | |
run: | | |
docker-compose down |