Skip to content

Commit f8cd0c0

Browse files
Harsh Dev PathakHarshdev098
authored andcommitted
feat: Added in-memory storage for testing purposes
1 parent b828ef6 commit f8cd0c0

9 files changed

Lines changed: 639 additions & 106 deletions

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: In-Memory VSS Server CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
test-in-memory:
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 6
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Create in-memory config
22+
run: |
23+
mkdir -p rust/server
24+
cat > rust/server/vss-server-config.toml <<EOF
25+
[server_config]
26+
host = "127.0.0.1"
27+
port = 8080
28+
store_type = "in-memory"
29+
EOF
30+
31+
- name: Build server
32+
working-directory: rust
33+
run: cargo build --release --bin vss-server
34+
35+
- name: Start VSS server
36+
working-directory: rust
37+
run: |
38+
./target/release/vss-server ./server/vss-server-config.toml --in-memory > server.log 2>&1 &
39+
echo "Server PID: $!"
40+
41+
- name: Wait for server
42+
run: |
43+
for i in {1..15}; do
44+
if curl -s http://127.0.0.1:8080 > /dev/null; then
45+
echo "Server is up!"
46+
exit 0
47+
fi
48+
sleep 1
49+
done
50+
echo "Server failed. Dumping log:"
51+
cat rust/server.log
52+
exit 1
53+
54+
- name: HTTP Smoke Test
55+
run: |
56+
sudo apt-get update && sudo apt-get install -y xxd
57+
58+
curl -f \
59+
-H "Authorization: Bearer test_user" \
60+
--data-binary @<(echo "0A04746573741A150A026B3110FFFFFFFFFFFFFFFFFF011A046B317631" | xxd -r -p) \
61+
http://127.0.0.1:8080/vss/putObjects
62+
63+
RESPONSE=$(curl -f \
64+
-H "Authorization: Bearer test_user" \
65+
--data-binary @<(echo "0A047465737412026B31" | xxd -r -p) \
66+
http://127.0.0.1:8080/vss/getObject)
67+
68+
- name: Run In-Memory unit tests
69+
working-directory: rust
70+
run: cargo test --package impls --lib -- in_memory_store::tests --nocapture

.github/workflows/ldk-node-integration.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,56 @@ jobs:
4747
export TEST_VSS_BASE_URL="http://localhost:8080/vss"
4848
RUSTFLAGS="--cfg vss_test" cargo test io::vss_store
4949
RUSTFLAGS="--cfg vss_test" cargo test --test integration_tests_vss
50+
51+
test-in-memory:
52+
runs-on: ubuntu-latest
53+
timeout-minutes: 30
54+
55+
steps:
56+
- name: Checkout code
57+
uses: actions/checkout@v3
58+
with:
59+
path: vss-server
60+
61+
- name: Checkout LDK Node
62+
uses: actions/checkout@v3
63+
with:
64+
repository: lightningdevkit/ldk-node
65+
path: ldk-node
66+
67+
- name: Create In-Memory config
68+
run: |
69+
mkdir -p vss-server/rust/server
70+
cat > vss-server/rust/server/vss-server-config.toml <<EOF
71+
[server_config]
72+
host = "127.0.0.1"
73+
port = 8080
74+
store_type = "in-memory"
75+
EOF
76+
77+
- name: Build & Start VSS Server
78+
working-directory: vss-server/rust
79+
run: |
80+
cargo build --release --bin vss-server
81+
./target/release/vss-server ./server/vss-server-config.toml --in-memory > server.log 2>&1 &
82+
echo "Server PID: $!"
83+
84+
- name: Wait for VSS
85+
run: |
86+
for i in {1..30}; do
87+
if curl -s http://127.0.0.1:8080/vss > /dev/null; then
88+
echo "VSS ready"
89+
exit 0
90+
fi
91+
sleep 1
92+
done
93+
echo "VSS failed:"
94+
cat vss-server/rust/vss.log
95+
exit 1
96+
97+
- name: Run LDK Node Integration tests
98+
working-directory: ldk-node
99+
run: |
100+
export TEST_VSS_BASE_URL="http://127.0.0.1:8080/vss"
101+
RUSTFLAGS="--cfg vss_test" cargo test io::vss_store
102+
RUSTFLAGS="--cfg vss_test" cargo test --test integration_tests_vss

rust/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ cargo build --release
2424
```
2525
cargo run -- server/vss-server-config.toml
2626
```
27+
28+
**Note:** For testing purposes, you can pass `--in-memory` to use in-memory instead of PostgreSQL
29+
```
30+
cargo run -- server/vss-server-config.toml --in-memory
31+
```
2732
4. VSS endpoint should be reachable at `http://localhost:8080/vss`.
2833

2934
### Configuration

0 commit comments

Comments
 (0)