From 333136a23fa46c00368ff5dda3ac0dd39dc155f8 Mon Sep 17 00:00:00 2001 From: Augustinas Bacvinka Date: Thu, 5 Jan 2023 15:29:52 +0200 Subject: [PATCH 1/7] Use correct binding inside waku_stop method --- waku-bindings/src/node/management.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/waku-bindings/src/node/management.rs b/waku-bindings/src/node/management.rs index cd79754..fe485ce 100644 --- a/waku-bindings/src/node/management.rs +++ b/waku-bindings/src/node/management.rs @@ -43,7 +43,7 @@ pub fn waku_start() -> Result { /// Stops a Waku node /// as per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_stop) pub fn waku_stop() -> Result { - let response = unsafe { CStr::from_ptr(waku_sys::waku_start()) } + let response = unsafe { CStr::from_ptr(waku_sys::waku_stop()) } .to_str() .expect("Response should always succeed to load to a &str"); From b324908425829e86dd57270da6a604ef7817f735 Mon Sep 17 00:00:00 2001 From: Augustinas Bacvinka Date: Thu, 5 Jan 2023 17:53:49 +0200 Subject: [PATCH 2/7] Run waku node related tests in sequence --- Cargo.lock | 143 +++++++++++++++++++++++++++ waku-bindings/Cargo.toml | 3 + waku-bindings/src/node/management.rs | 2 + waku-bindings/src/node/mod.rs | 2 + 4 files changed, 150 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index d42df85..2eccbc5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -337,6 +337,19 @@ dependencies = [ "syn", ] +[[package]] +name = "dashmap" +version = "5.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "907076dfda823b0b36d2a1bb5f90c96660a5bbcd7729e10727f07858f22c4edc" +dependencies = [ + "cfg-if", + "hashbrown", + "lock_api", + "once_cell", + "parking_lot_core", +] + [[package]] name = "data-encoding" version = "2.3.2" @@ -378,6 +391,83 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "futures" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38390104763dc37a5145a53c29c63c1290b5d316d6086ec32c293f6736051bb0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" + +[[package]] +name = "futures-executor" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7acc85df6714c176ab5edf386123fafe217be88c0840ec11f199441134a074e2" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" + +[[package]] +name = "futures-sink" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" + +[[package]] +name = "futures-task" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" + +[[package]] +name = "futures-util" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + [[package]] name = "generic-array" version = "0.14.6" @@ -415,6 +505,12 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + [[package]] name = "hex" version = "0.4.3" @@ -698,6 +794,18 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + [[package]] name = "polyval" version = "0.6.0" @@ -923,6 +1031,31 @@ dependencies = [ "serde", ] +[[package]] +name = "serial_test" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c789ec87f4687d022a2405cf46e0cd6284889f1839de292cadeb6c6019506f2" +dependencies = [ + "dashmap", + "futures", + "lazy_static", + "log", + "parking_lot", + "serial_test_derive", +] + +[[package]] +name = "serial_test_derive" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b64f9e531ce97c88b4778aad0ceee079216071cffec6ac9b904277f8f92e7fe3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "shlex" version = "1.1.0" @@ -959,6 +1092,15 @@ dependencies = [ "libc", ] +[[package]] +name = "slab" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg", +] + [[package]] name = "smallvec" version = "1.10.0" @@ -1215,6 +1357,7 @@ dependencies = [ "secp256k1", "serde", "serde_json", + "serial_test", "smart-default", "sscanf", "url", diff --git a/waku-bindings/Cargo.toml b/waku-bindings/Cargo.toml index ac57668..d08d67d 100644 --- a/waku-bindings/Cargo.toml +++ b/waku-bindings/Cargo.toml @@ -26,3 +26,6 @@ sscanf = "0.3" smart-default = "0.6" url = "2.3" waku-sys = { version = "0.1.0-beta1", path = "../waku-sys" } + +[dev-dependencies] +serial_test = "0.10.0" diff --git a/waku-bindings/src/node/management.rs b/waku-bindings/src/node/management.rs index fe485ce..3bcfb36 100644 --- a/waku-bindings/src/node/management.rs +++ b/waku-bindings/src/node/management.rs @@ -82,8 +82,10 @@ pub fn waku_listen_addresses() -> Result> { mod test { use super::waku_new; use crate::node::management::{waku_listen_addresses, waku_peer_id, waku_start, waku_stop}; + use serial_test::serial; #[test] + #[serial] fn waku_flow() { waku_new(None).unwrap(); waku_start().unwrap(); diff --git a/waku-bindings/src/node/mod.rs b/waku-bindings/src/node/mod.rs index 4f247df..ab9e94f 100644 --- a/waku-bindings/src/node/mod.rs +++ b/waku-bindings/src/node/mod.rs @@ -326,8 +326,10 @@ pub fn waku_new(config: Option) -> Result Date: Thu, 5 Jan 2023 18:26:54 +0200 Subject: [PATCH 4/7] CI content_topic test --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7626241..fbf9590 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -75,7 +75,7 @@ jobs: - uses: actions-rs/cargo@v1 continue-on-error: false with: - command: test + command: test content_topic lints: @@ -109,4 +109,4 @@ jobs: continue-on-error: false with: command: clippy - args: -- --deny warnings \ No newline at end of file + args: -- --deny warnings From 55be05662085015567f63338354e8445f5e1e8eb Mon Sep 17 00:00:00 2001 From: Augustinas Bacvinka Date: Thu, 5 Jan 2023 18:35:43 +0200 Subject: [PATCH 5/7] CI content_topic test --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fbf9590..f8aa931 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -75,7 +75,8 @@ jobs: - uses: actions-rs/cargo@v1 continue-on-error: false with: - command: test content_topic + command: test + args: content_topic lints: From ac5ef9f171a409ff9a1e8bdaf5e7ef9de452486f Mon Sep 17 00:00:00 2001 From: Augustinas Bacvinka Date: Thu, 5 Jan 2023 18:54:17 +0200 Subject: [PATCH 6/7] Revert to testing all in CI --- .github/workflows/main.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f8aa931..1bd790d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -76,8 +76,6 @@ jobs: continue-on-error: false with: command: test - args: content_topic - lints: name: Rust lints From e2ef9f407fb82ad590c38911952b3870042c2e84 Mon Sep 17 00:00:00 2001 From: Augustinas Bacvinka Date: Thu, 5 Jan 2023 18:55:05 +0200 Subject: [PATCH 7/7] Remove content_topic test --- waku-bindings/src/lib.rs | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/waku-bindings/src/lib.rs b/waku-bindings/src/lib.rs index a05d249..a43d3ab 100644 --- a/waku-bindings/src/lib.rs +++ b/waku-bindings/src/lib.rs @@ -19,27 +19,3 @@ pub use general::{ }; pub use events::{waku_set_event_callback, Event, Signal, WakuMessageEvent}; - -#[cfg(test)] -mod tests { - use std::ffi::CStr; - use std::os::raw::c_char; - use waku_sys::waku_content_topic; - - #[test] - fn content_topic() { - let topic = unsafe { - waku_content_topic( - "foo_bar".as_ptr() as *mut c_char, - 1, - "foo_topic".as_ptr() as *mut c_char, - "rfc26".as_ptr() as *mut c_char, - ) - }; - - let topic_str = unsafe { CStr::from_ptr(topic) } - .to_str() - .expect("Decoded return"); - println!("{}", topic_str); - } -}