Skip to content

Commit

Permalink
[DRAFT] Complete e2e integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
DanGould committed Oct 7, 2022
1 parent 84af9f1 commit e3cf468
Show file tree
Hide file tree
Showing 9 changed files with 413 additions and 107 deletions.
206 changes: 206 additions & 0 deletions Cargo.lock

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

6 changes: 1 addition & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,4 @@ bitcoincore-rpc = "0.15.0"
tempfile = "3"
tonic = "0.6.2"
hyper = { version = "0.14.9", features = ["full"] }

# [test]
# name = "test"
# path = "tests/integration.rs"
# required-features = ["test_paths"]
hyper-tls = { version = "0.5.0" }
7 changes: 6 additions & 1 deletion src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ const STATIC_DIR: &str = "static";

/// Serve requests to Schedule and execute PayJoins with given options.
pub async fn serve(sched: Scheduler, bind_addr: SocketAddr) -> Result<(), hyper::Error> {
println!("starting server on: http://{}", bind_addr);
let new_service = make_service_fn(move |_| {
let sched = sched.clone();
async move {
println!("req on: http://");

let handler = move |req| handle_web_req(sched.clone(), req);
Ok::<_, hyper::Error>(service_fn(handler))
}
Expand Down Expand Up @@ -48,8 +51,10 @@ async fn handle_web_req(
}

(&Method::POST, "/pj") => {
dbg!(req.uri().query());
println!("post on: http://");

dbg!(req.uri().query());
println!("{:?}", req.uri().query());
let headers = Headers(req.headers().to_owned());
let query = {
let uri = req.uri();
Expand Down
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#[macro_use]
extern crate serde_derive;
extern crate configure_me;

pub mod scheduler;
pub mod http;
mod args;
pub mod lnd;
configure_me::include_config!();
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

let scheduled_pj = parse_args(args).expect("failed to parse remaining arguments");

let scheduler = Scheduler::from_config(&config);
let scheduler = Scheduler::from_config(&config).await?;

if let Some(payjoin) = scheduled_pj {
let address = scheduler.schedule_payjoin(&payjoin).await?;
Expand Down
4 changes: 4 additions & 0 deletions src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ pub struct ScheduledChannel {
}

impl ScheduledChannel {
pub fn new(node: P2PAddress, amount: bitcoin::Amount) -> Self {
Self { node, amount }
}

pub(crate) fn from_args(addr: &str, amount: &str) -> Result<Self, ArgError> {
let node = addr.parse::<P2PAddress>().map_err(ArgError::InvalidNodeAddress)?;

Expand Down
6 changes: 2 additions & 4 deletions tests/compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ services:
volumes:
- "./nginx/reverse-https-proxy.conf:/etc/nginx/nginx.conf"
- "./nginx/ssl:/etc/ssl"
expose:
- "3010"
- "3000"

ports:
- "3010:3010"
bitcoind:
restart: unless-stopped
image: btcpayserver/bitcoin:22.0
Expand Down
Loading

0 comments on commit e3cf468

Please sign in to comment.