mirror of
https://github.com/fluencelabs/marine-rs-sdk-test
synced 2024-12-04 23:30:18 +00:00
fix serde behaviour in fce_test
This commit is contained in:
parent
5fc6cf07d7
commit
3d884e5791
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "fluence-sdk-test-macro-impl"
|
||||
version = "0.1.0" # remember to update html_root_url
|
||||
version = "0.1.2" # remember to update html_root_url
|
||||
edition = "2018"
|
||||
description = "Implementation of the `#[fce_test]` macro"
|
||||
repository = "https://github.com/fluencelabs/rust-sdk/crates/macro-test"
|
||||
|
@ -55,14 +55,14 @@ use std::path::Path;
|
||||
///
|
||||
/// pub fn greeting(&mut self, name: String) -> String {
|
||||
/// use std::ops::DerefMut;
|
||||
/// let arguments = fluence_test::internal::json!([name]);
|
||||
/// let arguments = fluence_test::internal::serde_json::json!([name]);
|
||||
/// let result = self
|
||||
/// .fce
|
||||
/// .as_ref
|
||||
/// .borrow_mut()
|
||||
/// .call_with_module_name("greeting", "greeting", arguments, <_>::default())
|
||||
/// .expect("call to FCE failed");
|
||||
/// let result: String = serde_json::from_value(result)
|
||||
/// let result: String = fluence_test::internal::serde_json::from_value(result)
|
||||
/// .expect("the default deserializer shouldn't fail");
|
||||
/// result
|
||||
/// }
|
||||
|
@ -39,14 +39,14 @@ use quote::quote;
|
||||
///
|
||||
/// pub fn greeting(&mut self, name: String) -> String {
|
||||
/// use std::ops::DerefMut;
|
||||
/// let arguments = fluence_test::internal::json!([name]);
|
||||
/// let arguments = fluence_test::internal::serde_json::json!([name]);
|
||||
/// let result = self
|
||||
/// .fce
|
||||
/// .as_ref
|
||||
/// .borrow_mut()
|
||||
/// .call_with_module_name("greeting", "greeting", arguments, <_>::default())
|
||||
/// .expect("call to FCE failed");
|
||||
/// let result: String = serde_json::from_value(result)
|
||||
/// let result: String = fluence_test::internal::serde_json::from_value(result)
|
||||
/// .expect("the default deserializer shouldn't fail");
|
||||
/// result
|
||||
/// }
|
||||
|
@ -85,13 +85,13 @@ fn generate_arguments_converter<'a>(
|
||||
let arg_idents: Vec<syn::Ident> = args.map(utils::new_ident).collect::<Result<_, _>>()?;
|
||||
|
||||
let args_converter =
|
||||
quote! { let arguments = fluence_test::internal::json!([#(#arg_idents),*]); };
|
||||
quote! { let arguments = fluence_test::internal::serde_json::json!([#(#arg_idents),*]); };
|
||||
|
||||
Ok(args_converter)
|
||||
}
|
||||
|
||||
fn generate_function_call(module_name: &str, method_name: &str) -> TokenStream {
|
||||
quote! { self.fce.as_ref().borrow_mut().call_with_module_name(#module_name, #method_name, arguments, <_>::default()).expect("call to FCE failed"); }
|
||||
quote! { self.fce.as_ref().borrow_mut().call_module(#module_name, #method_name, arguments, <_>::default()).expect("call to FCE failed"); }
|
||||
}
|
||||
|
||||
fn generate_set_result(output_type: &Option<&IType>) -> TokenStream {
|
||||
@ -109,7 +109,7 @@ fn generate_convert_to_output(
|
||||
Some(ty) => {
|
||||
let ty = utils::itype_to_tokens(ty, records)?;
|
||||
quote! {
|
||||
let result: #ty = serde_json::from_value(result).expect("the default deserializer shouldn't fail");
|
||||
let result: #ty = fluence_test::internal::serde_json::from_value(result).expect("the default deserializer shouldn't fail");
|
||||
}
|
||||
}
|
||||
None => TokenStream::new(),
|
||||
|
@ -31,7 +31,8 @@ pub(super) fn generate_records(records: &FCERecordTypes) -> TResult<Vec<TokenStr
|
||||
let fields = prepare_field(record.fields.deref().iter(), records)?;
|
||||
|
||||
let generated_record = quote! {
|
||||
#[derive(Clone, fluence_test::internal::Serialize, fluence_test::internal::Deserialize)]
|
||||
#[derive(Clone, fluence_test::internal::serde::Serialize, fluence_test::internal::serde::Deserialize)]
|
||||
#[serde(crate = "fluence_test::internal::serde")]
|
||||
pub struct #record_name_ident {
|
||||
#(#fields),*
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "fluence-sdk-test-macro"
|
||||
version = "0.1.0" # remember to update html_root_url
|
||||
version = "0.1.2" # remember to update html_root_url
|
||||
edition = "2018"
|
||||
description = "Definition of the `#[fce_test]` macro"
|
||||
repository = "https://github.com/fluencelabs/rust-sdk/crates/macro-test"
|
||||
@ -17,7 +17,7 @@ proc-macro = true
|
||||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
fluence-sdk-test-macro-impl = { path = "../fce-test-macro-impl", version = "0.1.0" }
|
||||
fluence-sdk-test-macro-impl = { path = "../fce-test-macro-impl", version = "0.1.2" }
|
||||
|
||||
quote = "1.0.9"
|
||||
proc-macro2 = "1.0.24"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "fluence-test"
|
||||
version = "0.1.0" # remember to update html_root_url
|
||||
version = "0.1.2" # remember to update html_root_url
|
||||
description = "Fluence backend SDK for testing"
|
||||
documentation = "https://docs.rs/fluence/"
|
||||
repository = "https://github.com/fluencelabs/rust-sdk"
|
||||
@ -19,7 +19,7 @@ path = "src/lib.rs"
|
||||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
fluence-sdk-test-macro = { path = "../crates/fce-test-macro", version = "0.1.0" }
|
||||
fluence-sdk-test-macro = { path = "../crates/fce-test-macro", version = "0.1.2" }
|
||||
fluence-app-service = { version = "0.7.0", features = ["raw-module-api"] }
|
||||
|
||||
serde = { version = "1.0.118", features = ["derive"] }
|
||||
|
@ -34,9 +34,8 @@ pub mod internal {
|
||||
pub use fluence_app_service::AppService;
|
||||
pub use fluence_app_service::TomlAppServiceConfig;
|
||||
|
||||
pub use serde::Serialize;
|
||||
pub use serde::Deserialize;
|
||||
pub use serde_json::json;
|
||||
pub use serde;
|
||||
pub use serde_json;
|
||||
|
||||
pub use uuid::Uuid;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user