Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integration tests: setup LND #77

Merged
merged 7 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ on:
pull_request:
branches: ['*']

env:
GO_VERSION: 1.21.0

jobs:
build_and_test:
build_and_format:
name: LNDK Rust Build
runs-on: ubuntu-latest
steps:
Expand All @@ -20,11 +23,6 @@ jobs:
with:
command: build
args: --release --all-features
- uses: actions-rs/cargo@v1
name: cargo test
with:
command: test
args: --all-targets --benches -- --test-threads=1
- uses: actions-rs/cargo@v1
name: cargo fmt
with:
Expand All @@ -35,6 +33,29 @@ jobs:
with:
command: clippy
args: -- --deny warnings

########################
# run ubuntu integration tests
########################
ubuntu-integration-test:
name: run ubuntu unit and integration tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: setup go ${{ env.GO_VERSION }}
uses: lightningnetwork/lnd/.github/actions/setup-go@v0-16-4-branch
with:
go-version: '${{ env.GO_VERSION }}'
- name: run unit tests
run: cargo test --bin lndk
- name: run integration tests
run: make itest

coverage:
name: LNDK Code Coverage
runs-on: ubuntu-latest
Expand All @@ -48,7 +69,7 @@ jobs:
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Generate code coverage
run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
run: cargo llvm-cov --bin lndk --workspace --lcov --output-path lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "lnd"]
path = lnd
url = https://github.com/lightningnetwork/lnd
11 changes: 8 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ cargo clippy
2. Error String: Lower case, no `.` terminating.
3. Display imps: Lower case, no `.` terminating.

### Integration tests
### Running tests

Note that the way the tests (both unit and integration tests) run now, it's best to run them sequentially rather than concurrently (which is Rust's default) to avoid port conflicts. You can run them sequentially with this command:
To run just the unit tests use the command:

`cargo test --bin lndk`

The integration tests require a Makefile to create an lnd binary. You'll need to [install Go](https://go.dev/doc/install) and then run them with this command:

`make itest`

`cargo test -- --test-threads=1`
8 changes: 5 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ log = "0.4.17"
simple_logger = "4.0.0"
tokio = { version = "1.25.0", features = ["rt", "rt-multi-thread"] }
tonic = "0.8.3"
tonic_lnd = "0.5.1"
tonic_lnd = { git = "https://github.com/Kixunil/tonic_lnd", rev = "fac4a67a8d4951d62fc020d61d38628c0064e6df" }
hex = "0.4.3"
configure_me = "0.4.0"
bytes = "1.4.0"

[dev-dependencies]
bitcoincore-rpc = { package="core-rpc", version = "0.17.0" }
bitcoind = { version = "0.30.0", features = [ "22_0" ] }
ldk-sample = { git = "https://github.com/lndk-org/ldk-sample", branch = "pub-interface" }
chrono = { version = "0.4.26" }
ldk-sample = { git = "https://github.com/lndk-org/ldk-sample", branch = "log-dir-tweak" }
mockall = "0.11.3"
tempfile = "3.5.0"

Expand Down
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This Makefile is used to compile an LND binary for the integration tests.

GO_BUILD := go build
CARGO_TEST := cargo test
LND_PKG := github.com/lightningnetwork/lnd

TMP_DIR := "/tmp"
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
TMP_DIR=${TMPDIR}
endif

itest:
orbitalturtle marked this conversation as resolved.
Show resolved Hide resolved
@$(call print, "Building lnd for itests.")
git submodule update --init --recursive
cd lnd/cmd/lnd; $(GO_BUILD) -tags="peersrpc signrpc dev" -o $(TMP_DIR)/lndk-tests/bin/lnd-itest$(EXEC_SUFFIX)
$(CARGO_TEST) -- -- test '*' --test-threads=1 --nocapture

1 change: 1 addition & 0 deletions lnd
Submodule lnd added at 2fb150
Loading