Skip to content

Commit

Permalink
feat: Rust networking with reqwest running in iOS (#49)
Browse files Browse the repository at this point in the history
* feat: very initial http test

* feat: try to get networking selftest into xcframework

* fix: use int instead until we figure out ffi struct api
  • Loading branch information
Michael Xu authored Apr 13, 2023
1 parent 185a52f commit 9bbb6d5
Show file tree
Hide file tree
Showing 7 changed files with 906 additions and 9 deletions.
1 change: 1 addition & 0 deletions bindings/xmtp_rust_swift/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ edition = "2021"
[dependencies]
xmtp-keystore = { path = "../../crates/xmtp-keystore" }
corecrypto = { path = "../../crates/corecrypto" }
xmtp-networking = { path = "../../crates/xmtp-networking" }

[lib]
name = "xmtp_rust_swift"
Expand Down
2 changes: 2 additions & 0 deletions bindings/xmtp_rust_swift/include/xmtp_rust_swift.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
#include <stdint.h>
#include <stdlib.h>

// Functions
uint16_t networking_selftest(void);
bool encryption_selftest(void);
14 changes: 13 additions & 1 deletion bindings/xmtp_rust_swift/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use corecrypto::encryption;


#[no_mangle]
pub extern "C" fn encryption_selftest() -> bool {
// Simple key choice, same as previous test but I chopped a digit off the first column
Expand Down Expand Up @@ -44,7 +45,12 @@ pub extern "C" fn encryption_selftest() -> bool {
if decrypt_result.unwrap() != plaintext {
return false;
}
return true;
true
}

#[no_mangle]
pub extern "C" fn networking_selftest() -> u16 {
xmtp_networking::selftest()
}

#[cfg(test)]
Expand All @@ -55,4 +61,10 @@ mod tests {
fn test_encryption() {
assert!(encryption_selftest());
}

#[test]
fn test_networking() {
let status_code = networking_selftest();
assert_eq!(status_code, 200);
}
}
Loading

0 comments on commit 9bbb6d5

Please sign in to comment.