Skip to content

Commit 8cbb2e1

Browse files
Harsh Dev PathakHarshdev098
authored andcommitted
feat: Added in-memory storage for testing purposes
1 parent 3a57b1b commit 8cbb2e1

9 files changed

Lines changed: 631 additions & 77 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
@@ -52,3 +52,56 @@ jobs:
5252
export TEST_VSS_BASE_URL="http://localhost:8080/vss"
5353
RUSTFLAGS="--cfg vss_test" cargo test io::vss_store -- --test-threads=1
5454
RUSTFLAGS="--cfg vss_test" cargo test --test integration_tests_vss -- --test-threads=1
55+
56+
test-in-memory:
57+
runs-on: ubuntu-latest
58+
timeout-minutes: 30
59+
60+
steps:
61+
- name: Checkout code
62+
uses: actions/checkout@v3
63+
with:
64+
path: vss-server
65+
66+
- name: Checkout LDK Node
67+
uses: actions/checkout@v3
68+
with:
69+
repository: lightningdevkit/ldk-node
70+
path: ldk-node
71+
72+
- name: Create In-Memory config
73+
run: |
74+
mkdir -p vss-server/rust/server
75+
cat > vss-server/rust/server/vss-server-config.toml <<EOF
76+
[server_config]
77+
host = "127.0.0.1"
78+
port = 8080
79+
store_type = "in-memory"
80+
EOF
81+
82+
- name: Build & Start VSS Server
83+
working-directory: vss-server/rust
84+
run: |
85+
cargo build --release --bin vss-server
86+
./target/release/vss-server ./server/vss-server-config.toml --in-memory > server.log 2>&1 &
87+
echo "Server PID: $!"
88+
89+
- name: Wait for VSS
90+
run: |
91+
for i in {1..30}; do
92+
if curl -s http://127.0.0.1:8080/vss > /dev/null; then
93+
echo "VSS ready"
94+
exit 0
95+
fi
96+
sleep 1
97+
done
98+
echo "VSS failed:"
99+
cat vss-server/rust/vss.log
100+
exit 1
101+
102+
- name: Run LDK Node Integration tests
103+
working-directory: ldk-node
104+
run: |
105+
export TEST_VSS_BASE_URL="http://127.0.0.1:8080/vss"
106+
RUSTFLAGS="--cfg vss_test" cargo test io::vss_store
107+
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
@@ -26,6 +26,11 @@ cargo build --release
2626
```
2727
cargo run server/vss-server-config.toml
2828
```
29+
30+
**Note:** For testing purposes, you can pass `--in-memory` to use in-memory instead of PostgreSQL
31+
```
32+
cargo run -- server/vss-server-config.toml --in-memory
33+
```
2934
4. VSS endpoint should be reachable at `http://localhost:8080/vss`.
3035

3136
### Configuration

0 commit comments

Comments
 (0)