mirror of
https://github.com/AthanorLabs/atomic-swap.git
synced 2026-01-09 14:18:03 -05:00
ci: split integration tests and unit tests (#57)
* split integration tests and unit tests * add script
This commit is contained in:
3
.github/workflows/unit-tests.yml
vendored
3
.github/workflows/unit-tests.yml
vendored
@@ -46,3 +46,6 @@ jobs:
|
||||
|
||||
- name: Run unit tests
|
||||
run: ./scripts/run-unit-tests.sh
|
||||
|
||||
- name: Run integration tests
|
||||
run: ./scripts/run-integration-tests.sh
|
||||
|
||||
3
Makefile
3
Makefile
@@ -8,6 +8,9 @@ lint:
|
||||
test:
|
||||
./scripts/run-unit-tests.sh
|
||||
|
||||
test-integration:
|
||||
./scripts/run-integration-tests.sh
|
||||
|
||||
install:
|
||||
cd cmd/ && go install && cd ..
|
||||
|
||||
|
||||
45
scripts/run-integration-tests.sh
Executable file
45
scripts/run-integration-tests.sh
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
|
||||
# install monero and run daemon and wallet RPC servers for alice and bob
|
||||
bash ./scripts/install-monero-linux.sh
|
||||
echo "starting monerod..."
|
||||
./monero-x86_64-linux-gnu-v0.17.2.3/monerod --detach --regtest --offline --fixed-difficulty=1 --rpc-bind-port 18081 &
|
||||
sleep 5
|
||||
|
||||
echo "starting monero-wallet-rpc on port 18083..."
|
||||
mkdir bob-test-keys
|
||||
./monero-x86_64-linux-gnu-v0.17.2.3/monero-wallet-rpc --rpc-bind-port 18083 --disable-rpc-login --wallet-dir ./bob-test-keys &> monero-wallet-cli-bob.log &
|
||||
MONERO_WALLET_CLI_BOB_PID=$!
|
||||
|
||||
sleep 5
|
||||
curl http://localhost:18083/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"create_wallet","params":{"filename":"test-wallet","password":"","language":"English"}}' -H 'Content-Type: application/json'
|
||||
|
||||
echo "starting monero-wallet-rpc on port 18084..."
|
||||
mkdir alice-test-keys
|
||||
./monero-x86_64-linux-gnu-v0.17.2.3/monero-wallet-rpc --rpc-bind-port 18084 --disable-rpc-login --wallet-dir ./alice-test-keys &> monero-wallet-cli-alice.log &
|
||||
MONERO_WALLET_CLI_ALICE_PID=$!
|
||||
|
||||
# install ganache and run
|
||||
echo "installing and starting ganache-cli..."
|
||||
if ! command -v golangci-lint &> /dev/null; then
|
||||
npm i -g ganache-cli
|
||||
fi
|
||||
export NODE_OPTIONS=--max_old_space_size=8192
|
||||
ganache-cli -d &> ganache-cli.log &
|
||||
GANACHE_CLI_PID=$!
|
||||
|
||||
# wait for servers to start
|
||||
sleep 10
|
||||
|
||||
# run unit tests
|
||||
echo "running unit tests..."
|
||||
go test ./tests -v
|
||||
OK=$?
|
||||
|
||||
# kill processes
|
||||
kill $MONERO_WALLET_CLI_BOB_PID
|
||||
kill $MONERO_WALLET_CLI_ALICE_PID
|
||||
kill $GANACHE_CLI_PID
|
||||
# rm -rf ./alice-test-keys
|
||||
# rm -rf ./bob-test-keys
|
||||
exit $OK
|
||||
@@ -1,6 +1,7 @@
|
||||
package tests
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -25,6 +26,11 @@ const (
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
flag.Parse()
|
||||
if testing.Short() {
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
cmd := exec.Command("../scripts/build.sh")
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user