Skip to content

Commit

Permalink
Merge pull request #1190 from getlipa/feature/greenlight-monitoring-t…
Browse files Browse the repository at this point in the history
…ests

Add E2E tests to periodically test GL/Breez/Backend-integration
  • Loading branch information
gcomte authored Sep 19, 2024
2 parents 586909e + c04a8dc commit 3b06a95
Show file tree
Hide file tree
Showing 11 changed files with 389 additions and 22 deletions.
5 changes: 3 additions & 2 deletions .cargo/config.toml.breez.sample
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ BREEZ_SDK_API_KEY = ""
BREEZ_SDK_PARTNER_CERTIFICATE = ""
BREEZ_SDK_PARTNER_KEY = ""

BREEZ_SDK_MNEMONIC_ALICE = ""
BREEZ_SDK_MNEMONIC_BOB = ""
BREEZ_SDK_MNEMONIC_EMPTY = ""
BREEZ_SDK_MNEMONIC_FUNDED_SENDER = ""
BREEZ_SDK_MNEMONIC_FUNDED_RECEIVER = ""
34 changes: 34 additions & 0 deletions .github/workflows/e2e_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: E2E Tests

on:
push:
branches:
- main
pull_request:
schedule:
- cron: '21 2 * * *' # every day at 5:21 AM UTC

env:
GITHUB_REF: ${{ github.ref }}

jobs:
integration:
name: E2E Tests
runs-on: ubuntu-latest
steps:
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- name: Config cargo
run: echo -e "$CARGO_CONFIG_TOML_BREEZ" > .cargo/config.toml
env:
CARGO_CONFIG_TOML_BREEZ: ${{ secrets.CARGO_CONFIG_TOML_BREEZ }}
- name: Rust Cache
uses: Swatinem/rust-cache@v2.7.0
- name: Run e2e tests
run: make testsatflows
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ integrationtests:
testregisternode:
cargo test --test register_node_test -- --ignored --nocapture

.PHONY: testsatflows
testsatflows:
cargo test --test sat_flows -- --ignored --nocapture

.PHONY: testall
testall: test integrationtests

Expand Down
1 change: 1 addition & 0 deletions src/task_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ impl TaskManager {
Ok(Ok(rates)) => {
persist_exchange_rates(&data_store, &rates);
*exchange_rates.lock_unwrap() = rates;
debug!("Updated exchange rates successfully");
}
Ok(Err(e)) => {
error!("Failed to update exchange rates: {e}");
Expand Down
4 changes: 2 additions & 2 deletions tests/decode_test.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
mod print_events_handler;
mod setup;

use crate::setup::start_alice;
use crate::setup::start_node;

use breez_sdk_core::Network;
use serial_test::file_serial;
Expand All @@ -11,7 +11,7 @@ use uniffi_lipalightninglib::{DecodeDataError, DecodedData, InvoiceDetails, Unsu
#[test]
#[file_serial(key, path => "/tmp/3l-int-tests-lock")]
fn test_decoding() {
let node = start_alice().unwrap();
let node = start_node().unwrap();

let invalid_invoice = "invalid".to_string();
let result = node.decode_data(invalid_invoice);
Expand Down
4 changes: 2 additions & 2 deletions tests/node_info_test.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
mod print_events_handler;
mod setup;

use crate::setup::start_alice;
use crate::setup::start_node;

use bitcoin::secp256k1::PublicKey;
use serial_test::file_serial;
Expand All @@ -10,7 +10,7 @@ use std::str::FromStr;
#[test]
#[file_serial(key, path => "/tmp/3l-int-tests-lock")]
fn test_get_node_info() {
let node = start_alice().unwrap();
let node = start_node().unwrap();
let node_info = node.get_node_info().unwrap();

assert!(
Expand Down
4 changes: 2 additions & 2 deletions tests/payment_fetching_test.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
mod print_events_handler;
mod setup;

use crate::setup::start_alice;
use crate::setup::start_node;

use serial_test::file_serial;
use uniffi_lipalightninglib::{Activity, InvoiceCreationMetadata};

#[test]
#[file_serial(key, path => "/tmp/3l-int-tests-lock")]
fn test_payment_fetching() {
let node = start_alice().unwrap();
let node = start_node().unwrap();

let invoice = node
.create_invoice(
Expand Down
4 changes: 2 additions & 2 deletions tests/receive_onchain_test.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
mod print_events_handler;
mod setup;

use crate::setup::start_alice;
use crate::setup::start_node;

use serial_test::file_serial;

#[test]
#[file_serial(key, path => "/tmp/3l-int-tests-lock")]
fn test_receive_onchain() {
let node = start_alice().unwrap();
let node = start_node().unwrap();

let swap_info = node.generate_swap_address(None).unwrap();
assert!(swap_info.address.starts_with("bc1"));
Expand Down
Loading

0 comments on commit 3b06a95

Please sign in to comment.