Skip to content

Commit

Permalink
Introduce e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tdroxler committed Nov 7, 2024
1 parent c6664e2 commit a933c41
Show file tree
Hide file tree
Showing 10 changed files with 4,459 additions and 0 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: E2E

on:
push:
branches: [ master ]
pull_request:
branches:
- '**'

jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
#######################
#### Setup phases
#######################
- name: Checkout explorer-backend
uses: actions/checkout@v4
- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
cache: sbt
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
- name: Start full node
run: |
pushd e2e/docker
docker compose up -d
popd
SECONDS=0
until curl http://localhost:22973/infos/self-clique
do
if (( SECONDS > 60 ))
then
echo "Alephium full node not working after 1 min..."
exit 1
fi
echo "Waiting..."
sleep 5
done
echo "Alephium full node is up"
- name: Start explorer-backend
run: |
export BLOCKFLOW_HOST=127.0.0.1
export BLOCKFLOW_PORT=22973
export BLOCKFLOW_NETWORK_ID=4
export DB_NAME=postgres
sbt app/run &
until curl http://localhost:9090/infos
do
if (( SECONDS > 300 ))
then
echo "explorer-backend not working after 5 min..."
exit 1
fi
echo "Waiting..."
sleep 5
done
echo "explorer-backend is up"
#######################
#### Test phase
#######################
- name: Run E2E tests
run: |
cd e2e
npm i
npm run test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
target
*.mv.db
node_modules
coverage
dist
55 changes: 55 additions & 0 deletions e2e/docker/devnet.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Import this mnemonic to have 4'000'000 token allocated for your addresses
#
# vault alarm sad mass witness property virus style good flower rice alpha viable evidence run glare pretty scout evil judge enroll refuse another lava

alephium.genesis.allocations = [
{
address = "1DrDyTr9RpRsQnDnXo2YRiPzPW4ooHX5LLoqXrqfMrpQH",
amount = 1000000000000000000000000,
lock-duration = 0 seconds
},
{
address = "14UAjZ3qcmEVKdTo84Kwf4RprTQi86w2TefnnGFjov9xF",
amount = 1000000000000000000000000,
lock-duration = 0 seconds
},
{
address = "15jjExDyS8q3Wqk9v29PCQ21jDqubDrD8WQdgn6VW2oi4",
amount = 1000000000000000000000000,
lock-duration = 0 seconds
},
{
address = "17cBiTcWhung3WDLuc9ja5Y7BMus5Q7CD9wYBxS1r1P2R",
amount = 1000000000000000000000000,
lock-duration = 0 seconds
}
]
alephium.consensus.num-zeros-at-least-in-hash = 0
alephium.consensus.uncle-dependency-gap-time = 0 seconds
alephium.network.leman-hard-fork-timestamp = 0

alephium.network.network-id = 4
alephium.discovery.bootstrap = []
alephium.wallet.locking-timeout = 99999 minutes
alephium.mempool.auto-mine-for-dev = true
alephium.node.event-log.enabled=true
alephium.node.event-log.index-by-tx-id = true
alephium.node.event-log.index-by-block-hash = true

alephium.network.rest-port = 22973
alephium.network.ws-port = 21973
alephium.network.miner-api-port = 20973
alephium.api.network-interface = "0.0.0.0"
alephium.api.api-key-enabled = false
alephium.mining.api-interface = "0.0.0.0"
alephium.network.bind-address = "0.0.0.0:19973"
alephium.network.internal-address = "alephium:19973"
alephium.network.coordinator-address = "alephium:19973"

# arbitrary mining addresses
alephium.mining.miner-addresses = [
"1FsroWmeJPBhcPiUr37pWXdojRBe6jdey9uukEXk1TheA",
"1CQvSXsmM5BMFKguKDPpNUfw1idiut8UifLtT8748JdHc",
"193maApeJWrz9GFwWCfa982ccLARVE9Y1WgKSJaUs7UAx",
"16fZKYPCZJv2TP3FArA9FLUQceTS9U8xVnSjxFG9MBKyY"
]
24 changes: 24 additions & 0 deletions e2e/docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: "3.9"

services:
alephium:
image: alephium/alephium:v2.12.1
restart: unless-stopped
ports:
- 19973:19973/tcp
- 19973:19973/udp
- 127.0.0.1:20973:20973
- 127.0.0.1:21973:21973
- 127.0.0.1:22973:22973
environment:
- ALEPHIUM_LOG_LEVEL=DEBUG
- ALEPHIUM_ENABLE_DEBUG_LOGGING=true
security_opt:
- no-new-privileges:true
volumes:
- ./devnet.conf:/alephium-home/.alephium/user.conf
healthcheck:
test: curl --fail http://127.0.0.1:22973/wallets || exit 1
interval: 3s
retries: 10
timeout: 45s
12 changes: 12 additions & 0 deletions e2e/jest-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"transform": {
"^.+\\.(t|j)sx?$": "ts-jest"
},
"testMatch": ["**/(src|test)/**/*.test.ts"],
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"],
"collectCoverage": true,
"coverageDirectory": "./coverage/",
"collectCoverageFrom": ["lib/**/*.ts"]
}


Loading

0 comments on commit a933c41

Please sign in to comment.