Skip to content

Commit

Permalink
experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
insipx committed Jul 3, 2024
1 parent df53d91 commit 75911ed
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
10 changes: 1 addition & 9 deletions .github/workflows/test-ffi-bindings.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
name: Test FFI Bindings

on:
push:
branches:
- main

pull_request:
# only run tests when related changes are made
paths:
Expand All @@ -21,27 +19,22 @@ on:
- "Cargo.toml"
- "Cargo.lock"
- "rust-toolchain"

jobs:
test:
name: Test
runs-on: warp-ubuntu-latest-x64-16x
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Update rust toolchains
run: rustup update

- uses: Swatinem/rust-cache@v2
with:
workspaces: |
.
bindings_ffi
- name: Start Docker containers
run: dev/up

- name: Setup Kotlin
run: |
sudo apt update -q
Expand All @@ -50,8 +43,7 @@ jobs:
cd bindings_ffi
make install-jar
echo "$(make echo-jar | tail -n 1 | sed -e 's/\.*export //')" >> "$GITHUB_ENV"
- name: Run cargo test on FFI bindings
run: |
export CLASSPATH="${{ env.CLASSPATH }}"
cargo test --manifest-path bindings_ffi/Cargo.toml -- --test-threads=2
RUST_LOG=info,mls::tests=debug cargo test --manifest-path bindings_ffi/Cargo.toml -- --test-threads=2
1 change: 1 addition & 0 deletions bindings_ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ xmtp_proto = { path = "../xmtp_proto", features = ["proto_full", "grpc"] }
xmtp_user_preferences = { path = "../xmtp_user_preferences" }
xmtp_v2 = { path = "../xmtp_v2" }

tracing-subscriber = { "0.3", features = ["env-filter"] }
# NOTE: A regression in openssl-sys exists where libatomic is dynamically linked
# for i686-linux-android targets. https://github.com/sfackler/rust-openssl/issues/2163
#
Expand Down
12 changes: 10 additions & 2 deletions bindings_ffi/src/mls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ pub async fn create_client(
legacy_signed_private_key_proto: Option<Vec<u8>>,
history_sync_url: Option<String>,
) -> Result<Arc<FfiXmtpClient>, GenericError> {
init_logger(logger);
use tracing_subscriber::prelude::*;
//init_logger(logger);
let _ = tracing_subscriber::registry()
.with(tracing_subscriber::fmt::layer())
.with(tracing_subscriber::EnvFilter::from_default_env())
.try_init();
log::info!(
"Creating API client for host: {}, isSecure: {}",
host,
Expand Down Expand Up @@ -1933,16 +1938,19 @@ mod tests {

let stream_callback = RustStreamCallback::default();
let stream_closer = group.stream(Box::new(stream_callback.clone()));
log::info!("WAITING FOR READY");
stream_closer.wait_for_ready().await;

group.send("hello".as_bytes().to_vec()).await.unwrap();
log::info!("SEND HELLO");
stream_callback.wait_for_delivery().await;

group.send("goodbye".as_bytes().to_vec()).await.unwrap();
log::info!("SEND GOODBYE");
stream_callback.wait_for_delivery().await;

assert_eq!(stream_callback.message_count(), 5);
println!("WAITING FOR STREAM TO END");
log::info!("STREAM CLSOER");
stream_closer.end_and_wait().await.unwrap();
}

Expand Down

0 comments on commit 75911ed

Please sign in to comment.