Skip to content

Commit e4fff57

Browse files
committed
f readd test in new ci job
1 parent 808e51f commit e4fff57

File tree

2 files changed

+144
-0
lines changed

2 files changed

+144
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: CI Checks - VSS No-Auth Integration Tests
2+
3+
on: [push, pull_request]
4+
5+
concurrency:
6+
group: ${{ github.workflow }}-${{ github.ref }}
7+
cancel-in-progress: true
8+
9+
jobs:
10+
build-and-test:
11+
runs-on: ubuntu-latest
12+
13+
services:
14+
postgres:
15+
image: postgres:latest
16+
ports:
17+
- 5432:5432
18+
env:
19+
POSTGRES_DB: postgres
20+
POSTGRES_USER: postgres
21+
POSTGRES_PASSWORD: postgres
22+
options: >-
23+
--health-cmd pg_isready
24+
--health-interval 10s
25+
--health-timeout 5s
26+
--health-retries 5
27+
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v3
31+
with:
32+
path: ldk-node
33+
- name: Checkout VSS
34+
uses: actions/checkout@v3
35+
with:
36+
repository: lightningdevkit/vss-server
37+
path: vss-server
38+
39+
- name: Build and Deploy VSS Server
40+
run: |
41+
cd vss-server/rust
42+
RUSTFLAGS=--cfg=noop_authorizer cargo run --no-default-features server/vss-server-config.toml&
43+
- name: Run VSS Integration tests
44+
run: |
45+
cd ldk-node
46+
export TEST_VSS_BASE_URL="http://localhost:8080/vss"
47+
RUSTFLAGS="--cfg vss_test" cargo test io::vss_store
48+
RUSTFLAGS="--cfg vss_test --cfg cycle_tests" cargo test --test integration_tests_vss
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
// This file is Copyright its original authors, visible in version control history.
2+
//
3+
// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
5+
// http://opensource.org/licenses/MIT>, at your option. You may not use this file except in
6+
// accordance with one or both of these licenses.
7+
8+
#![cfg(vss_test)]
9+
10+
mod common;
11+
12+
use std::collections::HashMap;
13+
14+
use ldk_node::entropy::NodeEntropy;
15+
use ldk_node::Builder;
16+
use rand::{rng, Rng, RngCore};
17+
18+
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
19+
async fn vss_v0_schema_backwards_compatibility() {
20+
let (bitcoind, electrsd) = common::setup_bitcoind_and_electrsd();
21+
let esplora_url = format!("http://{}", electrsd.esplora_url.as_ref().unwrap());
22+
let vss_base_url = std::env::var("TEST_VSS_BASE_URL").unwrap();
23+
24+
let rand_suffix: String =
25+
(0..7).map(|_| rng().sample(rand::distr::Alphanumeric) as char).collect();
26+
let store_id = format!("v0_compat_test_{}", rand_suffix);
27+
let storage_path = common::random_storage_path().to_str().unwrap().to_owned();
28+
let mut seed_bytes = [42u8; 64];
29+
rand::thread_rng().fill_bytes(&mut seed_bytes);
30+
let node_entropy = NodeEntropy::from_seed_bytes(seed_bytes);
31+
32+
// Setup a v0.6.2 `Node` persisted with the v0 scheme.
33+
let (old_balance, old_node_id) = {
34+
let mut builder_old = ldk_node_062::Builder::new();
35+
builder_old.set_network(bitcoin::Network::Regtest);
36+
builder_old.set_storage_dir_path(storage_path.clone());
37+
builder_old.set_entropy_seed_bytes(seed_bytes);
38+
builder_old.set_chain_source_esplora(esplora_url.clone(), None);
39+
let node_old = builder_old
40+
.build_with_vss_store_and_fixed_headers(
41+
vss_base_url.clone(),
42+
store_id.clone(),
43+
HashMap::new(),
44+
)
45+
.unwrap();
46+
47+
node_old.start().unwrap();
48+
let addr_old = node_old.onchain_payment().new_address().unwrap();
49+
common::premine_and_distribute_funds(
50+
&bitcoind.client,
51+
&electrsd.client,
52+
vec![addr_old],
53+
bitcoin::Amount::from_sat(100_000),
54+
)
55+
.await;
56+
node_old.sync_wallets().unwrap();
57+
58+
let balance = node_old.list_balances().spendable_onchain_balance_sats;
59+
assert!(balance > 0);
60+
let node_id = node_old.node_id();
61+
62+
// Workaround necessary as v0.6.2's VSS runtime wasn't dropsafe in a tokio context.
63+
tokio::task::block_in_place(move || {
64+
node_old.stop().unwrap();
65+
drop(node_old);
66+
});
67+
68+
(balance, node_id)
69+
};
70+
71+
// Now ensure we can still reinit from the same backend.
72+
let mut builder_new = Builder::new();
73+
builder_new.set_network(bitcoin::Network::Regtest);
74+
builder_new.set_storage_dir_path(storage_path);
75+
builder_new.set_chain_source_esplora(esplora_url, None);
76+
77+
let node_new = builder_new
78+
.build_with_vss_store_and_fixed_headers(
79+
node_entropy,
80+
vss_base_url,
81+
store_id,
82+
HashMap::new(),
83+
)
84+
.unwrap();
85+
86+
node_new.start().unwrap();
87+
node_new.sync_wallets().unwrap();
88+
89+
let new_balance = node_new.list_balances().spendable_onchain_balance_sats;
90+
let new_node_id = node_new.node_id();
91+
92+
assert_eq!(old_node_id, new_node_id);
93+
assert_eq!(old_balance, new_balance);
94+
95+
node_new.stop().unwrap();
96+
}

0 commit comments

Comments
 (0)