diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 47878b0..e831924 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,9 +14,6 @@ jobs: runs-on: ubuntu-latest - strategy: - matrix: - args: ["--all-features"] env: FREENET_LOG: error CARGO_TARGET_DIR: ${{ github.workspace }}/target @@ -37,7 +34,7 @@ jobs: - uses: Swatinem/rust-cache@v2 - name: Test - features - run: cargo test --workspace ${{ matrix.args }} + run: cargo test --workspace --features contract,net,testing,trace build_targets: name: Build targets diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 79539ca..8746bd6 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -70,3 +70,4 @@ freenet-main-contract = [] net = ["dep:tokio", "dep:tokio-tungstenite", "dep:wasm-bindgen", "dep:web-sys", "dep:js-sys", "dep:serde-wasm-bindgen"] testing = ["dep:arbitrary"] trace = [] +wasmer-tests = [] diff --git a/rust/src/client_api/client_events.rs b/rust/src/client_api/client_events.rs index d2878d2..2dc3071 100644 --- a/rust/src/client_api/client_events.rs +++ b/rust/src/client_api/client_events.rs @@ -54,7 +54,7 @@ use crate::{ use super::WsApiError; -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize, Clone)] pub struct ClientError { kind: Box, } @@ -321,7 +321,7 @@ impl ClientRequest<'_> { matches!(self, Self::Disconnect { .. }) } - pub fn try_decode_fbs(msg: &[u8]) -> Result { + pub fn try_decode_fbs(msg: &[u8]) -> Result, WsApiError> { let req = { match root_as_client_request(msg) { Ok(client_request) => match client_request.client_request_type() { @@ -707,7 +707,7 @@ impl<'a> TryFromFbs<&FbsDelegateRequest<'a>> for DelegateRequest<'a> { } /// A response to a previous [`ClientRequest`] -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, Clone)] #[non_exhaustive] pub enum HostResponse { ContractResponse(#[serde(bound(deserialize = "T: DeserializeOwned"))] ContractResponse), @@ -722,7 +722,7 @@ pub enum HostResponse { type Peer = String; -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, Clone)] pub enum QueryResponse { ConnectedPeers { peers: Vec<(Peer, SocketAddr)> }, NetworkDebug(NetworkDebugInfo), diff --git a/rust/src/contract_interface.rs b/rust/src/contract_interface.rs index 0a3710c..c8047d6 100644 --- a/rust/src/contract_interface.rs +++ b/rust/src/contract_interface.rs @@ -1554,11 +1554,11 @@ pub(crate) mod wasm_interface { mod test { use super::*; use once_cell::sync::Lazy; - use rand::{rngs::SmallRng, Rng, SeedableRng}; + use rand::{rng, rngs::SmallRng, Rng, SeedableRng}; static RND_BYTES: Lazy<[u8; 1024]> = Lazy::new(|| { let mut bytes = [0; 1024]; - let mut rng = SmallRng::from_os_rng(); + let mut rng = SmallRng::from_rng(&mut rng()); rng.fill(&mut bytes); bytes }); diff --git a/rust/src/delegate_interface.rs b/rust/src/delegate_interface.rs index 272a58d..3f67591 100644 --- a/rust/src/delegate_interface.rs +++ b/rust/src/delegate_interface.rs @@ -40,7 +40,7 @@ impl Delegate<'_> { &self.key } - pub fn code(&self) -> &DelegateCode { + pub fn code(&self) -> &DelegateCode<'_> { &self.data } @@ -48,7 +48,7 @@ impl Delegate<'_> { &self.data.code_hash } - pub fn params(&self) -> &Parameters { + pub fn params(&self) -> &Parameters<'_> { &self.parameters } diff --git a/rust/src/generated/client_request_generated.rs b/rust/src/generated/client_request_generated.rs index c71edfd..bb81ae4 100644 --- a/rust/src/generated/client_request_generated.rs +++ b/rust/src/generated/client_request_generated.rs @@ -4707,7 +4707,7 @@ pub mod client_request { /// `root_as_client_request_unchecked`. pub fn root_as_client_request( buf: &[u8], - ) -> Result { + ) -> Result, flatbuffers::InvalidFlatbuffer> { flatbuffers::root::(buf) } #[inline] @@ -4719,7 +4719,7 @@ pub mod client_request { /// `size_prefixed_root_as_client_request_unchecked`. pub fn size_prefixed_root_as_client_request( buf: &[u8], - ) -> Result { + ) -> Result, flatbuffers::InvalidFlatbuffer> { flatbuffers::size_prefixed_root::(buf) } #[inline] @@ -4752,14 +4752,14 @@ pub mod client_request { /// Assumes, without verification, that a buffer of bytes contains a ClientRequest and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid `ClientRequest`. - pub unsafe fn root_as_client_request_unchecked(buf: &[u8]) -> ClientRequest { + pub unsafe fn root_as_client_request_unchecked(buf: &[u8]) -> ClientRequest<'_> { flatbuffers::root_unchecked::(buf) } #[inline] /// Assumes, without verification, that a buffer of bytes contains a size prefixed ClientRequest and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid size prefixed `ClientRequest`. - pub unsafe fn size_prefixed_root_as_client_request_unchecked(buf: &[u8]) -> ClientRequest { + pub unsafe fn size_prefixed_root_as_client_request_unchecked(buf: &[u8]) -> ClientRequest<'_> { flatbuffers::size_prefixed_root_unchecked::(buf) } #[inline] diff --git a/rust/src/generated/host_response_generated.rs b/rust/src/generated/host_response_generated.rs index d9f75cb..af9cc75 100644 --- a/rust/src/generated/host_response_generated.rs +++ b/rust/src/generated/host_response_generated.rs @@ -3338,7 +3338,7 @@ pub mod host_response { /// `root_as_host_response_unchecked`. pub fn root_as_host_response( buf: &[u8], - ) -> Result { + ) -> Result, flatbuffers::InvalidFlatbuffer> { flatbuffers::root::(buf) } #[inline] @@ -3350,7 +3350,7 @@ pub mod host_response { /// `size_prefixed_root_as_host_response_unchecked`. pub fn size_prefixed_root_as_host_response( buf: &[u8], - ) -> Result { + ) -> Result, flatbuffers::InvalidFlatbuffer> { flatbuffers::size_prefixed_root::(buf) } #[inline] @@ -3383,14 +3383,14 @@ pub mod host_response { /// Assumes, without verification, that a buffer of bytes contains a HostResponse and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid `HostResponse`. - pub unsafe fn root_as_host_response_unchecked(buf: &[u8]) -> HostResponse { + pub unsafe fn root_as_host_response_unchecked(buf: &[u8]) -> HostResponse<'_> { flatbuffers::root_unchecked::(buf) } #[inline] /// Assumes, without verification, that a buffer of bytes contains a size prefixed HostResponse and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid size prefixed `HostResponse`. - pub unsafe fn size_prefixed_root_as_host_response_unchecked(buf: &[u8]) -> HostResponse { + pub unsafe fn size_prefixed_root_as_host_response_unchecked(buf: &[u8]) -> HostResponse<'_> { flatbuffers::size_prefixed_root_unchecked::(buf) } #[inline] diff --git a/rust/src/memory/buf.rs b/rust/src/memory/buf.rs index 3345258..c637bb7 100644 --- a/rust/src/memory/buf.rs +++ b/rust/src/memory/buf.rs @@ -340,7 +340,7 @@ fn __frnt__initiate_buffer(capacity: u32) -> i64 { buffer as i64 } -#[cfg(all(test, any(unix, windows)))] +#[cfg(all(test, any(unix, windows), feature = "wasmer-tests"))] mod test { use super::*; use wasmer::{ diff --git a/rust/src/versioning.rs b/rust/src/versioning.rs index b92dc99..7fea6b8 100644 --- a/rust/src/versioning.rs +++ b/rust/src/versioning.rs @@ -50,7 +50,7 @@ impl DelegateContainer { } } - pub fn code(&self) -> &DelegateCode { + pub fn code(&self) -> &DelegateCode<'_> { match self { Self::Wasm(DelegateWasmAPIVersion::V1(delegate_v1)) => delegate_v1.code(), }