Skip to content

Commit dceae89

Browse files
committed
Run externalized tests in CI
1 parent 271d1b7 commit dceae89

File tree

5 files changed

+53
-13
lines changed

5 files changed

+53
-13
lines changed

.github/workflows/build.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,20 @@ concurrency:
1313
cancel-in-progress: true
1414

1515
jobs:
16+
ext-test:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout source code
20+
uses: actions/checkout@v4
21+
- name: Install Rust stable toolchain
22+
run: |
23+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain stable
24+
rustup override set stable
25+
- name: Run externalized tests
26+
run: |
27+
cd ext-functional-test-demo
28+
cargo test --verbose --color always
29+
cargo test --verbose --color always --features test-broken
1630
build:
1731
strategy:
1832
fail-fast: false

ci/ci-tests.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,6 @@ cargo check --verbose --color always
112112
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
113113
popd
114114

115-
echo -e "\n\Running functional tests from outside the workspace"
116-
pushd ext-functional-test-demo
117-
[ "$RUSTC_MINOR_VERSION" -lt 65 ] && cargo update -p regex --precise "1.9.6" --verbose
118-
cargo test --color always
119-
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
120-
popd
121-
122115
# Test that we can build downstream code with only the "release pins".
123116
pushd msrv-no-dev-deps-check
124117
PIN_RELEASE_DEPS

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 = ["_externalize_tests"] }

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
@@ -11423,7 +11423,7 @@ where
1142311423
// Most of our tests were written when we only broadcasted
1142411424
// `channel_announcement`s once and then never re-broadcasted
1142511425
// them again, so disable the re-broadcasting entirely in tests
11426-
#[cfg(test)]
11426+
#[cfg(any(test, feature = "_test_utils"))]
1142711427
{
1142811428
should_announce = announcement_sigs.is_some();
1142911429
}

0 commit comments

Comments
 (0)