Skip to content
Closed
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
54 changes: 54 additions & 0 deletions .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Smoke Test (Testnet11)

on:
workflow_dispatch:
inputs:
timeout:
description: 'Funding timeout (seconds)'
default: '900'
return_address:
description: 'Address to return remaining TXCH to after test'
default: ''

concurrency:
group: smoke-test

jobs:
smoke:
name: Testnet11 Smoke Test
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y jq curl libgtk-3-dev libjavascriptcoregtk-4.1-dev libwebkit2gtk-4.1-dev

- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-smoke-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-smoke-

- name: Build sage-cli
run: cargo build --release -p sage-cli

- name: Run smoke test
run: |
ARGS=""
if [[ -n "${{ inputs.timeout }}" ]]; then
ARGS="$ARGS --timeout ${{ inputs.timeout }}"
fi
if [[ -n "${{ inputs.return_address }}" ]]; then
ARGS="$ARGS --return-address ${{ inputs.return_address }}"
fi
./crates/sage-rpc/tests/smoke_test.sh $ARGS
4 changes: 4 additions & 0 deletions Cargo.lock

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

15 changes: 12 additions & 3 deletions crates/sage-cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
mod rpc;

use std::path::PathBuf;

use anyhow::Result;
use clap::Parser;
use rpc::RpcCommand;
use rustls::crypto::aws_lc_rs::default_provider;

#[derive(Debug, Parser)]
struct Args {
/// Override the data directory
#[clap(long, global = true)]
data_dir: Option<PathBuf>,
#[clap(subcommand)]
command: Command,
}
Expand All @@ -27,9 +32,13 @@ async fn main() -> Result<()> {

let args = Args::parse();

let path = dirs::data_dir()
.expect("could not get data directory")
.join("com.rigidnetwork.sage");
let path = if let Some(dir) = args.data_dir {
dir
} else {
dirs::data_dir()
.expect("could not get data directory")
.join("com.rigidnetwork.sage")
};

match args.command {
Command::Rpc { command } => command.handle(path).await?,
Expand Down
2 changes: 1 addition & 1 deletion crates/sage-cli/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl_endpoints! {
Ok(())
},
(repeat Self::Endpoint { body } => {
let client = Client::new()?;
let client = Client::from_dir(&path)?;
handle(client.endpoint(body).await);
Ok(())
} ,)
Expand Down
9 changes: 9 additions & 0 deletions crates/sage-rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,12 @@ rustls-pemfile = { workspace = true }
utoipa = "5.2.0"
serde_json = { workspace = true }
indexmap = { workspace = true }

[dev-dependencies]
tower = { version = "0.5", features = ["util"] }
http-body-util = "0.1"
hyper = "1"
tempfile = "3"
serde_json = { workspace = true }
sage-api = { workspace = true }
tokio = { workspace = true, features = ["full", "test-util"] }
7 changes: 6 additions & 1 deletion crates/sage-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ impl_endpoints! {
}
}

/// Creates the API router without TLS. Used by integration tests.
pub fn make_router(sage: Arc<Mutex<Sage>>) -> Router {
api_router().with_state(AppState { sage })
}

fn handle<T>(value: sage::Result<T>) -> Response
where
T: Serialize,
Expand Down Expand Up @@ -80,7 +85,7 @@ pub async fn start_rpc(sage: Arc<Mutex<Sage>>) -> Result<()> {

drop(app);

let router = api_router().with_state(AppState { sage });
let router = make_router(sage);

axum_server::bind_rustls(addr, RustlsConfig::from_config(Arc::new(config)))
.serve(router.into_make_service())
Expand Down
Loading