Skip to content

Commit a92c915

Browse files
committed
run externalized tests in CI
1 parent c2d451f commit a92c915

File tree

4 files changed

+46
-6
lines changed

4 files changed

+46
-6
lines changed

ci/ci-tests.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,13 @@ RUSTFLAGS="$RUSTFLAGS --cfg=ldk_test_vectors" cargo test -p lightning --verbose
142142
# check that compile with no_std and serde works in lightning-invoice
143143
cargo test -p lightning-invoice --verbose --color always --no-default-features --features serde
144144

145+
echo -e "\n\nRunning externalized integration tests"
146+
pushd ext-functional-test-demo
147+
cargo test --verbose --color always
148+
cargo test --verbose --color always --features test-broken
149+
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
150+
popd
151+
145152
echo -e "\n\nTesting no_std build on a downstream no-std crate"
146153
# check no-std compatibility across dependencies
147154
pushd no-std-check

ext-functional-test-demo/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@ name = "ext-functional-tester"
33
version = "0.1.0"
44
edition = "2021"
55

6+
[features]
7+
test-broken = []
8+
69
[dependencies]
710
lightning = { path = "../lightning", features = ["_test_utils"] }

ext-functional-test-demo/src/main.rs

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ fn main() {
33
}
44

55
#[cfg(test)]
6+
#[allow(unused)]
67
mod tests {
8+
use lightning::ln::functional_tests::*;
79
use lightning::util::dyn_signer::{DynKeysInterfaceTrait, DynSigner};
810
use lightning::util::test_utils::{TestSignerFactory, SIGNER_FACTORY};
911
use std::panic::catch_unwind;
@@ -20,12 +22,40 @@ mod tests {
2022
}
2123
}
2224

25+
#[cfg(feature = "test-broken")]
2326
#[test]
24-
fn test_functional() {
25-
lightning::ln::functional_tests::test_insane_channel_opens();
26-
lightning::ln::functional_tests::fake_network_test();
27-
27+
fn test_broken() {
2828
SIGNER_FACTORY.set(Arc::new(BrokenSignerFactory()));
29-
catch_unwind(|| lightning::ln::functional_tests::fake_network_test()).unwrap_err();
29+
catch_unwind(|| fake_network_test()).unwrap_err();
30+
}
31+
32+
#[cfg(not(feature = "test-broken"))]
33+
#[test]
34+
fn test_default_one() {
35+
test_htlc_on_chain_success();
36+
}
37+
38+
#[cfg(not(feature = "test-broken"))]
39+
#[test]
40+
fn test_default_all() {
41+
let mut failed_tests = Vec::new();
42+
for test in lightning::get_xtests() {
43+
print!("Running test: {}", test.test_name);
44+
let mut pass = catch_unwind(|| (test.test_fn)()).is_ok();
45+
if test.should_panic {
46+
pass = !pass;
47+
}
48+
if !pass {
49+
failed_tests.push(test.test_name);
50+
}
51+
}
52+
if !failed_tests.is_empty() {
53+
println!("Failed tests:");
54+
for test in failed_tests.iter() {
55+
println!("- {}", test);
56+
}
57+
}
58+
println!("Done with {} failures", failed_tests.len());
59+
assert!(failed_tests.is_empty());
3060
}
3161
}

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11041,7 +11041,7 @@ where
1104111041
// Most of our tests were written when we only broadcasted
1104211042
// `channel_announcement`s once and then never re-broadcasted
1104311043
// them again, so disable the re-broadcasting entirely in tests
11044-
#[cfg(test)]
11044+
#[cfg(any(test, feature = "_test_utils"))]
1104511045
{
1104611046
should_announce = announcement_sigs.is_some();
1104711047
}

0 commit comments

Comments
 (0)