Skip to content

Commit 4b7a892

Browse files
committed
f readd test in new ci job
1 parent ddc72fc commit 4b7a892

File tree

2 files changed

+132
-0
lines changed

2 files changed

+132
-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 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: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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::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 storage_path = common::random_storage_path().to_str().unwrap().to_owned();
25+
let mut seed_bytes = [42u8; 64];
26+
rand::thread_rng().fill_bytes(&mut seed_bytes);
27+
let node_entropy = NodeEntropy::from_seed_bytes(seed_bytes);
28+
29+
// Setup a v0.6.2 `Node` persisted with the v0 scheme.
30+
let (old_balance, old_node_id) = {
31+
let mut builder_old = ldk_node_062::Builder::new();
32+
builder_old.set_network(bitcoin::Network::Regtest);
33+
builder_old.set_storage_dir_path(storage_path.clone());
34+
builder_old.set_entropy_seed_bytes(seed_bytes);
35+
builder_old.set_chain_source_esplora(esplora_url.clone(), None);
36+
let node_old = builder_old
37+
.build_with_vss_store(vss_base_url.clone(), "".to_owned(), HashMap::new())
38+
.unwrap();
39+
40+
node_old.start().unwrap();
41+
let addr_old = node_old.onchain_payment().new_address().unwrap();
42+
common::premine_and_distribute_funds(
43+
&bitcoind.client,
44+
&electrsd.client,
45+
vec![addr_old],
46+
bitcoin::Amount::from_sat(100_000),
47+
)
48+
.await;
49+
node_old.sync_wallets().unwrap();
50+
51+
let balance = node_old.list_balances().spendable_onchain_balance_sats;
52+
assert!(balance > 0);
53+
let node_id = node_old.node_id();
54+
55+
// Workaround necessary as v0.6.2's VSS runtime wasn't dropsafe in a tokio context.
56+
tokio::task::block_in_place(move || {
57+
node_old.stop().unwrap();
58+
drop(node_old);
59+
});
60+
61+
(balance, node_id)
62+
};
63+
64+
// Now ensure we can still reinit from the same backend.
65+
let mut builder_new = Builder::new();
66+
builder_new.set_network(bitcoin::Network::Regtest);
67+
builder_new.set_storage_dir_path(storage_path);
68+
builder_new.set_chain_source_esplora(esplora_url, None);
69+
70+
let node_new = builder_new
71+
.build_with_vss_store(node_entropy, vss_base_url, "".to_owned(), HashMap::new())
72+
.unwrap();
73+
74+
node_new.start().unwrap();
75+
node_new.sync_wallets().unwrap();
76+
77+
let new_balance = node_new.list_balances().spendable_onchain_balance_sats;
78+
let new_node_id = node_new.node_id();
79+
80+
assert_eq!(old_node_id, new_node_id);
81+
assert_eq!(old_balance, new_balance);
82+
83+
node_new.stop().unwrap();
84+
}

0 commit comments

Comments
 (0)