diff --git a/src/lotus_json/actors/params/cron_params.rs b/src/lotus_json/actors/params/cron_params.rs index d1d9239aea72..418ef05ef751 100644 --- a/src/lotus_json/actors/params/cron_params.rs +++ b/src/lotus_json/actors/params/cron_params.rs @@ -7,7 +7,7 @@ use pastey::paste; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone)] +#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone, PartialEq)] #[serde(rename_all = "PascalCase")] pub struct CronConstructorParamsLotusJson { #[schemars(with = "LotusJson>")] @@ -19,58 +19,67 @@ macro_rules! impl_lotus_json_for_cron_constructor_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_cron_state::[]::ConstructorParams { - type LotusJson = CronConstructorParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - use crate::shim::address::Address; - vec![( - json!({ - "Entries": [ - { - "Receiver": "f01", - "MethodNum": 2 - }, - { - "Receiver": "f02", - "MethodNum": 3 - } - ] - }), - Self { - entries: vec![ - fil_actor_cron_state::[]::Entry { - receiver: Address::new_id(1).into(), - method_num: 2, - }, - fil_actor_cron_state::[]::Entry { - receiver: Address::new_id(2).into(), - method_num: 3, - }, - ], - }, - )] + mod [] { + use super::*; + type T = fil_actor_cron_state::[]::ConstructorParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - Self::LotusJson { - entries: self.entries.into_iter().map(Entry::[]).collect(), + impl HasLotusJson for T { + type LotusJson = CronConstructorParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + use crate::shim::address::Address; + vec![( + json!({ + "Entries": [ + { + "Receiver": "f01", + "MethodNum": 2 + }, + { + "Receiver": "f02", + "MethodNum": 3 + } + ] + }), + Self { + entries: vec![ + fil_actor_cron_state::[]::Entry { + receiver: Address::new_id(1).into(), + method_num: 2, + }, + fil_actor_cron_state::[]::Entry { + receiver: Address::new_id(2).into(), + method_num: 3, + }, + ], + }, + )] + } + + fn into_lotus_json(self) -> Self::LotusJson { + Self::LotusJson { + entries: self.entries.into_iter().map(Entry::[]).collect(), + } } - } - fn from_lotus_json(json: Self::LotusJson) -> Self { - Self { - entries: json.entries.into_iter().map(|entry| match entry { - Entry::[](e) => e, - _ => { - let lotus_entry = entry.into_lotus_json(); - fil_actor_cron_state::[]::Entry { - receiver: lotus_entry.receiver.into(), - method_num: lotus_entry.method_num, + fn from_lotus_json(json: Self::LotusJson) -> Self { + Self { + entries: json.entries.into_iter().map(|entry| match entry { + Entry::[](e) => e, + _ => { + let lotus_entry = entry.into_lotus_json(); + fil_actor_cron_state::[]::Entry { + receiver: lotus_entry.receiver.into(), + method_num: lotus_entry.method_num, + } } - } - }).collect(), + }).collect(), + } } } } diff --git a/src/lotus_json/actors/params/eam_params.rs b/src/lotus_json/actors/params/eam_params.rs index cc86d8102346..7b7ec7db3187 100644 --- a/src/lotus_json/actors/params/eam_params.rs +++ b/src/lotus_json/actors/params/eam_params.rs @@ -20,36 +20,45 @@ macro_rules! impl_eam_create_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_eam_state::[]::CreateParams { - type LotusJson = EAMCreateParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - json!({ - "Initcode": "ESIzRFU=", - "Nonce": 42 - }), - Self { - initcode: hex::decode("1122334455").unwrap(), - nonce: 42, - }, - ), - ] + mod [] { + use super::*; + type T = fil_actor_eam_state::[]::CreateParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - EAMCreateParamsLotusJson { - initcode: RawBytes::new(self.initcode), - nonce: self.nonce, + impl HasLotusJson for T { + type LotusJson = EAMCreateParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + json!({ + "Initcode": "ESIzRFU=", + "Nonce": 42 + }), + Self { + initcode: hex::decode("1122334455").unwrap(), + nonce: 42, + }, + ), + ] + } + + fn into_lotus_json(self) -> Self::LotusJson { + EAMCreateParamsLotusJson { + initcode: RawBytes::new(self.initcode), + nonce: self.nonce, + } } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - initcode: lotus_json.initcode.into(), - nonce: lotus_json.nonce, + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + initcode: lotus_json.initcode.into(), + nonce: lotus_json.nonce, + } } } } @@ -71,36 +80,45 @@ macro_rules! impl_eam_create2_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_eam_state::[]::Create2Params { - type LotusJson = EAMCreate2ParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - json!({ - "Initcode": "ESIzRFU=", - "Salt": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] - }), - Self { - initcode: hex::decode("1122334455").unwrap(), - salt: [0; 32], - }, - ), - ] + mod [] { + use super::*; + type T = fil_actor_eam_state::[]::Create2Params; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - EAMCreate2ParamsLotusJson { - initcode: self.initcode, - salt: self.salt, + impl HasLotusJson for T { + type LotusJson = EAMCreate2ParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + json!({ + "Initcode": "ESIzRFU=", + "Salt": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] + }), + Self { + initcode: hex::decode("1122334455").unwrap(), + salt: [0; 32], + }, + ), + ] + } + + fn into_lotus_json(self) -> Self::LotusJson { + EAMCreate2ParamsLotusJson { + initcode: self.initcode, + salt: self.salt, + } } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - initcode: lotus_json.initcode, - salt: lotus_json.salt, + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + initcode: lotus_json.initcode, + salt: lotus_json.salt, + } } } } @@ -121,25 +139,34 @@ macro_rules! impl_eam_create_external_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_eam_state::[]::CreateExternalParams { - type LotusJson = EAMCreateExternalParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - json!("ESIzRFU="), - Self(hex::decode("1122334455").unwrap()), - ), - ] + mod [] { + use super::*; + type T = fil_actor_eam_state::[]::CreateExternalParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - EAMCreateExternalParamsLotusJson(RawBytes::new(self.0)) - } + impl HasLotusJson for T { + type LotusJson = EAMCreateExternalParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + json!("ESIzRFU="), + Self(hex::decode("1122334455").unwrap()), + ), + ] + } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self(lotus_json.0.into()) + fn into_lotus_json(self) -> Self::LotusJson { + EAMCreateExternalParamsLotusJson(RawBytes::new(self.0)) + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self(lotus_json.0.into()) + } } } } diff --git a/src/lotus_json/actors/params/evm_params.rs b/src/lotus_json/actors/params/evm_params.rs index 58466bfa56eb..a030a19c3694 100644 --- a/src/lotus_json/actors/params/evm_params.rs +++ b/src/lotus_json/actors/params/evm_params.rs @@ -23,36 +23,45 @@ macro_rules! impl_evm_constructor_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_evm_state::[]::ConstructorParams { - type LotusJson = EVMConstructorParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - json!({ - "Creator": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], - "Initcode": "ESIzRFU=" - }), - Self { - creator: fil_actor_evm_state::evm_shared::[]::address::EthAddress([0; 20]), - initcode: RawBytes::new(hex::decode("1122334455").unwrap()), - }, - ), - ] + mod [] { + use super::*; + type T = fil_actor_evm_state::[]::ConstructorParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - EVMConstructorParamsLotusJson { - creator: self.creator.0, - initcode: self.initcode, + impl HasLotusJson for T { + type LotusJson = EVMConstructorParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + json!({ + "Creator": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], + "Initcode": "ESIzRFU=" + }), + Self { + creator: fil_actor_evm_state::evm_shared::[]::address::EthAddress([0; 20]), + initcode: RawBytes::new(hex::decode("1122334455").unwrap()), + }, + ), + ] } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - creator: fil_actor_evm_state::evm_shared::[]::address::EthAddress(lotus_json.creator), - initcode: lotus_json.initcode, + fn into_lotus_json(self) -> Self::LotusJson { + EVMConstructorParamsLotusJson { + creator: self.creator.0, + initcode: self.initcode, + } + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + creator: fil_actor_evm_state::evm_shared::[]::address::EthAddress(lotus_json.creator), + initcode: lotus_json.initcode, + } } } } @@ -79,47 +88,60 @@ pub struct EVMDelegateCallParamsLotusJson { } macro_rules! impl_evm_delegate_call_params_lotus_json { -($($version:literal),+) => { + ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_evm_state::[]::DelegateCallParams { - type LotusJson = EVMDelegateCallParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![( - json!({ - "Code": "bafy2bzaceaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "Input": "ESIzRFU=", - "Caller": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], - "Value": "0" - }), - Self { - code: Cid::default(), - input: hex::decode("1122334455").unwrap(), - caller: fil_actor_evm_state::evm_shared::[]::address::EthAddress([0; 20]), - value: TokenAmount::from_atto(0).into(), - }, - )] - } - - fn into_lotus_json(self) -> Self::LotusJson { - EVMDelegateCallParamsLotusJson { - code: self.code, - input: self.input.into(), - caller: self.caller.0, - value: self.value.into(), + mod [] { + use super::*; + type T = fil_actor_evm_state::[]::DelegateCallParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - code: lotus_json.code, - input: lotus_json.input.into(), - caller: fil_actor_evm_state::evm_shared::[]::address::EthAddress(lotus_json.caller), - value: lotus_json.value.into(), + + impl HasLotusJson for T { + type LotusJson = EVMDelegateCallParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![( + json!({ + "Code": { + "/": "baeaaaaa" + }, + "Input": "ESIzRFU=", + "Caller": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], + "Value": "0" + }), + Self { + code: Cid::default(), + input: hex::decode("1122334455").unwrap(), + caller: fil_actor_evm_state::evm_shared::[]::address::EthAddress([0; 20]), + value: TokenAmount::from_atto(0).into(), + }, + )] + } + + fn into_lotus_json(self) -> Self::LotusJson { + EVMDelegateCallParamsLotusJson { + code: self.code, + input: self.input.into(), + caller: self.caller.0, + value: self.value.into(), + } + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + code: lotus_json.code, + input: lotus_json.input.into(), + caller: fil_actor_evm_state::evm_shared::[]::address::EthAddress(lotus_json.caller), + value: lotus_json.value.into(), + } + } } } - }} + } )+ }; } @@ -156,3 +178,4 @@ impl HasLotusJson for GetStorageAtParams { .expect("expected array to have 32 elements") } } +crate::test_snapshots!(GetStorageAtParams); diff --git a/src/lotus_json/actors/params/init_params.rs b/src/lotus_json/actors/params/init_params.rs index 32b94795317c..0c433385aa95 100644 --- a/src/lotus_json/actors/params/init_params.rs +++ b/src/lotus_json/actors/params/init_params.rs @@ -50,32 +50,41 @@ macro_rules! impl_lotus_json_for_init_constructor_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_init_state::[]::ConstructorParams { - type LotusJson = InitConstructorParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - json!({ - "NetworkName": "calibnet", - }), - Self { - network_name: "calibnet".to_string(), - }, - ), - ] + mod [] { + use super::*; + type T = fil_actor_init_state::[]::ConstructorParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - Self::LotusJson { - network_name: self.network_name, + impl HasLotusJson for T { + type LotusJson = InitConstructorParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + json!({ + "NetworkName": "calibnet", + }), + Self { + network_name: "calibnet".to_string(), + }, + ), + ] + } + + fn into_lotus_json(self) -> Self::LotusJson { + Self::LotusJson { + network_name: self.network_name, + } } - } - fn from_lotus_json(json: Self::LotusJson) -> Self { - Self { - network_name: json.network_name, + fn from_lotus_json(json: Self::LotusJson) -> Self { + Self { + network_name: json.network_name, + } } } } @@ -88,38 +97,47 @@ macro_rules! impl_lotus_json_for_init_exec_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_init_state::[]::ExecParams { - type LotusJson = InitExecParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - json!({ - "CodeCID": { - "/": "baeaaaaa" - }, - "ConstructorParams": "ESIzRFU=", - }), - Self { - code_cid: Cid::default(), - constructor_params: RawBytes::new(hex::decode("1122334455").unwrap()), - }, - ), - ] + mod [] { + use super::*; + type T = fil_actor_init_state::[]::ExecParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - Self::LotusJson { - code_cid: self.code_cid, - constructor_params: self.constructor_params, + impl HasLotusJson for T { + type LotusJson = InitExecParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + json!({ + "CodeCID": { + "/": "baeaaaaa" + }, + "ConstructorParams": "ESIzRFU=", + }), + Self { + code_cid: Cid::default(), + constructor_params: RawBytes::new(hex::decode("1122334455").unwrap()), + }, + ), + ] } - } - fn from_lotus_json(json: Self::LotusJson) -> Self { - Self { - code_cid: json.code_cid, - constructor_params: json.constructor_params, + fn into_lotus_json(self) -> Self::LotusJson { + Self::LotusJson { + code_cid: self.code_cid, + constructor_params: self.constructor_params, + } + } + + fn from_lotus_json(json: Self::LotusJson) -> Self { + Self { + code_cid: json.code_cid, + constructor_params: json.constructor_params, + } } } } @@ -132,42 +150,51 @@ macro_rules! impl_lotus_json_for_init_exec4_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_init_state::[]::Exec4Params { - type LotusJson = InitExec4ParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - json!({ - "CodeCID": { - "/": "baeaaaaa" - }, - "ConstructorParams": "ESIzRFU=", - "SubAddress": "ESIzRFU=", - }), - Self { - code_cid: Cid::default(), - constructor_params: RawBytes::new(hex::decode("1122334455").unwrap()), - subaddress: RawBytes::new(hex::decode("1122334455").unwrap()), - }, - ), - ] + mod [] { + use super::*; + type T = fil_actor_init_state::[]::Exec4Params; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - Self::LotusJson { - code_cid: self.code_cid, - constructor_params: self.constructor_params, - sub_address: self.subaddress, + impl HasLotusJson for T { + type LotusJson = InitExec4ParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + json!({ + "CodeCID": { + "/": "baeaaaaa" + }, + "ConstructorParams": "ESIzRFU=", + "SubAddress": "ESIzRFU=", + }), + Self { + code_cid: Cid::default(), + constructor_params: RawBytes::new(hex::decode("1122334455").unwrap()), + subaddress: RawBytes::new(hex::decode("1122334455").unwrap()), + }, + ), + ] + } + + fn into_lotus_json(self) -> Self::LotusJson { + Self::LotusJson { + code_cid: self.code_cid, + constructor_params: self.constructor_params, + sub_address: self.subaddress, + } } - } - fn from_lotus_json(json: Self::LotusJson) -> Self { - Self { - code_cid: json.code_cid, - constructor_params: json.constructor_params, - subaddress: json.sub_address, + fn from_lotus_json(json: Self::LotusJson) -> Self { + Self { + code_cid: json.code_cid, + constructor_params: json.constructor_params, + subaddress: json.sub_address, + } } } } diff --git a/src/lotus_json/actors/params/market_params.rs b/src/lotus_json/actors/params/market_params.rs index 60db603acabd..5a9eb7e6024d 100644 --- a/src/lotus_json/actors/params/market_params.rs +++ b/src/lotus_json/actors/params/market_params.rs @@ -40,26 +40,36 @@ macro_rules! impl_lotus_json_for_add_balance_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_market_state::[]::AddBalanceParams { - type LotusJson = AddBalanceParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - serde_json::json!("f0100"), - Self { provider_or_client: Address::new_id(100).into() } - ), - ] - } + mod [] { + use super::*; + type T = fil_actor_market_state::[]::AddBalanceParams; + + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); + } + + impl HasLotusJson for T { + type LotusJson = AddBalanceParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + serde_json::json!("f0100"), + Self { provider_or_client: Address::new_id(100).into() } + ), + ] + } - fn into_lotus_json(self) -> Self::LotusJson { - AddBalanceParamsLotusJson(self.provider_or_client.into()) - } + fn into_lotus_json(self) -> Self::LotusJson { + AddBalanceParamsLotusJson(self.provider_or_client.into()) + } - fn from_lotus_json(json: Self::LotusJson) -> Self { - Self { - provider_or_client: json.0.into(), + fn from_lotus_json(json: Self::LotusJson) -> Self { + Self { + provider_or_client: json.0.into(), + } } } } @@ -72,34 +82,44 @@ macro_rules! impl_lotus_json_for_withdraw_balance_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_market_state::[]::WithdrawBalanceParams { - type LotusJson = WithdrawBalanceParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![( - json!({ - "ProviderOrClientAddress": "f01234", - "Amount": "1000000000000000000", - }), - Self{ - provider_or_client: Address::new_id(1234).into(), - amount: TokenAmount::from_atto(1000000000000000000u64).into(), - }, - )] - } + mod [] { + use super::*; + type T = fil_actor_market_state::[]::WithdrawBalanceParams; + + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); + } + + impl HasLotusJson for T { + type LotusJson = WithdrawBalanceParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![( + json!({ + "ProviderOrClientAddress": "f01234", + "Amount": "1000000000000000000", + }), + Self{ + provider_or_client: Address::new_id(1234).into(), + amount: TokenAmount::from_atto(1000000000000000000u64).into(), + }, + )] + } - fn into_lotus_json(self) -> Self::LotusJson { - Self::LotusJson { - provider_or_client: self.provider_or_client.into(), - amount: self.amount.into(), + fn into_lotus_json(self) -> Self::LotusJson { + Self::LotusJson { + provider_or_client: self.provider_or_client.into(), + amount: self.amount.into(), + } } - } - fn from_lotus_json(json: Self::LotusJson) -> Self { - Self { - provider_or_client: json.provider_or_client.into(), - amount: json.amount.into(), + fn from_lotus_json(json: Self::LotusJson) -> Self { + Self { + provider_or_client: json.provider_or_client.into(), + amount: json.amount.into(), + } } } } @@ -119,28 +139,38 @@ macro_rules! impl_lotus_json_for_label { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_market_state::[]::Label { - type LotusJson = LabelLotusJson; + mod [] { + use super::*; + type T = fil_actor_market_state::[]::Label; - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - (serde_json::json!("label-string"), Self::String("label-string".to_owned())), - (serde_json::json!([1,2,3]), Self::Bytes(vec![1,2,3])), - ] + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - match self { - Self::Bytes(bytes) => LabelLotusJson::Bytes(bytes), - Self::String(string) => LabelLotusJson::String(string), + impl HasLotusJson for T { + type LotusJson = LabelLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + (serde_json::json!("label-string"), Self::String("label-string".to_owned())), + (serde_json::json!([1,2,3]), Self::Bytes(vec![1,2,3])), + ] + } + + fn into_lotus_json(self) -> Self::LotusJson { + match self { + Self::Bytes(bytes) => LabelLotusJson::Bytes(bytes), + Self::String(string) => LabelLotusJson::String(string), + } } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - match lotus_json { - LabelLotusJson::Bytes(bytes) => Self::Bytes(bytes), - LabelLotusJson::String(string) => Self::String(string), + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + match lotus_json { + LabelLotusJson::Bytes(bytes) => Self::Bytes(bytes), + LabelLotusJson::String(string) => Self::String(string), + } } } } @@ -184,103 +214,113 @@ macro_rules! impl_lotus_json_for_deal_proposal { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_market_state::[]::DealProposal { - type LotusJson = DealProposalLotusJson; + mod [] { + use super::*; + type T = fil_actor_market_state::[]::DealProposal; - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - // Create minimal test data using Default where possible - - // Note: We need to create version-specific test data due to different fvm_shared versions - // For now, we'll use a minimal example that should work across versions - let test_cid = ::cid::Cid::try_from("baga6ea4seaqao7s73y24kcutaosvacpdjgfe5pw76ooefnyqw4ynr3d2y6x2mpq").unwrap(); - - vec![( - serde_json::json!({ - "PieceCID": { "/": test_cid.to_string() }, - "PieceSize": 1024, - "VerifiedDeal": false, - "Client": "f01234", - "Provider": "f05678", - "Label": "test", - "StartEpoch": 100, - "EndEpoch": 200, - "StoragePricePerEpoch": "1000", - "ProviderCollateral": "2000", - "ClientCollateral": "3000" - }), - // Create the corresponding object using from_lotus_json to ensure compatibility - Self::from_lotus_json(DealProposalLotusJson { - piece_cid: test_cid, - piece_size: 1024u64.into(), - verified_deal: false, - client: Address::new_id(1234).into(), - provider: Address::new_id(5678).into(), - label: LabelLotusJson::String("test".to_string()), - start_epoch: 100, - end_epoch: 200, - storage_price_per_epoch: TokenAmount::from_atto(1000u64).into(), - provider_collateral: TokenAmount::from_atto(2000u64).into(), - client_collateral: TokenAmount::from_atto(3000u64).into(), - }) - )] + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - let Self { - piece_cid, - piece_size, - verified_deal, - client, - provider, - label, - start_epoch, - end_epoch, - storage_price_per_epoch, - provider_collateral, - client_collateral, - } = self; - Self::LotusJson { - piece_cid: piece_cid.into(), - piece_size: piece_size.into(), - verified_deal: verified_deal.into(), - client: client.into(), - provider: provider.into(), - label: label.into_lotus_json(), - start_epoch: start_epoch.into(), - end_epoch: end_epoch.into(), - storage_price_per_epoch: storage_price_per_epoch.into(), - provider_collateral: provider_collateral.into(), - client_collateral: client_collateral.into(), + impl HasLotusJson for T { + type LotusJson = DealProposalLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + // Create minimal test data using Default where possible + + // Note: We need to create version-specific test data due to different fvm_shared versions + // For now, we'll use a minimal example that should work across versions + let test_cid = ::cid::Cid::try_from("baga6ea4seaqao7s73y24kcutaosvacpdjgfe5pw76ooefnyqw4ynr3d2y6x2mpq").unwrap(); + + vec![( + serde_json::json!({ + "PieceCID": { "/": test_cid.to_string() }, + "PieceSize": 1024, + "VerifiedDeal": false, + "Client": "f01234", + "Provider": "f05678", + "Label": "test", + "StartEpoch": 100, + "EndEpoch": 200, + "StoragePricePerEpoch": "1000", + "ProviderCollateral": "2000", + "ClientCollateral": "3000" + }), + // Create the corresponding object using from_lotus_json to ensure compatibility + Self::from_lotus_json(DealProposalLotusJson { + piece_cid: test_cid, + piece_size: 1024u64.into(), + verified_deal: false, + client: Address::new_id(1234).into(), + provider: Address::new_id(5678).into(), + label: LabelLotusJson::String("test".to_string()), + start_epoch: 100, + end_epoch: 200, + storage_price_per_epoch: TokenAmount::from_atto(1000u64).into(), + provider_collateral: TokenAmount::from_atto(2000u64).into(), + client_collateral: TokenAmount::from_atto(3000u64).into(), + }) + )] } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - let Self::LotusJson { - piece_cid, - piece_size, - verified_deal, - client, - provider, - label, - start_epoch, - end_epoch, - storage_price_per_epoch, - provider_collateral, - client_collateral, - } = lotus_json; - Self { - piece_cid, - piece_size: piece_size.into(), - verified_deal, - client: client.into(), - provider: provider.into(), - label: fil_actor_market_state::[]::Label::from_lotus_json(label), // delegate - start_epoch, - end_epoch, - storage_price_per_epoch: storage_price_per_epoch.into(), - provider_collateral: provider_collateral.into(), - client_collateral: client_collateral.into(), + fn into_lotus_json(self) -> Self::LotusJson { + let Self { + piece_cid, + piece_size, + verified_deal, + client, + provider, + label, + start_epoch, + end_epoch, + storage_price_per_epoch, + provider_collateral, + client_collateral, + } = self; + Self::LotusJson { + piece_cid: piece_cid.into(), + piece_size: piece_size.into(), + verified_deal: verified_deal.into(), + client: client.into(), + provider: provider.into(), + label: label.into_lotus_json(), + start_epoch: start_epoch.into(), + end_epoch: end_epoch.into(), + storage_price_per_epoch: storage_price_per_epoch.into(), + provider_collateral: provider_collateral.into(), + client_collateral: client_collateral.into(), + } + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + let Self::LotusJson { + piece_cid, + piece_size, + verified_deal, + client, + provider, + label, + start_epoch, + end_epoch, + storage_price_per_epoch, + provider_collateral, + client_collateral, + } = lotus_json; + Self { + piece_cid, + piece_size: piece_size.into(), + verified_deal, + client: client.into(), + provider: provider.into(), + label: fil_actor_market_state::[]::Label::from_lotus_json(label), // delegate + start_epoch, + end_epoch, + storage_price_per_epoch: storage_price_per_epoch.into(), + provider_collateral: provider_collateral.into(), + client_collateral: client_collateral.into(), + } } } } @@ -320,68 +360,78 @@ macro_rules! impl_lotus_json_for_client_deal_proposal { ($type_suffix:path: $lotus_json_type:ty: $($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_market_state::[]::ClientDealProposal { - type LotusJson = $lotus_json_type; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - // Use the same test data as DealProposal, but add a client signature - let test_cid = ::cid::Cid::try_from("baga6ea4seaqao7s73y24kcutaosvacpdjgfe5pw76ooefnyqw4ynr3d2y6x2mpq").unwrap(); + mod [] { + use super::*; + type T = fil_actor_market_state::[]::ClientDealProposal; - vec![( - serde_json::json!({ - "Proposal": { - "PieceCID": { "/": test_cid.to_string() }, - "PieceSize": 1024, - "VerifiedDeal": false, - "Client": "f01234", - "Provider": "f05678", - "Label": "test", - "StartEpoch": 100, - "EndEpoch": 200, - "StoragePricePerEpoch": "1000", - "ProviderCollateral": "2000", - "ClientCollateral": "3000" - }, - "ClientSignature": { - "Type": 1, - "Data": "dGVzdA==" // base64 for "test" - } - }), - // Create object using from_lotus_json to ensure compatibility - Self::from_lotus_json($lotus_json_type { - proposal: DealProposalLotusJson { - piece_cid: test_cid, - piece_size: 1024u64.into(), - verified_deal: false, - client: crate::shim::address::Address::new_id(1234).into(), - provider: crate::shim::address::Address::new_id(5678).into(), - label: LabelLotusJson::String("test".to_string()), - start_epoch: 100, - end_epoch: 200, - storage_price_per_epoch: crate::shim::econ::TokenAmount::from_atto(1000u64).into(), - provider_collateral: crate::shim::econ::TokenAmount::from_atto(2000u64).into(), - client_collateral: crate::shim::econ::TokenAmount::from_atto(3000u64).into(), - }, - client_signature: $type_suffix::Signature { - sig_type: $type_suffix::SignatureType::Secp256k1, - bytes: b"test".to_vec(), - }, - }) - )] + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - Self::LotusJson { - proposal: self.proposal.into_lotus_json(), - client_signature: self.client_signature.into(), + impl HasLotusJson for T { + type LotusJson = $lotus_json_type; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + // Use the same test data as DealProposal, but add a client signature + let test_cid = ::cid::Cid::try_from("baga6ea4seaqao7s73y24kcutaosvacpdjgfe5pw76ooefnyqw4ynr3d2y6x2mpq").unwrap(); + + vec![( + serde_json::json!({ + "Proposal": { + "PieceCID": { "/": test_cid.to_string() }, + "PieceSize": 1024, + "VerifiedDeal": false, + "Client": "f01234", + "Provider": "f05678", + "Label": "test", + "StartEpoch": 100, + "EndEpoch": 200, + "StoragePricePerEpoch": "1000", + "ProviderCollateral": "2000", + "ClientCollateral": "3000" + }, + "ClientSignature": { + "Type": 1, + "Data": "dGVzdA==" // base64 for "test" + } + }), + // Create object using from_lotus_json to ensure compatibility + Self::from_lotus_json($lotus_json_type { + proposal: DealProposalLotusJson { + piece_cid: test_cid, + piece_size: 1024u64.into(), + verified_deal: false, + client: crate::shim::address::Address::new_id(1234).into(), + provider: crate::shim::address::Address::new_id(5678).into(), + label: LabelLotusJson::String("test".to_string()), + start_epoch: 100, + end_epoch: 200, + storage_price_per_epoch: crate::shim::econ::TokenAmount::from_atto(1000u64).into(), + provider_collateral: crate::shim::econ::TokenAmount::from_atto(2000u64).into(), + client_collateral: crate::shim::econ::TokenAmount::from_atto(3000u64).into(), + }, + client_signature: $type_suffix::Signature { + sig_type: $type_suffix::SignatureType::Secp256k1, + bytes: b"test".to_vec(), + }, + }) + )] } - } - fn from_lotus_json(json: Self::LotusJson) -> Self { - Self { - proposal: fil_actor_market_state::[]::DealProposal::from_lotus_json(json.proposal), - client_signature: json.client_signature.into(), + fn into_lotus_json(self) -> Self::LotusJson { + Self::LotusJson { + proposal: self.proposal.into_lotus_json(), + client_signature: self.client_signature.into(), + } + } + + fn from_lotus_json(json: Self::LotusJson) -> Self { + Self { + proposal: fil_actor_market_state::[]::DealProposal::from_lotus_json(json.proposal), + client_signature: json.client_signature.into(), + } } } } @@ -412,76 +462,86 @@ macro_rules! impl_publish_storage_deals_params_snapshots_v2 { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_market_state::[]::PublishStorageDealsParams { - type LotusJson = PublishStorageDealsParamsV2LotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - json!({ - "Deals": [ - { - "Proposal": { - "PieceCID": { - "/": "baga6ea4seaqao7s73y24kcutaosvacpdjgfe5pw76ooefnyqw4ynr3d2y6x2mpq" + mod [] { + use super::*; + type T = fil_actor_market_state::[]::PublishStorageDealsParams; + + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); + } + + impl HasLotusJson for T { + type LotusJson = PublishStorageDealsParamsV2LotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + json!({ + "Deals": [ + { + "Proposal": { + "PieceCID": { + "/": "baga6ea4seaqao7s73y24kcutaosvacpdjgfe5pw76ooefnyqw4ynr3d2y6x2mpq" + }, + "PieceSize": 1024, + "VerifiedDeal": false, + "Client": "f17uoq6tp427uzv7fztkbsnn64iwotfrristwpryy", + "Provider": "f01000", + "Label": "test-deal", + "StartEpoch": 100, + "EndEpoch": 200, + "StoragePricePerEpoch": "1000", + "ProviderCollateral": "2000", + "ClientCollateral": "1500" }, - "PieceSize": 1024, - "VerifiedDeal": false, - "Client": "f17uoq6tp427uzv7fztkbsnn64iwotfrristwpryy", - "Provider": "f01000", - "Label": "test-deal", - "StartEpoch": 100, - "EndEpoch": 200, - "StoragePricePerEpoch": "1000", - "ProviderCollateral": "2000", - "ClientCollateral": "1500" - }, - "ClientSignature": { - "Type": 1, - "Data": "VGVzdCBzaWduYXR1cmU=" + "ClientSignature": { + "Type": 1, + "Data": "VGVzdCBzaWduYXR1cmU=" + } } - } - ] - }), - fil_actor_market_state::[]::PublishStorageDealsParams::from_lotus_json(PublishStorageDealsParamsV2LotusJson { - deals: vec![ - ClientDealProposalV2LotusJson { - proposal: DealProposalLotusJson { - piece_cid: "baga6ea4seaqao7s73y24kcutaosvacpdjgfe5pw76ooefnyqw4ynr3d2y6x2mpq".parse().unwrap(), - piece_size: 1024u64.into(), - verified_deal: false, - client: "f17uoq6tp427uzv7fztkbsnn64iwotfrristwpryy".parse().unwrap(), - provider: "f01000".parse().unwrap(), - label: LabelLotusJson::String("test-deal".to_string()), - start_epoch: ChainEpoch::from(100), - end_epoch: ChainEpoch::from(200), - storage_price_per_epoch: TokenAmount::from_atto(1000u64), - provider_collateral: TokenAmount::from_atto(2000u64), - client_collateral: TokenAmount::from_atto(1500u64), - }, - client_signature: fvm_shared2::crypto::signature::Signature { - sig_type: fvm_shared2::crypto::signature::SignatureType::Secp256k1, - bytes: b"Test signature".to_vec(), - }, - } - ] - }) - ) - ] - } + ] + }), + T::from_lotus_json(PublishStorageDealsParamsV2LotusJson { + deals: vec![ + ClientDealProposalV2LotusJson { + proposal: DealProposalLotusJson { + piece_cid: "baga6ea4seaqao7s73y24kcutaosvacpdjgfe5pw76ooefnyqw4ynr3d2y6x2mpq".parse().unwrap(), + piece_size: 1024u64.into(), + verified_deal: false, + client: "f17uoq6tp427uzv7fztkbsnn64iwotfrristwpryy".parse().unwrap(), + provider: "f01000".parse().unwrap(), + label: LabelLotusJson::String("test-deal".to_string()), + start_epoch: ChainEpoch::from(100), + end_epoch: ChainEpoch::from(200), + storage_price_per_epoch: TokenAmount::from_atto(1000u64), + provider_collateral: TokenAmount::from_atto(2000u64), + client_collateral: TokenAmount::from_atto(1500u64), + }, + client_signature: fvm_shared2::crypto::signature::Signature { + sig_type: fvm_shared2::crypto::signature::SignatureType::Secp256k1, + bytes: b"Test signature".to_vec(), + }, + } + ] + }) + ) + ] + } - fn into_lotus_json(self) -> Self::LotusJson { - Self::LotusJson { - deals: self.deals.into_iter().map(|d| d.into_lotus_json()).collect(), + fn into_lotus_json(self) -> Self::LotusJson { + Self::LotusJson { + deals: self.deals.into_iter().map(|d| d.into_lotus_json()).collect(), + } } - } - fn from_lotus_json(json: Self::LotusJson) -> Self { - Self { - deals: json.deals.into_iter() - .map(|d| fil_actor_market_state::[]::ClientDealProposal::from_lotus_json(d)) // delegate - .collect(), + fn from_lotus_json(json: Self::LotusJson) -> Self { + Self { + deals: json.deals.into_iter() + .map(|d| fil_actor_market_state::[]::ClientDealProposal::from_lotus_json(d)) // delegate + .collect(), + } } } } @@ -494,76 +554,86 @@ macro_rules! impl_publish_storage_deals_params_snapshots_v3 { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_market_state::[]::PublishStorageDealsParams { - type LotusJson = PublishStorageDealsParamsV3LotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - json!({ - "Deals": [ - { - "Proposal": { - "PieceCID": { - "/": "baga6ea4seaqao7s73y24kcutaosvacpdjgfe5pw76ooefnyqw4ynr3d2y6x2mpq" + mod [] { + use super::*; + type T = fil_actor_market_state::[]::PublishStorageDealsParams; + + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); + } + + impl HasLotusJson for T { + type LotusJson = PublishStorageDealsParamsV3LotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + json!({ + "Deals": [ + { + "Proposal": { + "PieceCID": { + "/": "baga6ea4seaqao7s73y24kcutaosvacpdjgfe5pw76ooefnyqw4ynr3d2y6x2mpq" + }, + "PieceSize": 1024, + "VerifiedDeal": false, + "Client": "f17uoq6tp427uzv7fztkbsnn64iwotfrristwpryy", + "Provider": "f01000", + "Label": "test-deal", + "StartEpoch": 100, + "EndEpoch": 200, + "StoragePricePerEpoch": "1000", + "ProviderCollateral": "2000", + "ClientCollateral": "1500" }, - "PieceSize": 1024, - "VerifiedDeal": false, - "Client": "f17uoq6tp427uzv7fztkbsnn64iwotfrristwpryy", - "Provider": "f01000", - "Label": "test-deal", - "StartEpoch": 100, - "EndEpoch": 200, - "StoragePricePerEpoch": "1000", - "ProviderCollateral": "2000", - "ClientCollateral": "1500" - }, - "ClientSignature": { - "Type": 1, - "Data": "VGVzdCBzaWduYXR1cmU=" + "ClientSignature": { + "Type": 1, + "Data": "VGVzdCBzaWduYXR1cmU=" + } } - } - ] - }), - fil_actor_market_state::[]::PublishStorageDealsParams::from_lotus_json(PublishStorageDealsParamsV3LotusJson { - deals: vec![ - ClientDealProposalV3LotusJson { - proposal: DealProposalLotusJson { - piece_cid: "baga6ea4seaqao7s73y24kcutaosvacpdjgfe5pw76ooefnyqw4ynr3d2y6x2mpq".parse().unwrap(), - piece_size: 1024u64.into(), - verified_deal: false, - client: "f17uoq6tp427uzv7fztkbsnn64iwotfrristwpryy".parse().unwrap(), - provider: "f01000".parse().unwrap(), - label: LabelLotusJson::String("test-deal".to_string()), - start_epoch: ChainEpoch::from(100), - end_epoch: ChainEpoch::from(200), - storage_price_per_epoch: TokenAmount::from_atto(1000u64), - provider_collateral: TokenAmount::from_atto(2000u64), - client_collateral: TokenAmount::from_atto(1500u64), - }, - client_signature: fvm_shared3::crypto::signature::Signature { - sig_type: fvm_shared3::crypto::signature::SignatureType::Secp256k1, - bytes: b"Test signature".to_vec(), - }, - } - ] - }) - ) - ] - } + ] + }), + T::from_lotus_json(PublishStorageDealsParamsV3LotusJson { + deals: vec![ + ClientDealProposalV3LotusJson { + proposal: DealProposalLotusJson { + piece_cid: "baga6ea4seaqao7s73y24kcutaosvacpdjgfe5pw76ooefnyqw4ynr3d2y6x2mpq".parse().unwrap(), + piece_size: 1024u64.into(), + verified_deal: false, + client: "f17uoq6tp427uzv7fztkbsnn64iwotfrristwpryy".parse().unwrap(), + provider: "f01000".parse().unwrap(), + label: LabelLotusJson::String("test-deal".to_string()), + start_epoch: ChainEpoch::from(100), + end_epoch: ChainEpoch::from(200), + storage_price_per_epoch: TokenAmount::from_atto(1000u64), + provider_collateral: TokenAmount::from_atto(2000u64), + client_collateral: TokenAmount::from_atto(1500u64), + }, + client_signature: fvm_shared3::crypto::signature::Signature { + sig_type: fvm_shared3::crypto::signature::SignatureType::Secp256k1, + bytes: b"Test signature".to_vec(), + }, + } + ] + }) + ) + ] + } - fn into_lotus_json(self) -> Self::LotusJson { - Self::LotusJson { - deals: self.deals.into_iter().map(|d| d.into_lotus_json()).collect(), + fn into_lotus_json(self) -> Self::LotusJson { + Self::LotusJson { + deals: self.deals.into_iter().map(|d| d.into_lotus_json()).collect(), + } } - } - fn from_lotus_json(json: Self::LotusJson) -> Self { - Self { - deals: json.deals.into_iter() - .map(|d| fil_actor_market_state::[]::ClientDealProposal::from_lotus_json(d)) // delegate - .collect(), + fn from_lotus_json(json: Self::LotusJson) -> Self { + Self { + deals: json.deals.into_iter() + .map(|d| fil_actor_market_state::[]::ClientDealProposal::from_lotus_json(d)) // delegate + .collect(), + } } } } @@ -576,76 +646,86 @@ macro_rules! impl_publish_storage_deals_params_snapshots_v4 { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_market_state::[]::PublishStorageDealsParams { - type LotusJson = PublishStorageDealsParamsV4LotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - json!({ - "Deals": [ - { - "Proposal": { - "PieceCID": { - "/": "baga6ea4seaqao7s73y24kcutaosvacpdjgfe5pw76ooefnyqw4ynr3d2y6x2mpq" + mod [] { + use super::*; + type T = fil_actor_market_state::[]::PublishStorageDealsParams; + + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); + } + + impl HasLotusJson for T { + type LotusJson = PublishStorageDealsParamsV4LotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + json!({ + "Deals": [ + { + "Proposal": { + "PieceCID": { + "/": "baga6ea4seaqao7s73y24kcutaosvacpdjgfe5pw76ooefnyqw4ynr3d2y6x2mpq" + }, + "PieceSize": 1024, + "VerifiedDeal": false, + "Client": "f17uoq6tp427uzv7fztkbsnn64iwotfrristwpryy", + "Provider": "f01000", + "Label": "test-deal", + "StartEpoch": 100, + "EndEpoch": 200, + "StoragePricePerEpoch": "1000", + "ProviderCollateral": "2000", + "ClientCollateral": "1500" }, - "PieceSize": 1024, - "VerifiedDeal": false, - "Client": "f17uoq6tp427uzv7fztkbsnn64iwotfrristwpryy", - "Provider": "f01000", - "Label": "test-deal", - "StartEpoch": 100, - "EndEpoch": 200, - "StoragePricePerEpoch": "1000", - "ProviderCollateral": "2000", - "ClientCollateral": "1500" - }, - "ClientSignature": { - "Type": 1, - "Data": "VGVzdCBzaWduYXR1cmU=" + "ClientSignature": { + "Type": 1, + "Data": "VGVzdCBzaWduYXR1cmU=" + } } - } - ] - }), - fil_actor_market_state::[]::PublishStorageDealsParams::from_lotus_json(PublishStorageDealsParamsV4LotusJson { - deals: vec![ - ClientDealProposalV4LotusJson { - proposal: DealProposalLotusJson { - piece_cid: "baga6ea4seaqao7s73y24kcutaosvacpdjgfe5pw76ooefnyqw4ynr3d2y6x2mpq".parse().unwrap(), - piece_size: 1024u64.into(), - verified_deal: false, - client: "f17uoq6tp427uzv7fztkbsnn64iwotfrristwpryy".parse().unwrap(), - provider: "f01000".parse().unwrap(), - label: LabelLotusJson::String("test-deal".to_string()), - start_epoch: ChainEpoch::from(100), - end_epoch: ChainEpoch::from(200), - storage_price_per_epoch: TokenAmount::from_atto(1000u64), - provider_collateral: TokenAmount::from_atto(2000u64), - client_collateral: TokenAmount::from_atto(1500u64), - }, - client_signature: fvm_shared4::crypto::signature::Signature { - sig_type: fvm_shared4::crypto::signature::SignatureType::Secp256k1, - bytes: b"Test signature".to_vec(), - }, - } - ] - }) - ) - ] - } + ] + }), + T::from_lotus_json(PublishStorageDealsParamsV4LotusJson { + deals: vec![ + ClientDealProposalV4LotusJson { + proposal: DealProposalLotusJson { + piece_cid: "baga6ea4seaqao7s73y24kcutaosvacpdjgfe5pw76ooefnyqw4ynr3d2y6x2mpq".parse().unwrap(), + piece_size: 1024u64.into(), + verified_deal: false, + client: "f17uoq6tp427uzv7fztkbsnn64iwotfrristwpryy".parse().unwrap(), + provider: "f01000".parse().unwrap(), + label: LabelLotusJson::String("test-deal".to_string()), + start_epoch: ChainEpoch::from(100), + end_epoch: ChainEpoch::from(200), + storage_price_per_epoch: TokenAmount::from_atto(1000u64), + provider_collateral: TokenAmount::from_atto(2000u64), + client_collateral: TokenAmount::from_atto(1500u64), + }, + client_signature: fvm_shared4::crypto::signature::Signature { + sig_type: fvm_shared4::crypto::signature::SignatureType::Secp256k1, + bytes: b"Test signature".to_vec(), + }, + } + ] + }) + ) + ] + } - fn into_lotus_json(self) -> Self::LotusJson { - Self::LotusJson { - deals: self.deals.into_iter().map(|d| d.into_lotus_json()).collect(), + fn into_lotus_json(self) -> Self::LotusJson { + Self::LotusJson { + deals: self.deals.into_iter().map(|d| d.into_lotus_json()).collect(), + } } - } - fn from_lotus_json(json: Self::LotusJson) -> Self { - Self { - deals: json.deals.into_iter() - .map(|d| fil_actor_market_state::[]::ClientDealProposal::from_lotus_json(d)) // delegate - .collect(), + fn from_lotus_json(json: Self::LotusJson) -> Self { + Self { + deals: json.deals.into_iter() + .map(|d| fil_actor_market_state::[]::ClientDealProposal::from_lotus_json(d)) // delegate + .collect(), + } } } } @@ -676,38 +756,48 @@ macro_rules! impl_lotus_json_for_sector_deals { ($type_suffix:path: no_sector_type: no_sector_number: $($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_market_state::[]::SectorDeals { - type LotusJson = SectorDealsLotusJson; + mod [] { + use super::*; + type T = fil_actor_market_state::[]::SectorDeals; - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - serde_json::json!({ - "SectorExpiry": 1000, - "DealIDs": [1,2,3] - }), - Self { - sector_expiry: 1000, - deal_ids: vec![1,2,3], - } - ), - ] + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - Self::LotusJson { - sector_number: None, - sector_type: None, - sector_expiry: self.sector_expiry.into_lotus_json(), - deal_ids: self.deal_ids.into(), + impl HasLotusJson for T { + type LotusJson = SectorDealsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + serde_json::json!({ + "SectorExpiry": 1000, + "DealIDs": [1,2,3] + }), + Self { + sector_expiry: 1000, + deal_ids: vec![1,2,3], + } + ), + ] } - } - fn from_lotus_json(json: Self::LotusJson) -> Self { - Self { - sector_expiry: json.sector_expiry.into(), - deal_ids: json.deal_ids.into(), + fn into_lotus_json(self) -> Self::LotusJson { + Self::LotusJson { + sector_number: None, + sector_type: None, + sector_expiry: self.sector_expiry.into_lotus_json(), + deal_ids: self.deal_ids.into(), + } + } + + fn from_lotus_json(json: Self::LotusJson) -> Self { + Self { + sector_expiry: json.sector_expiry.into(), + deal_ids: json.deal_ids.into(), + } } } } @@ -718,41 +808,51 @@ macro_rules! impl_lotus_json_for_sector_deals { ($type_suffix:path: no_sector_number: $($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_market_state::[]::SectorDeals { - type LotusJson = SectorDealsLotusJson; + mod [] { + use super::*; + type T = fil_actor_market_state::[]::SectorDeals; - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - serde_json::json!({ - "SectorType": 1, - "SectorExpiry": 1000, - "DealIDs": [1,2,3] - }), - Self { - sector_type: RegisteredSealProof::from(1).into(), - sector_expiry: 1000, - deal_ids: vec![1,2,3], - } - ), - ] + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - Self::LotusJson { - sector_number: None, - sector_type: Some(self.sector_type.into()), - sector_expiry: self.sector_expiry.into_lotus_json(), - deal_ids: self.deal_ids.into(), + impl HasLotusJson for T { + type LotusJson = SectorDealsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + serde_json::json!({ + "SectorType": 1, + "SectorExpiry": 1000, + "DealIDs": [1,2,3] + }), + Self { + sector_type: RegisteredSealProof::from(1).into(), + sector_expiry: 1000, + deal_ids: vec![1,2,3], + } + ), + ] } - } - fn from_lotus_json(json: Self::LotusJson) -> Self { - Self { - sector_expiry: json.sector_expiry.into(), - sector_type: json.sector_type.unwrap_or(RegisteredSealProof::invalid()).into(), - deal_ids: json.deal_ids.into(), + fn into_lotus_json(self) -> Self::LotusJson { + Self::LotusJson { + sector_number: None, + sector_type: Some(self.sector_type.into()), + sector_expiry: self.sector_expiry.into_lotus_json(), + deal_ids: self.deal_ids.into(), + } + } + + fn from_lotus_json(json: Self::LotusJson) -> Self { + Self { + sector_expiry: json.sector_expiry.into(), + sector_type: json.sector_type.unwrap_or(RegisteredSealProof::invalid()).into(), + deal_ids: json.deal_ids.into(), + } } } } @@ -762,44 +862,54 @@ macro_rules! impl_lotus_json_for_sector_deals { ($type_suffix:path: $($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_market_state::[]::SectorDeals { - type LotusJson = SectorDealsLotusJson; + mod [] { + use super::*; + type T = fil_actor_market_state::[]::SectorDeals; - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - serde_json::json!({ - "SectorNumber": 42, - "SectorType": 1, - "SectorExpiry": 1000, - "DealIDs": [1,2,3] - }), - Self { - sector_number: 42, - sector_type: RegisteredSealProof::from(1).into(), - sector_expiry: 1000, - deal_ids: vec![1,2,3], - } - ), - ] + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - Self::LotusJson { - sector_number: Some(self.sector_number), - sector_type: Some(self.sector_type.into()), - sector_expiry: self.sector_expiry.into_lotus_json(), - deal_ids: self.deal_ids.into(), + impl HasLotusJson for T { + type LotusJson = SectorDealsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + serde_json::json!({ + "SectorNumber": 42, + "SectorType": 1, + "SectorExpiry": 1000, + "DealIDs": [1,2,3] + }), + Self { + sector_number: 42, + sector_type: RegisteredSealProof::from(1).into(), + sector_expiry: 1000, + deal_ids: vec![1,2,3], + } + ), + ] } - } - fn from_lotus_json(json: Self::LotusJson) -> Self { - Self { - sector_number: json.sector_number.unwrap_or(0), - sector_type: json.sector_type.unwrap_or(RegisteredSealProof::invalid()).into(), - sector_expiry: json.sector_expiry.into(), - deal_ids: json.deal_ids.into(), + fn into_lotus_json(self) -> Self::LotusJson { + Self::LotusJson { + sector_number: Some(self.sector_number), + sector_type: Some(self.sector_type.into()), + sector_expiry: self.sector_expiry.into_lotus_json(), + deal_ids: self.deal_ids.into(), + } + } + + fn from_lotus_json(json: Self::LotusJson) -> Self { + Self { + sector_number: json.sector_number.unwrap_or(0), + sector_type: json.sector_type.unwrap_or(RegisteredSealProof::invalid()).into(), + sector_expiry: json.sector_expiry.into(), + deal_ids: json.deal_ids.into(), + } } } } @@ -818,56 +928,16 @@ macro_rules! impl_lotus_json_for_verify_deals_for_activation_params { // Version 8: SectorDeals has only sector_expiry and deal_ids (v8) => { paste! { - impl HasLotusJson for fil_actor_market_state::v8::VerifyDealsForActivationParams { - type LotusJson = VerifyDealsForActivationParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - serde_json::json!({ - "Sectors": [ - { - "SectorExpiry": 1000, - "DealIDs": [1,2,3] - } - ] - }), - Self { - sectors: vec![ - fil_actor_market_state::v8::SectorDeals { - sector_expiry: 1000, - deal_ids: vec![1,2,3], - } - ], - } - ), - ] - } + mod impl_verify_deals_for_activation_params_v8 { + use super::*; + type T = fil_actor_market_state::v8::VerifyDealsForActivationParams; - fn into_lotus_json(self) -> Self::LotusJson { - Self::LotusJson { - sectors: self.sectors.into_iter().map(|s| s.into_lotus_json()).collect(), - } + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn from_lotus_json(json: Self::LotusJson) -> Self { - Self { - sectors: json - .sectors - .into_iter() - .map(|s| fil_actor_market_state::v8::SectorDeals::from_lotus_json(s)) - .collect(), - } - } - } - } - }; - // Versions 9-12: SectorDeals has sector_type (which gets default value invalid() = 0) - (v9_to_v12: $($version:literal),+) => { - $( - paste! { - impl HasLotusJson for fil_actor_market_state::[]::VerifyDealsForActivationParams { + impl HasLotusJson for T { type LotusJson = VerifyDealsForActivationParamsLotusJson; #[cfg(test)] @@ -878,17 +948,15 @@ macro_rules! impl_lotus_json_for_verify_deals_for_activation_params { "Sectors": [ { "SectorExpiry": 1000, - "DealIDs": [1,2,3], - "SectorType": 0 + "DealIDs": [1,2,3] } ] }), Self { sectors: vec![ - fil_actor_market_state::[]::SectorDeals { + fil_actor_market_state::v8::SectorDeals { sector_expiry: 1000, deal_ids: vec![1,2,3], - sector_type: RegisteredSealProof::invalid().into(), } ], } @@ -907,62 +975,134 @@ macro_rules! impl_lotus_json_for_verify_deals_for_activation_params { sectors: json .sectors .into_iter() - .map(|s| fil_actor_market_state::[]::SectorDeals::from_lotus_json(s)) + .map(|s| fil_actor_market_state::v8::SectorDeals::from_lotus_json(s)) .collect(), } } } } + } + }; + // Versions 9-12: SectorDeals has sector_type (which gets default value invalid() = 0) + (v9_to_v12: $($version:literal),+) => { + $( + paste! { + mod [] { + use super::*; + type T = fil_actor_market_state::[]::VerifyDealsForActivationParams; + + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); + } + + impl HasLotusJson for T { + type LotusJson = VerifyDealsForActivationParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + serde_json::json!({ + "Sectors": [ + { + "SectorExpiry": 1000, + "DealIDs": [1,2,3], + "SectorType": 0 + } + ] + }), + Self { + sectors: vec![ + fil_actor_market_state::[]::SectorDeals { + sector_expiry: 1000, + deal_ids: vec![1,2,3], + sector_type: RegisteredSealProof::invalid().into(), + } + ], + } + ), + ] + } + + fn into_lotus_json(self) -> Self::LotusJson { + Self::LotusJson { + sectors: self.sectors.into_iter().map(|s| s.into_lotus_json()).collect(), + } + } + + fn from_lotus_json(json: Self::LotusJson) -> Self { + Self { + sectors: json + .sectors + .into_iter() + .map(|s| fil_actor_market_state::[]::SectorDeals::from_lotus_json(s)) + .collect(), + } + } + } + } + } )+ }; // Versions 13+: SectorDeals has both sector_type and sector_number (both get default values) (v13_plus: $($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_market_state::[]::VerifyDealsForActivationParams { - type LotusJson = VerifyDealsForActivationParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - serde_json::json!({ - "Sectors": [ - { - "SectorExpiry": 1000, - "DealIDs": [1,2,3], - "SectorType": 0, - "SectorNumber": 0 - } - ] - }), - Self { - sectors: vec![ - fil_actor_market_state::[]::SectorDeals { - sector_expiry: 1000, - deal_ids: vec![1,2,3], - sector_type: RegisteredSealProof::invalid().into(), - sector_number: 0u64.into(), - } - ], - } - ), - ] - } + mod [] { + use super::*; + type T = fil_actor_market_state::[]::VerifyDealsForActivationParams; + + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); + } + + impl HasLotusJson for T { + type LotusJson = VerifyDealsForActivationParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + serde_json::json!({ + "Sectors": [ + { + "SectorExpiry": 1000, + "DealIDs": [1,2,3], + "SectorType": 0, + "SectorNumber": 0 + } + ] + }), + Self { + sectors: vec![ + fil_actor_market_state::[]::SectorDeals { + sector_expiry: 1000, + deal_ids: vec![1,2,3], + sector_type: RegisteredSealProof::invalid().into(), + sector_number: 0u64.into(), + } + ], + } + ), + ] + } - fn into_lotus_json(self) -> Self::LotusJson { - Self::LotusJson { - sectors: self.sectors.into_iter().map(|s| s.into_lotus_json()).collect(), + fn into_lotus_json(self) -> Self::LotusJson { + Self::LotusJson { + sectors: self.sectors.into_iter().map(|s| s.into_lotus_json()).collect(), + } } - } - fn from_lotus_json(json: Self::LotusJson) -> Self { - Self { - sectors: json - .sectors - .into_iter() - .map(|s| fil_actor_market_state::[]::SectorDeals::from_lotus_json(s)) - .collect(), + fn from_lotus_json(json: Self::LotusJson) -> Self { + Self { + sectors: json + .sectors + .into_iter() + .map(|s| fil_actor_market_state::[]::SectorDeals::from_lotus_json(s)) + .collect(), + } } } } @@ -984,36 +1124,46 @@ macro_rules! impl_lotus_json_for_activate_deals_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_market_state::[]::ActivateDealsParams { - type LotusJson = ActivateDealsParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - serde_json::json!({ - "DealIDs": [1,2,3], - "SectorExpiry": 1000 - }), - Self { - deal_ids: vec![1,2,3], - sector_expiry: 1000, - } - ), - ] - } + mod [] { + use super::*; + type T = fil_actor_market_state::[]::ActivateDealsParams; + + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); + } + + impl HasLotusJson for T { + type LotusJson = ActivateDealsParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + serde_json::json!({ + "DealIDs": [1,2,3], + "SectorExpiry": 1000 + }), + Self { + deal_ids: vec![1,2,3], + sector_expiry: 1000, + } + ), + ] + } - fn into_lotus_json(self) -> Self::LotusJson { - Self::LotusJson { - deal_ids: self.deal_ids.into(), - sector_expiry: self.sector_expiry.into_lotus_json(), + fn into_lotus_json(self) -> Self::LotusJson { + Self::LotusJson { + deal_ids: self.deal_ids.into(), + sector_expiry: self.sector_expiry.into_lotus_json(), + } } - } - fn from_lotus_json(json: Self::LotusJson) -> Self { - Self { - deal_ids: json.deal_ids.into(), - sector_expiry: json.sector_expiry.into(), + fn from_lotus_json(json: Self::LotusJson) -> Self { + Self { + deal_ids: json.deal_ids.into(), + sector_expiry: json.sector_expiry.into(), + } } } } @@ -1034,55 +1184,65 @@ macro_rules! impl_lotus_json_for_batch_activate_deals_params { (v12: $($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_market_state::[]::BatchActivateDealsParams { - type LotusJson = BatchActivateDealsParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - serde_json::json!({ - "Sectors": [ - { - "SectorType": 1, - "SectorExpiry": 1000, - "DealIDs": [1,2,3] - } - ], - "ComputeCid": true - }), - Self { - sectors: vec![ - fil_actor_market_state::[]::SectorDeals::from_lotus_json( - SectorDealsLotusJson { - sector_number: None, // No sector_number in v12 - sector_type: Some(RegisteredSealProof::from(1).into()), - sector_expiry: 1000, - deal_ids: vec![1,2,3], + mod [] { + use super::*; + type T = fil_actor_market_state::[]::BatchActivateDealsParams; + + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); + } + + impl HasLotusJson for T { + type LotusJson = BatchActivateDealsParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + serde_json::json!({ + "Sectors": [ + { + "SectorType": 1, + "SectorExpiry": 1000, + "DealIDs": [1,2,3] } - ) - ], - compute_cid: true, - } - ), - ] - } + ], + "ComputeCid": true + }), + Self { + sectors: vec![ + fil_actor_market_state::[]::SectorDeals::from_lotus_json( + SectorDealsLotusJson { + sector_number: None, // No sector_number in v12 + sector_type: Some(RegisteredSealProof::from(1).into()), + sector_expiry: 1000, + deal_ids: vec![1,2,3], + } + ) + ], + compute_cid: true, + } + ), + ] + } - fn into_lotus_json(self) -> Self::LotusJson { - Self::LotusJson { - sectors: self.sectors.into_iter().map(|s| s.into_lotus_json()).collect(), - compute_cid: self.compute_cid, + fn into_lotus_json(self) -> Self::LotusJson { + Self::LotusJson { + sectors: self.sectors.into_iter().map(|s| s.into_lotus_json()).collect(), + compute_cid: self.compute_cid, + } } - } - fn from_lotus_json(json: Self::LotusJson) -> Self { - Self { - sectors: json - .sectors - .into_iter() - .map(|s| fil_actor_market_state::[]::SectorDeals::from_lotus_json(s)) - .collect(), - compute_cid: json.compute_cid, + fn from_lotus_json(json: Self::LotusJson) -> Self { + Self { + sectors: json + .sectors + .into_iter() + .map(|s| fil_actor_market_state::[]::SectorDeals::from_lotus_json(s)) + .collect(), + compute_cid: json.compute_cid, + } } } } @@ -1093,56 +1253,66 @@ macro_rules! impl_lotus_json_for_batch_activate_deals_params { (v13_onwards: $($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_market_state::[]::BatchActivateDealsParams { - type LotusJson = BatchActivateDealsParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - serde_json::json!({ - "Sectors": [ - { - "SectorNumber": 42, - "SectorType": 1, - "SectorExpiry": 1000, - "DealIDs": [1,2,3] - } - ], - "ComputeCid": true - }), - Self { - sectors: vec![ - fil_actor_market_state::[]::SectorDeals::from_lotus_json( - SectorDealsLotusJson { - sector_number: Some(42), // Has sector_number in v13+ - sector_type: Some(RegisteredSealProof::from(1).into()), - sector_expiry: 1000, - deal_ids: vec![1,2,3], + mod [] { + use super::*; + type T = fil_actor_market_state::[]::BatchActivateDealsParams; + + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); + } + + impl HasLotusJson for T { + type LotusJson = BatchActivateDealsParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + serde_json::json!({ + "Sectors": [ + { + "SectorNumber": 42, + "SectorType": 1, + "SectorExpiry": 1000, + "DealIDs": [1,2,3] } - ) - ], - compute_cid: true, - } - ), - ] - } + ], + "ComputeCid": true + }), + Self { + sectors: vec![ + fil_actor_market_state::[]::SectorDeals::from_lotus_json( + SectorDealsLotusJson { + sector_number: Some(42), // Has sector_number in v13+ + sector_type: Some(RegisteredSealProof::from(1).into()), + sector_expiry: 1000, + deal_ids: vec![1,2,3], + } + ) + ], + compute_cid: true, + } + ), + ] + } - fn into_lotus_json(self) -> Self::LotusJson { - Self::LotusJson { - sectors: self.sectors.into_iter().map(|s| s.into_lotus_json()).collect(), - compute_cid: self.compute_cid, + fn into_lotus_json(self) -> Self::LotusJson { + Self::LotusJson { + sectors: self.sectors.into_iter().map(|s| s.into_lotus_json()).collect(), + compute_cid: self.compute_cid, + } } - } - fn from_lotus_json(json: Self::LotusJson) -> Self { - Self { - sectors: json - .sectors - .into_iter() - .map(|s| fil_actor_market_state::[]::SectorDeals::from_lotus_json(s)) - .collect(), - compute_cid: json.compute_cid, + fn from_lotus_json(json: Self::LotusJson) -> Self { + Self { + sectors: json + .sectors + .into_iter() + .map(|s| fil_actor_market_state::[]::SectorDeals::from_lotus_json(s)) + .collect(), + compute_cid: json.compute_cid, + } } } } @@ -1173,36 +1343,46 @@ macro_rules! impl_lotus_json_for_on_miner_sectors_terminate_params { (OnMinerSectorsTerminateParamsLotusJsonV8: $($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_market_state::[]::OnMinerSectorsTerminateParams { - type LotusJson = OnMinerSectorsTerminateParamsLotusJsonV8; + mod [] { + use super::*; + type T = fil_actor_market_state::[]::OnMinerSectorsTerminateParams; - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - serde_json::json!({ - "Epoch": 1000, - "DealIDs": [1,2,3] - }), - Self { - epoch: 1000, - deal_ids: vec![1,2,3], - } - ), - ] + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - Self::LotusJson { - epoch: self.epoch.into(), - deal_ids: self.deal_ids.into(), + impl HasLotusJson for T { + type LotusJson = OnMinerSectorsTerminateParamsLotusJsonV8; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + serde_json::json!({ + "Epoch": 1000, + "DealIDs": [1,2,3] + }), + Self { + epoch: 1000, + deal_ids: vec![1,2,3], + } + ), + ] } - } - fn from_lotus_json(json: Self::LotusJson) -> Self { - Self { - epoch: json.epoch.into(), - deal_ids: json.deal_ids.into(), + fn into_lotus_json(self) -> Self::LotusJson { + Self::LotusJson { + epoch: self.epoch.into(), + deal_ids: self.deal_ids.into(), + } + } + + fn from_lotus_json(json: Self::LotusJson) -> Self { + Self { + epoch: json.epoch.into(), + deal_ids: json.deal_ids.into(), + } } } } @@ -1212,39 +1392,49 @@ macro_rules! impl_lotus_json_for_on_miner_sectors_terminate_params { (OnMinerSectorsTerminateParamsLotusJsonV13: $($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_market_state::[]::OnMinerSectorsTerminateParams { - type LotusJson = OnMinerSectorsTerminateParamsLotusJsonV13; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - let mut sectors = BitField::new(); - sectors.set(1); - - vec![ - ( - serde_json::json!({ - "Epoch": 1000, - "Sectors": [1, 1] - }), - Self { - epoch: 1000, - sectors, - } - ), - ] - } + mod [] { + use super::*; + type T = fil_actor_market_state::[]::OnMinerSectorsTerminateParams; + + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); + } + + impl HasLotusJson for T { + type LotusJson = OnMinerSectorsTerminateParamsLotusJsonV13; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + let mut sectors = BitField::new(); + sectors.set(1); + + vec![ + ( + serde_json::json!({ + "Epoch": 1000, + "Sectors": [1, 1] + }), + Self { + epoch: 1000, + sectors, + } + ), + ] + } - fn into_lotus_json(self) -> Self::LotusJson { - Self::LotusJson { - epoch: self.epoch.into(), - sectors: self.sectors.into(), + fn into_lotus_json(self) -> Self::LotusJson { + Self::LotusJson { + epoch: self.epoch.into(), + sectors: self.sectors.into(), + } } - } - fn from_lotus_json(json: Self::LotusJson) -> Self { - Self { - epoch: json.epoch.into(), - sectors: json.sectors.into(), + fn from_lotus_json(json: Self::LotusJson) -> Self { + Self { + epoch: json.epoch.into(), + sectors: json.sectors.into(), + } } } } @@ -1268,36 +1458,46 @@ macro_rules! impl_lotus_json_for_sector_data_spec { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_market_state::[]::SectorDataSpec { - type LotusJson = SectorDataSpecLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - serde_json::json!({ - "DealIDs": [1,2,3], - "SectorType": 1 - }), - Self { - deal_ids: vec![1,2,3], - sector_type: RegisteredSealProof::from(1).into(), - } - ), - ] - } + mod [] { + use super::*; + type T = fil_actor_market_state::[]::SectorDataSpec; + + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); + } + + impl HasLotusJson for T { + type LotusJson = SectorDataSpecLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + serde_json::json!({ + "DealIDs": [1,2,3], + "SectorType": 1 + }), + Self { + deal_ids: vec![1,2,3], + sector_type: RegisteredSealProof::from(1).into(), + } + ), + ] + } - fn into_lotus_json(self) -> Self::LotusJson { - Self::LotusJson { - deal_ids: self.deal_ids.into(), - sector_type: self.sector_type.into(), + fn into_lotus_json(self) -> Self::LotusJson { + Self::LotusJson { + deal_ids: self.deal_ids.into(), + sector_type: self.sector_type.into(), + } } - } - fn from_lotus_json(json: Self::LotusJson) -> Self { - Self { - deal_ids: json.deal_ids.into(), - sector_type: json.sector_type.into(), + fn from_lotus_json(json: Self::LotusJson) -> Self { + Self { + deal_ids: json.deal_ids.into(), + sector_type: json.sector_type.into(), + } } } } @@ -1316,48 +1516,58 @@ macro_rules! impl_lotus_json_for_compute_data_commitment_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_market_state::[]::ComputeDataCommitmentParams { - type LotusJson = ComputeDataCommitmentParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - serde_json::json!({ - "Inputs": [ - { - "DealIDs": [1,2,3], - "SectorType": 1 - } - ] - }), - Self { - inputs: vec![ - fil_actor_market_state::[]::SectorDataSpec::from_lotus_json( - SectorDataSpecLotusJson { - deal_ids: vec![1,2,3], - sector_type: RegisteredSealProof::from(1).into(), + mod [] { + use super::*; + type T = fil_actor_market_state::[]::ComputeDataCommitmentParams; + + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); + } + + impl HasLotusJson for T { + type LotusJson = ComputeDataCommitmentParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + serde_json::json!({ + "Inputs": [ + { + "DealIDs": [1,2,3], + "SectorType": 1 } - ) - ], - } - ), - ] - } + ] + }), + Self { + inputs: vec![ + fil_actor_market_state::[]::SectorDataSpec::from_lotus_json( + SectorDataSpecLotusJson { + deal_ids: vec![1,2,3], + sector_type: RegisteredSealProof::from(1).into(), + } + ) + ], + } + ), + ] + } - fn into_lotus_json(self) -> Self::LotusJson { - Self::LotusJson { - inputs: self.inputs.into_iter().map(|s| s.into_lotus_json()).collect(), + fn into_lotus_json(self) -> Self::LotusJson { + Self::LotusJson { + inputs: self.inputs.into_iter().map(|s| s.into_lotus_json()).collect(), + } } - } - fn from_lotus_json(json: Self::LotusJson) -> Self { - Self { - inputs: json - .inputs - .into_iter() - .map(|s| fil_actor_market_state::[]::SectorDataSpec::from_lotus_json(s)) // delegate - .collect(), + fn from_lotus_json(json: Self::LotusJson) -> Self { + Self { + inputs: json + .inputs + .into_iter() + .map(|s| fil_actor_market_state::[]::SectorDataSpec::from_lotus_json(s)) // delegate + .collect(), + } } } } @@ -1378,26 +1588,36 @@ macro_rules! impl_lotus_json_for_deal_query_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_market_state::[]::DealQueryParams { - type LotusJson = DealQueryParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - serde_json::json!(42), - Self { id: 42 } - ), - ] - } + mod [] { + use super::*; + type T = fil_actor_market_state::[]::DealQueryParams; + + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); + } + + impl HasLotusJson for T { + type LotusJson = DealQueryParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + serde_json::json!(42), + Self { id: 42 } + ), + ] + } - fn into_lotus_json(self) -> Self::LotusJson { - DealQueryParamsLotusJson(self.id.into()) - } + fn into_lotus_json(self) -> Self::LotusJson { + DealQueryParamsLotusJson(self.id.into()) + } - fn from_lotus_json(json: Self::LotusJson) -> Self { - Self { - id: json.0, + fn from_lotus_json(json: Self::LotusJson) -> Self { + Self { + id: json.0, + } } } } @@ -1418,26 +1638,36 @@ macro_rules! impl_lotus_json_for_settle_deal_payments_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_market_state::[]::SettleDealPaymentsParams { - type LotusJson = SettleDealPaymentsParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - serde_json::json!([0]), - Self { deal_ids: BitField::new() } - ), - ] - } + mod [] { + use super::*; + type T = fil_actor_market_state::[]::SettleDealPaymentsParams; + + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); + } + + impl HasLotusJson for T { + type LotusJson = SettleDealPaymentsParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + serde_json::json!([0]), + Self { deal_ids: BitField::new() } + ), + ] + } - fn into_lotus_json(self) -> Self::LotusJson { - SettleDealPaymentsParamsLotusJson(self.deal_ids.into()) - } + fn into_lotus_json(self) -> Self::LotusJson { + SettleDealPaymentsParamsLotusJson(self.deal_ids.into()) + } - fn from_lotus_json(json: Self::LotusJson) -> Self { - Self { - deal_ids: json.0, + fn from_lotus_json(json: Self::LotusJson) -> Self { + Self { + deal_ids: json.0, + } } } } @@ -1478,56 +1708,66 @@ macro_rules! impl_lotus_json_for_sector_content_changed_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_market_state::[]::ext::miner::SectorContentChangedParams { - type LotusJson = SectorContentChangedParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - serde_json::json!({ - "Sectors": [] - }), - Self { - sectors: vec![], - } - ), - ] - } + mod [] { + use super::*; + type T = fil_actor_market_state::[]::ext::miner::SectorContentChangedParams; + + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); + } + + impl HasLotusJson for T { + type LotusJson = SectorContentChangedParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + serde_json::json!({ + "Sectors": [] + }), + Self { + sectors: vec![], + } + ), + ] + } - fn into_lotus_json(self) -> Self::LotusJson { - Self::LotusJson { - sectors: self.sectors.into_iter().map(|sector_changes| { - SectorChangesLotusJson { - sector: sector_changes.sector.into(), - minimum_commitment_epoch: sector_changes.minimum_commitment_epoch, - added: sector_changes.added.into_iter().map(|piece_change| { - PieceChangeLotusJson { - data: piece_change.data.into(), - size: piece_change.size.into(), - payload: piece_change.payload.into(), - } - }).collect(), - } - }).collect(), + fn into_lotus_json(self) -> Self::LotusJson { + Self::LotusJson { + sectors: self.sectors.into_iter().map(|sector_changes| { + SectorChangesLotusJson { + sector: sector_changes.sector.into(), + minimum_commitment_epoch: sector_changes.minimum_commitment_epoch, + added: sector_changes.added.into_iter().map(|piece_change| { + PieceChangeLotusJson { + data: piece_change.data.into(), + size: piece_change.size.into(), + payload: piece_change.payload.into(), + } + }).collect(), + } + }).collect(), + } } - } - fn from_lotus_json(json: Self::LotusJson) -> Self { - Self { - sectors: json.sectors.into_iter().map(|sector_changes_json| { - fil_actor_market_state::[]::ext::miner::SectorChanges { - sector: sector_changes_json.sector.into(), - minimum_commitment_epoch: sector_changes_json.minimum_commitment_epoch, - added: sector_changes_json.added.into_iter().map(|piece_change_json| { - fil_actor_market_state::[]::ext::miner::PieceChange { - data: piece_change_json.data.into(), - size: piece_change_json.size.into(), - payload: piece_change_json.payload.into(), - } - }).collect(), - } - }).collect(), + fn from_lotus_json(json: Self::LotusJson) -> Self { + Self { + sectors: json.sectors.into_iter().map(|sector_changes_json| { + fil_actor_market_state::[]::ext::miner::SectorChanges { + sector: sector_changes_json.sector.into(), + minimum_commitment_epoch: sector_changes_json.minimum_commitment_epoch, + added: sector_changes_json.added.into_iter().map(|piece_change_json| { + fil_actor_market_state::[]::ext::miner::PieceChange { + data: piece_change_json.data.into(), + size: piece_change_json.size.into(), + payload: piece_change_json.payload.into(), + } + }).collect(), + } + }).collect(), + } } } } @@ -1563,21 +1803,7 @@ impl_lotus_json_for_deal_query_params!(10, 11, 12, 13, 14, 15, 16, 17); impl_lotus_json_for_settle_deal_payments_params!(13, 14, 15, 16, 17); impl_lotus_json_for_sector_content_changed_params!(13, 14, 15, 16, 17); -test_snapshots!(fil_actor_market_state: AddBalanceParams: 8, 9, 10, 11, 12, 13, 14, 15, 16, 17); -test_snapshots!(fil_actor_market_state: WithdrawBalanceParams: 8, 9, 10, 11, 12, 13, 14, 15, 16, 17); -test_snapshots!(fil_actor_market_state: Label: 8, 9, 10, 11, 12, 13, 14, 15, 16, 17); -test_snapshots!(fil_actor_market_state: DealProposal: 8, 9, 10, 11, 12, 13, 14, 15, 16, 17); -test_snapshots!(fil_actor_market_state: ClientDealProposal: 8, 9, 10, 11, 12, 13, 14, 15, 16, 17); -test_snapshots!(fil_actor_market_state: PublishStorageDealsParams: 8, 9, 10, 11, 12, 13, 14, 15, 16, 17); -test_snapshots!(fil_actor_market_state: SectorDeals: 8, 9, 10, 11, 12, 13, 14, 15, 16, 17); -test_snapshots!(fil_actor_market_state: VerifyDealsForActivationParams: 8, 9, 10, 11, 12, 13, 14, 15, 16, 17); -test_snapshots!(fil_actor_market_state: ActivateDealsParams: 8, 9, 10, 11); -test_snapshots!(fil_actor_market_state: BatchActivateDealsParams: 12, 13, 14, 15, 16, 17); -test_snapshots!(fil_actor_market_state: OnMinerSectorsTerminateParams: 8, 9, 10, 11, 12, 13, 14, 15, 16, 17); -test_snapshots!(fil_actor_market_state: SectorDataSpec: 8, 9, 10, 11); -test_snapshots!(fil_actor_market_state: ComputeDataCommitmentParams: 8, 9, 10, 11); -test_snapshots!(fil_actor_market_state: DealQueryParams: 10, 11, 12, 13, 14, 15, 16, 17); -test_snapshots!(fil_actor_market_state: SettleDealPaymentsParams: 13, 14, 15, 16, 17); +// Tests for GetDeal*Params types (type aliases for DealQueryParams) test_snapshots!(fil_actor_market_state: GetDealActivationParams: 10, 11, 12, 13, 14, 15, 16, 17); test_snapshots!(fil_actor_market_state: GetDealClientCollateralParams: 10, 11, 12, 13, 14, 15, 16, 17); test_snapshots!(fil_actor_market_state: GetDealClientParams: 10, 11, 12, 13, 14, 15, 16, 17); @@ -1589,4 +1815,3 @@ test_snapshots!(fil_actor_market_state: GetDealTermParams: 10, 11, 12, 13, 14, 1 test_snapshots!(fil_actor_market_state: GetDealTotalPriceParams: 10, 11, 12, 13, 14, 15, 16, 17); test_snapshots!(fil_actor_market_state: GetDealVerifiedParams: 10, 11, 12, 13, 14, 15, 16, 17); test_snapshots!(fil_actor_market_state: GetDealSectorParams: 13, 14, 15, 16, 17); -test_snapshots!(fil_actor_market_state: ext::miner: SectorContentChangedParams: 13, 14, 15, 16, 17); diff --git a/src/lotus_json/actors/params/multisig_params.rs b/src/lotus_json/actors/params/multisig_params.rs index 2839edceac23..9bc47278c1dc 100644 --- a/src/lotus_json/actors/params/multisig_params.rs +++ b/src/lotus_json/actors/params/multisig_params.rs @@ -120,42 +120,51 @@ macro_rules! impl_multisig_constructor_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_multisig_state::[]::ConstructorParams { - type LotusJson = ConstructorParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![( - json!({ - "Signers": ["f01234", "f01235"], - "NumApprovalsThreshold": 2, - "UnlockDuration": 100, - "StartEpoch": 0, - }), - Self { - signers: vec![Address::new_id(1234).into(), Address::new_id(1235).into()], - num_approvals_threshold: 2, - unlock_duration: 100, - start_epoch: 0, - }, - )] + mod [] { + use super::*; + type T = fil_actor_multisig_state::[]::ConstructorParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - ConstructorParamsLotusJson { - signers: self.signers.into_iter().map(|a| a.into()).collect(), - num_approvals_threshold: self.num_approvals_threshold, - unlock_duration: self.unlock_duration, - start_epoch: self.start_epoch, + impl HasLotusJson for T { + type LotusJson = ConstructorParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![( + json!({ + "Signers": ["f01234", "f01235"], + "NumApprovalsThreshold": 2, + "UnlockDuration": 100, + "StartEpoch": 0, + }), + Self { + signers: vec![Address::new_id(1234).into(), Address::new_id(1235).into()], + num_approvals_threshold: 2, + unlock_duration: 100, + start_epoch: 0, + }, + )] } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - signers: lotus_json.signers.into_iter().map(|a| a.into()).collect(), - num_approvals_threshold: lotus_json.num_approvals_threshold, - unlock_duration: lotus_json.unlock_duration, - start_epoch: lotus_json.start_epoch, + fn into_lotus_json(self) -> Self::LotusJson { + ConstructorParamsLotusJson { + signers: self.signers.into_iter().map(|a| a.into()).collect(), + num_approvals_threshold: self.num_approvals_threshold, + unlock_duration: self.unlock_duration, + start_epoch: self.start_epoch, + } + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + signers: lotus_json.signers.into_iter().map(|a| a.into()).collect(), + num_approvals_threshold: lotus_json.num_approvals_threshold, + unlock_duration: lotus_json.unlock_duration, + start_epoch: lotus_json.start_epoch, + } } } } @@ -169,42 +178,51 @@ macro_rules! impl_multisig_propose_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_multisig_state::[]::ProposeParams { - type LotusJson = ProposeParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![( - json!({ - "To": "f01234", - "Value": "1000000000000000000", - "Method": 0, - "Params": "Ynl0ZSBhcnJheQ==", - }), - Self { - to: Address::new_id(1234).into(), - value: TokenAmount::from_atto(1000000000000000000u64).into(), - method: 0, - params: RawBytes::new(b"byte array".to_vec()), - }, - )] + mod [] { + use super::*; + type T = fil_actor_multisig_state::[]::ProposeParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - ProposeParamsLotusJson { - to: self.to.into(), - value: self.value.into(), - method: self.method, - params: self.params, + impl HasLotusJson for T { + type LotusJson = ProposeParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![( + json!({ + "To": "f01234", + "Value": "1000000000000000000", + "Method": 0, + "Params": "Ynl0ZSBhcnJheQ==", + }), + Self { + to: Address::new_id(1234).into(), + value: TokenAmount::from_atto(1000000000000000000u64).into(), + method: 0, + params: RawBytes::new(b"byte array".to_vec()), + }, + )] } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - to: lotus_json.to.into(), - value: lotus_json.value.into(), - method: lotus_json.method, - params: lotus_json.params, + fn into_lotus_json(self) -> Self::LotusJson { + ProposeParamsLotusJson { + to: self.to.into(), + value: self.value.into(), + method: self.method, + params: self.params, + } + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + to: lotus_json.to.into(), + value: lotus_json.value.into(), + method: lotus_json.method, + params: lotus_json.params, + } } } } @@ -218,34 +236,43 @@ macro_rules! impl_multisig_txn_id_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_multisig_state::[]::TxnIDParams { - type LotusJson = TxnIDParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![( - json!({ - "ID": 1234, - "ProposalHash": "YWJjZGVmZ2g=", - }), - Self { - id: fil_actor_multisig_state::[]::TxnID(1234), - proposal_hash: b"abcdefgh".to_vec(), - }, - )] + mod [] { + use super::*; + type T = fil_actor_multisig_state::[]::TxnIDParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - TxnIDParamsLotusJson { - id: self.id.0, - proposal_hash: self.proposal_hash, + impl HasLotusJson for T { + type LotusJson = TxnIDParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![( + json!({ + "ID": 1234, + "ProposalHash": "YWJjZGVmZ2g=", + }), + Self { + id: fil_actor_multisig_state::[]::TxnID(1234), + proposal_hash: b"abcdefgh".to_vec(), + }, + )] } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - id: fil_actor_multisig_state::[]::TxnID(lotus_json.id), - proposal_hash: lotus_json.proposal_hash, + fn into_lotus_json(self) -> Self::LotusJson { + TxnIDParamsLotusJson { + id: self.id.0, + proposal_hash: self.proposal_hash, + } + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + id: fil_actor_multisig_state::[]::TxnID(lotus_json.id), + proposal_hash: lotus_json.proposal_hash, + } } } } @@ -259,34 +286,43 @@ macro_rules! impl_multisig_add_signer_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_multisig_state::[]::AddSignerParams { - type LotusJson = AddSignerParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![( - json!({ - "Signer": "f01234", - "Increase": true, - }), - Self { - signer: Address::new_id(1234).into(), - increase: true, - }, - )] + mod [] { + use super::*; + type T = fil_actor_multisig_state::[]::AddSignerParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - AddSignerParamsLotusJson { - signer: self.signer.into(), - increase: self.increase, + impl HasLotusJson for T { + type LotusJson = AddSignerParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![( + json!({ + "Signer": "f01234", + "Increase": true, + }), + Self { + signer: Address::new_id(1234).into(), + increase: true, + }, + )] } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - signer: lotus_json.signer.into(), - increase: lotus_json.increase, + fn into_lotus_json(self) -> Self::LotusJson { + AddSignerParamsLotusJson { + signer: self.signer.into(), + increase: self.increase, + } + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + signer: lotus_json.signer.into(), + increase: lotus_json.increase, + } } } } @@ -300,34 +336,43 @@ macro_rules! impl_multisig_remove_signer_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_multisig_state::[]::RemoveSignerParams { - type LotusJson = RemoveSignerParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![( - json!({ - "Signer": "f01234", - "Decrease": false, - }), - Self { - signer: Address::new_id(1234).into(), - decrease: false, - }, - )] + mod [] { + use super::*; + type T = fil_actor_multisig_state::[]::RemoveSignerParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - RemoveSignerParamsLotusJson { - signer: self.signer.into(), - decrease: self.decrease, + impl HasLotusJson for T { + type LotusJson = RemoveSignerParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![( + json!({ + "Signer": "f01234", + "Decrease": false, + }), + Self { + signer: Address::new_id(1234).into(), + decrease: false, + }, + )] } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - signer: lotus_json.signer.into(), - decrease: lotus_json.decrease, + fn into_lotus_json(self) -> Self::LotusJson { + RemoveSignerParamsLotusJson { + signer: self.signer.into(), + decrease: self.decrease, + } + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + signer: lotus_json.signer.into(), + decrease: lotus_json.decrease, + } } } } @@ -341,34 +386,43 @@ macro_rules! impl_multisig_swap_signer_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_multisig_state::[]::SwapSignerParams { - type LotusJson = SwapSignerParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![( - json!({ - "From": "f01234", - "To": "f01235", - }), - Self { - from: Address::new_id(1234).into(), - to: Address::new_id(1235).into(), - }, - )] + mod [] { + use super::*; + type T = fil_actor_multisig_state::[]::SwapSignerParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - SwapSignerParamsLotusJson { - from: self.from.into(), - to: self.to.into(), + impl HasLotusJson for T { + type LotusJson = SwapSignerParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![( + json!({ + "From": "f01234", + "To": "f01235", + }), + Self { + from: Address::new_id(1234).into(), + to: Address::new_id(1235).into(), + }, + )] } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - from: lotus_json.from.into(), - to: lotus_json.to.into(), + fn into_lotus_json(self) -> Self::LotusJson { + SwapSignerParamsLotusJson { + from: self.from.into(), + to: self.to.into(), + } + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + from: lotus_json.from.into(), + to: lotus_json.to.into(), + } } } } @@ -382,28 +436,37 @@ macro_rules! impl_multisig_change_num_approvals_threshold_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_multisig_state::[]::ChangeNumApprovalsThresholdParams { - type LotusJson = ChangeNumApprovalsThresholdParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![( - json!({ - "NewThreshold": 3, - }), - Self { new_threshold: 3 }, - )] + mod [] { + use super::*; + type T = fil_actor_multisig_state::[]::ChangeNumApprovalsThresholdParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - ChangeNumApprovalsThresholdParamsLotusJson { - new_threshold: self.new_threshold, + impl HasLotusJson for T { + type LotusJson = ChangeNumApprovalsThresholdParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![( + json!({ + "NewThreshold": 3, + }), + Self { new_threshold: 3 }, + )] } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - new_threshold: lotus_json.new_threshold, + fn into_lotus_json(self) -> Self::LotusJson { + ChangeNumApprovalsThresholdParamsLotusJson { + new_threshold: self.new_threshold, + } + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + new_threshold: lotus_json.new_threshold, + } } } } @@ -417,38 +480,47 @@ macro_rules! impl_multisig_lock_balance_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_multisig_state::[]::LockBalanceParams { - type LotusJson = LockBalanceParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![( - json!({ - "StartEpoch": 100, - "UnlockDuration": 200, - "Amount": "5000000000000000000", - }), - Self { - start_epoch: 100, - unlock_duration: 200, - amount: TokenAmount::from_atto(5000000000000000000u64).into(), - }, - )] + mod [] { + use super::*; + type T = fil_actor_multisig_state::[]::LockBalanceParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - LockBalanceParamsLotusJson { - start_epoch: self.start_epoch, - unlock_duration: self.unlock_duration, - amount: self.amount.into(), + impl HasLotusJson for T { + type LotusJson = LockBalanceParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![( + json!({ + "StartEpoch": 100, + "UnlockDuration": 200, + "Amount": "5000000000000000000", + }), + Self { + start_epoch: 100, + unlock_duration: 200, + amount: TokenAmount::from_atto(5000000000000000000u64).into(), + }, + )] + } + + fn into_lotus_json(self) -> Self::LotusJson { + LockBalanceParamsLotusJson { + start_epoch: self.start_epoch, + unlock_duration: self.unlock_duration, + amount: self.amount.into(), + } } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - start_epoch: lotus_json.start_epoch, - unlock_duration: lotus_json.unlock_duration, - amount: lotus_json.amount.into(), + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + start_epoch: lotus_json.start_epoch, + unlock_duration: lotus_json.unlock_duration, + amount: lotus_json.amount.into(), + } } } } diff --git a/src/lotus_json/actors/params/paych_params.rs b/src/lotus_json/actors/params/paych_params.rs index bdc126608914..c112fe246c08 100644 --- a/src/lotus_json/actors/params/paych_params.rs +++ b/src/lotus_json/actors/params/paych_params.rs @@ -164,36 +164,45 @@ macro_rules! impl_paych_constructor_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_paych_state::[]::ConstructorParams { - type LotusJson = ConstructorParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - json!({ - "From": "f01234", - "To": "f01235" - }), - Self { - from: Address::new_id(1234).into(), - to: Address::new_id(1235).into(), - }, - ), - ] + mod [] { + use super::*; + type T = fil_actor_paych_state::[]::ConstructorParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - ConstructorParamsLotusJson { - from: self.from.into(), - to: self.to.into(), + impl HasLotusJson for T { + type LotusJson = ConstructorParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + json!({ + "From": "f01234", + "To": "f01235" + }), + Self { + from: Address::new_id(1234).into(), + to: Address::new_id(1235).into(), + }, + ), + ] } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - from: lotus_json.from.into(), - to: lotus_json.to.into(), + fn into_lotus_json(self) -> Self::LotusJson { + ConstructorParamsLotusJson { + from: self.from.into(), + to: self.to.into(), + } + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + from: lotus_json.from.into(), + to: lotus_json.to.into(), + } } } } @@ -207,106 +216,115 @@ macro_rules! impl_paych_update_channel_state_params_v2 { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_paych_state::[]::UpdateChannelStateParams { - type LotusJson = UpdateChannelStateParamsV2LotusJson; + mod [] { + use super::*; + type T = fil_actor_paych_state::[]::UpdateChannelStateParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); + } - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - json!({ - "Sv": { - "ChannelAddr": "f01234", - "TimeLockMin": 0, - "TimeLockMax": 0, - "SecretPreImage": "", - "Extra": null, - "Lane": 0, - "Nonce": 1, - "Amount": "1000", - "MinSettleHeight": 0, - "Merges": [], - "Signature": null - }, - "Secret": "" - }), - Self { - sv: fil_actor_paych_state::[]::SignedVoucher { - channel_addr: Address::new_id(1234).into(), - time_lock_min: 0, - time_lock_max: 0, - secret_pre_image: vec![], - extra: None, - lane: 0, - nonce: 1, - amount: TokenAmount::from_atto(1000).into(), - min_settle_height: 0, - merges: vec![], - signature: None, + impl HasLotusJson for T { + type LotusJson = UpdateChannelStateParamsV2LotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + json!({ + "Sv": { + "ChannelAddr": "f01234", + "TimeLockMin": 0, + "TimeLockMax": 0, + "SecretHash": null, + "Extra": null, + "Lane": 0, + "Nonce": 1, + "Amount": "1000", + "MinSettleHeight": 0, + "Merges": null, + "Signature": null + }, + "Secret": null + }), + Self { + sv: fil_actor_paych_state::[]::SignedVoucher { + channel_addr: Address::new_id(1234).into(), + time_lock_min: 0, + time_lock_max: 0, + secret_pre_image: vec![], + extra: None, + lane: 0, + nonce: 1, + amount: TokenAmount::from_atto(1000).into(), + min_settle_height: 0, + merges: vec![], + signature: None, + }, + secret: vec![], }, - secret: vec![], - }, - ), - ] - } + ), + ] + } - fn into_lotus_json(self) -> Self::LotusJson { - UpdateChannelStateParamsV2LotusJson { - sv: SignedVoucherV2LotusJson { - channel_addr: self.sv.channel_addr.into(), - time_lock_min: self.sv.time_lock_min, - time_lock_max: self.sv.time_lock_max, - secret_pre_image: self.sv.secret_pre_image, - extra: self.sv.extra.map(|e| ModVerifyParamsLotusJson { - actor: e.actor.into(), - method: e.method, - data: e.data, - }), - lane: self.sv.lane, - nonce: self.sv.nonce, - amount: self.sv.amount.into(), - min_settle_height: self.sv.min_settle_height, - merges: if self.sv.merges.is_empty() { - None - } else { - Some(self.sv.merges.into_iter().map(|m| MergeLotusJson { - lane: m.lane, - nonce: m.nonce, - }).collect()) + fn into_lotus_json(self) -> Self::LotusJson { + UpdateChannelStateParamsV2LotusJson { + sv: SignedVoucherV2LotusJson { + channel_addr: self.sv.channel_addr.into(), + time_lock_min: self.sv.time_lock_min, + time_lock_max: self.sv.time_lock_max, + secret_pre_image: self.sv.secret_pre_image, + extra: self.sv.extra.map(|e| ModVerifyParamsLotusJson { + actor: e.actor.into(), + method: e.method, + data: e.data, + }), + lane: self.sv.lane, + nonce: self.sv.nonce, + amount: self.sv.amount.into(), + min_settle_height: self.sv.min_settle_height, + merges: if self.sv.merges.is_empty() { + None + } else { + Some(self.sv.merges.into_iter().map(|m| MergeLotusJson { + lane: m.lane, + nonce: m.nonce, + }).collect()) + }, + signature: self.sv.signature, }, - signature: self.sv.signature, - }, - secret: self.secret, + secret: self.secret, + } } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - sv: fil_actor_paych_state::[]::SignedVoucher { - channel_addr: lotus_json.sv.channel_addr.into(), - time_lock_min: lotus_json.sv.time_lock_min, - time_lock_max: lotus_json.sv.time_lock_max, - secret_pre_image: lotus_json.sv.secret_pre_image, - extra: lotus_json.sv.extra.map(|e| fil_actor_paych_state::[]::ModVerifyParams { - actor: e.actor.into(), - method: e.method, - data: e.data, - }), - lane: lotus_json.sv.lane, - nonce: lotus_json.sv.nonce, - amount: lotus_json.sv.amount.into(), - min_settle_height: lotus_json.sv.min_settle_height, - merges: if lotus_json.sv.merges.is_none() { - vec![] - } else { - lotus_json.sv.merges.unwrap().into_iter().map(|m| fil_actor_paych_state::[]::Merge { - lane: m.lane, - nonce: m.nonce, - }).collect() + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + sv: fil_actor_paych_state::[]::SignedVoucher { + channel_addr: lotus_json.sv.channel_addr.into(), + time_lock_min: lotus_json.sv.time_lock_min, + time_lock_max: lotus_json.sv.time_lock_max, + secret_pre_image: lotus_json.sv.secret_pre_image, + extra: lotus_json.sv.extra.map(|e| fil_actor_paych_state::[]::ModVerifyParams { + actor: e.actor.into(), + method: e.method, + data: e.data, + }), + lane: lotus_json.sv.lane, + nonce: lotus_json.sv.nonce, + amount: lotus_json.sv.amount.into(), + min_settle_height: lotus_json.sv.min_settle_height, + merges: if lotus_json.sv.merges.is_none() { + vec![] + } else { + lotus_json.sv.merges.unwrap().into_iter().map(|m| fil_actor_paych_state::[]::Merge { + lane: m.lane, + nonce: m.nonce, + }).collect() + }, + signature: lotus_json.sv.signature, }, - signature: lotus_json.sv.signature, - }, - secret: lotus_json.secret, + secret: lotus_json.secret, + } } } } @@ -319,106 +337,115 @@ macro_rules! impl_paych_update_channel_state_params_v3 { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_paych_state::[]::UpdateChannelStateParams { - type LotusJson = UpdateChannelStateParamsV3LotusJson; + mod [] { + use super::*; + type T = fil_actor_paych_state::[]::UpdateChannelStateParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); + } - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - json!({ - "Sv": { - "ChannelAddr": "f01234", - "TimeLockMin": 0, - "TimeLockMax": 0, - "SecretPreImage": "", - "Extra": null, - "Lane": 0, - "Nonce": 1, - "Amount": "1000", - "MinSettleHeight": 0, - "Merges": [], - "Signature": null - }, - "Secret": "" - }), - Self { - sv: fil_actor_paych_state::[]::SignedVoucher { - channel_addr: Address::new_id(1234).into(), - time_lock_min: 0, - time_lock_max: 0, - secret_pre_image: vec![], - extra: None, - lane: 0, - nonce: 1, - amount: TokenAmount::from_atto(1000).into(), - min_settle_height: 0, - merges: vec![], - signature: None, + impl HasLotusJson for T { + type LotusJson = UpdateChannelStateParamsV3LotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + json!({ + "Sv": { + "ChannelAddr": "f01234", + "TimeLockMin": 0, + "TimeLockMax": 0, + "SecretHash": null, + "Extra": null, + "Lane": 0, + "Nonce": 1, + "Amount": "1000", + "MinSettleHeight": 0, + "Merges": null, + "Signature": null + }, + "Secret": null + }), + Self { + sv: fil_actor_paych_state::[]::SignedVoucher { + channel_addr: Address::new_id(1234).into(), + time_lock_min: 0, + time_lock_max: 0, + secret_pre_image: vec![], + extra: None, + lane: 0, + nonce: 1, + amount: TokenAmount::from_atto(1000).into(), + min_settle_height: 0, + merges: vec![], + signature: None, + }, + secret: vec![], }, - secret: vec![], - }, - ), - ] - } + ), + ] + } - fn into_lotus_json(self) -> Self::LotusJson { - UpdateChannelStateParamsV3LotusJson { - sv: SignedVoucherV3LotusJson { - channel_addr: self.sv.channel_addr.into(), - time_lock_min: self.sv.time_lock_min, - time_lock_max: self.sv.time_lock_max, - secret_pre_image: self.sv.secret_pre_image, - extra: self.sv.extra.map(|e| ModVerifyParamsLotusJson { - actor: e.actor.into(), - method: e.method, - data: e.data, - }), - lane: self.sv.lane, - nonce: self.sv.nonce, - amount: self.sv.amount.into(), - min_settle_height: self.sv.min_settle_height, - merges: if self.sv.merges.is_empty() { - None - } else { - Some(self.sv.merges.into_iter().map(|m| MergeLotusJson { - lane: m.lane, - nonce: m.nonce, - }).collect()) + fn into_lotus_json(self) -> Self::LotusJson { + UpdateChannelStateParamsV3LotusJson { + sv: SignedVoucherV3LotusJson { + channel_addr: self.sv.channel_addr.into(), + time_lock_min: self.sv.time_lock_min, + time_lock_max: self.sv.time_lock_max, + secret_pre_image: self.sv.secret_pre_image, + extra: self.sv.extra.map(|e| ModVerifyParamsLotusJson { + actor: e.actor.into(), + method: e.method, + data: e.data, + }), + lane: self.sv.lane, + nonce: self.sv.nonce, + amount: self.sv.amount.into(), + min_settle_height: self.sv.min_settle_height, + merges: if self.sv.merges.is_empty() { + None + } else { + Some(self.sv.merges.into_iter().map(|m| MergeLotusJson { + lane: m.lane, + nonce: m.nonce, + }).collect()) + }, + signature: self.sv.signature, }, - signature: self.sv.signature, - }, - secret: self.secret, + secret: self.secret, + } } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - sv: fil_actor_paych_state::[]::SignedVoucher { - channel_addr: lotus_json.sv.channel_addr.into(), - time_lock_min: lotus_json.sv.time_lock_min, - time_lock_max: lotus_json.sv.time_lock_max, - secret_pre_image: lotus_json.sv.secret_pre_image, - extra: lotus_json.sv.extra.map(|e| fil_actor_paych_state::[]::ModVerifyParams { - actor: e.actor.into(), - method: e.method, - data: e.data, - }), - lane: lotus_json.sv.lane, - nonce: lotus_json.sv.nonce, - amount: lotus_json.sv.amount.into(), - min_settle_height: lotus_json.sv.min_settle_height, - merges: if lotus_json.sv.merges.is_none() { - vec![] - } else { - lotus_json.sv.merges.unwrap().into_iter().map(|m| fil_actor_paych_state::[]::Merge { - lane: m.lane, - nonce: m.nonce, - }).collect() + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + sv: fil_actor_paych_state::[]::SignedVoucher { + channel_addr: lotus_json.sv.channel_addr.into(), + time_lock_min: lotus_json.sv.time_lock_min, + time_lock_max: lotus_json.sv.time_lock_max, + secret_pre_image: lotus_json.sv.secret_pre_image, + extra: lotus_json.sv.extra.map(|e| fil_actor_paych_state::[]::ModVerifyParams { + actor: e.actor.into(), + method: e.method, + data: e.data, + }), + lane: lotus_json.sv.lane, + nonce: lotus_json.sv.nonce, + amount: lotus_json.sv.amount.into(), + min_settle_height: lotus_json.sv.min_settle_height, + merges: if lotus_json.sv.merges.is_none() { + vec![] + } else { + lotus_json.sv.merges.unwrap().into_iter().map(|m| fil_actor_paych_state::[]::Merge { + lane: m.lane, + nonce: m.nonce, + }).collect() + }, + signature: lotus_json.sv.signature, }, - signature: lotus_json.sv.signature, - }, - secret: lotus_json.secret, + secret: lotus_json.secret, + } } } } @@ -431,106 +458,115 @@ macro_rules! impl_paych_update_channel_state_params_v4 { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_paych_state::[]::UpdateChannelStateParams { - type LotusJson = UpdateChannelStateParamsV4LotusJson; + mod [] { + use super::*; + type T = fil_actor_paych_state::[]::UpdateChannelStateParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); + } - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - json!({ - "Sv": { - "ChannelAddr": "f01234", - "TimeLockMin": 0, - "TimeLockMax": 0, - "SecretPreImage": "", - "Extra": null, - "Lane": 0, - "Nonce": 1, - "Amount": "1000", - "MinSettleHeight": 0, - "Merges": [], - "Signature": null - }, - "Secret": "" - }), - Self { - sv: fil_actor_paych_state::[]::SignedVoucher { - channel_addr: Address::new_id(1234).into(), - time_lock_min: 0, - time_lock_max: 0, - secret_pre_image: vec![], - extra: None, - lane: 0, - nonce: 1, - amount: TokenAmount::from_atto(1000).into(), - min_settle_height: 0, - merges: vec![], - signature: None, + impl HasLotusJson for T { + type LotusJson = UpdateChannelStateParamsV4LotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + json!({ + "Sv": { + "ChannelAddr": "f01234", + "TimeLockMin": 0, + "TimeLockMax": 0, + "SecretHash": null, + "Extra": null, + "Lane": 0, + "Nonce": 1, + "Amount": "1000", + "MinSettleHeight": 0, + "Merges": null, + "Signature": null + }, + "Secret": null + }), + Self { + sv: fil_actor_paych_state::[]::SignedVoucher { + channel_addr: Address::new_id(1234).into(), + time_lock_min: 0, + time_lock_max: 0, + secret_pre_image: vec![], + extra: None, + lane: 0, + nonce: 1, + amount: TokenAmount::from_atto(1000).into(), + min_settle_height: 0, + merges: vec![], + signature: None, + }, + secret: vec![], }, - secret: vec![], - }, - ), - ] - } + ), + ] + } - fn into_lotus_json(self) -> Self::LotusJson { - UpdateChannelStateParamsV4LotusJson { - sv: SignedVoucherV4LotusJson { - channel_addr: self.sv.channel_addr.into(), - time_lock_min: self.sv.time_lock_min, - time_lock_max: self.sv.time_lock_max, - secret_pre_image: self.sv.secret_pre_image, - extra: self.sv.extra.map(|e| ModVerifyParamsLotusJson { - actor: e.actor.into(), - method: e.method, - data: e.data, - }), - lane: self.sv.lane, - nonce: self.sv.nonce, - amount: self.sv.amount.into(), - min_settle_height: self.sv.min_settle_height, - merges: if self.sv.merges.is_empty() { - None - } else { - Some(self.sv.merges.into_iter().map(|m| MergeLotusJson { - lane: m.lane, - nonce: m.nonce, - }).collect()) + fn into_lotus_json(self) -> Self::LotusJson { + UpdateChannelStateParamsV4LotusJson { + sv: SignedVoucherV4LotusJson { + channel_addr: self.sv.channel_addr.into(), + time_lock_min: self.sv.time_lock_min, + time_lock_max: self.sv.time_lock_max, + secret_pre_image: self.sv.secret_pre_image, + extra: self.sv.extra.map(|e| ModVerifyParamsLotusJson { + actor: e.actor.into(), + method: e.method, + data: e.data, + }), + lane: self.sv.lane, + nonce: self.sv.nonce, + amount: self.sv.amount.into(), + min_settle_height: self.sv.min_settle_height, + merges: if self.sv.merges.is_empty() { + None + } else { + Some(self.sv.merges.into_iter().map(|m| MergeLotusJson { + lane: m.lane, + nonce: m.nonce, + }).collect()) + }, + signature: self.sv.signature, }, - signature: self.sv.signature, - }, - secret: self.secret, + secret: self.secret, + } } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - sv: fil_actor_paych_state::[]::SignedVoucher { - channel_addr: lotus_json.sv.channel_addr.into(), - time_lock_min: lotus_json.sv.time_lock_min, - time_lock_max: lotus_json.sv.time_lock_max, - secret_pre_image: lotus_json.sv.secret_pre_image, - extra: lotus_json.sv.extra.map(|e| fil_actor_paych_state::[]::ModVerifyParams { - actor: e.actor.into(), - method: e.method, - data: e.data, - }), - lane: lotus_json.sv.lane, - nonce: lotus_json.sv.nonce, - amount: lotus_json.sv.amount.into(), - min_settle_height: lotus_json.sv.min_settle_height, - merges: if lotus_json.sv.merges.is_none() { - vec![] - } else { - lotus_json.sv.merges.unwrap().into_iter().map(|m| fil_actor_paych_state::[]::Merge { - lane: m.lane, - nonce: m.nonce, - }).collect() + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + sv: fil_actor_paych_state::[]::SignedVoucher { + channel_addr: lotus_json.sv.channel_addr.into(), + time_lock_min: lotus_json.sv.time_lock_min, + time_lock_max: lotus_json.sv.time_lock_max, + secret_pre_image: lotus_json.sv.secret_pre_image, + extra: lotus_json.sv.extra.map(|e| fil_actor_paych_state::[]::ModVerifyParams { + actor: e.actor.into(), + method: e.method, + data: e.data, + }), + lane: lotus_json.sv.lane, + nonce: lotus_json.sv.nonce, + amount: lotus_json.sv.amount.into(), + min_settle_height: lotus_json.sv.min_settle_height, + merges: if lotus_json.sv.merges.is_none() { + vec![] + } else { + lotus_json.sv.merges.unwrap().into_iter().map(|m| fil_actor_paych_state::[]::Merge { + lane: m.lane, + nonce: m.nonce, + }).collect() + }, + signature: lotus_json.sv.signature, }, - signature: lotus_json.sv.signature, - }, - secret: lotus_json.secret, + secret: lotus_json.secret, + } } } } diff --git a/src/lotus_json/actors/params/power_params.rs b/src/lotus_json/actors/params/power_params.rs index b9e1e091d380..cb11adff210a 100644 --- a/src/lotus_json/actors/params/power_params.rs +++ b/src/lotus_json/actors/params/power_params.rs @@ -79,48 +79,60 @@ macro_rules! impl_lotus_json_for_power_create_miner_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_power_state::[]::CreateMinerParams { - type LotusJson = CreateMinerParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - json!({ - "Owner": "f01234", - "Worker": "f01235", - "WindowPostProofType": 1, - "Peer": "AQ==", - "Multiaddrs": ["Ag==", "Aw=="], - }), - Self { - owner: Address::new_id(1234).into(), - worker: Address::new_id(1235).into(), - window_post_proof_type: RegisteredPoStProof::from(fvm_shared4::sector::RegisteredPoStProof::StackedDRGWindow2KiBV1P1).into(), - peer: vec![1], - multiaddrs: vec![], - }, - ), - ] + mod [] { + use super::*; + type T = fil_actor_power_state::[]::CreateMinerParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - CreateMinerParamsLotusJson { - owner: self.owner.into(), - worker: self.worker.into(), - window_po_st_proof_type: self.window_post_proof_type.into(), - peer: self.peer, - multiaddrs: self.multiaddrs.into_iter().map(|addr| addr.0).collect(), + impl HasLotusJson for T { + type LotusJson = CreateMinerParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + json!({ + "Owner": "f01234", + "Worker": "f01235", + "WindowPoStProofType": 10, + "Peer": "AQ==", + "Multiaddrs": ["L2lwNC8xMjcuMC4wLjEvdGNwLzgwODA=", "L2Rucy9leGFtcGxlLmNvbQ=="], + }), + Self { + owner: Address::new_id(1234).into(), + worker: Address::new_id(1235).into(), + window_post_proof_type: RegisteredPoStProof::from(fvm_shared4::sector::RegisteredPoStProof::StackedDRGWindow2KiBV1P1).into(), + peer: vec![1], + multiaddrs: vec![ + BytesDe(b"/ip4/127.0.0.1/tcp/8080".to_vec()), + BytesDe(b"/dns/example.com".to_vec()), + ], + }, + ), + ] + } + + fn into_lotus_json(self) -> Self::LotusJson { + CreateMinerParamsLotusJson { + owner: self.owner.into(), + worker: self.worker.into(), + window_po_st_proof_type: self.window_post_proof_type.into(), + peer: self.peer, + multiaddrs: self.multiaddrs.into_iter().map(|addr| addr.0).collect(), + } } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - owner: lotus_json.owner.into(), - worker: lotus_json.worker.into(), - window_post_proof_type: lotus_json.window_po_st_proof_type.into(), - peer: lotus_json.peer, - multiaddrs: lotus_json.multiaddrs.into_iter().map(BytesDe).collect(), + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + owner: lotus_json.owner.into(), + worker: lotus_json.worker.into(), + window_post_proof_type: lotus_json.window_po_st_proof_type.into(), + peer: lotus_json.peer, + multiaddrs: lotus_json.multiaddrs.into_iter().map(BytesDe).collect(), + } } } } @@ -134,36 +146,45 @@ macro_rules! impl_lotus_json_for_power_update_claimed_power_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_power_state::[]::UpdateClaimedPowerParams { - type LotusJson = UpdateClaimedPowerParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - json!({ - "RawByteDelta": "1024", - "QualityAdjustedDelta": "2048", - }), - Self { - raw_byte_delta: crate::shim::sector::StoragePower::from(1024u64), - quality_adjusted_delta: crate::shim::sector::StoragePower::from(2048u64), - }, - ), - ] + mod [] { + use super::*; + type T = fil_actor_power_state::[]::UpdateClaimedPowerParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - UpdateClaimedPowerParamsLotusJson { - raw_byte_delta: self.raw_byte_delta, - quality_adjusted_delta: self.quality_adjusted_delta, + impl HasLotusJson for T { + type LotusJson = UpdateClaimedPowerParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + json!({ + "RawByteDelta": "1024", + "QualityAdjustedDelta": "2048", + }), + Self { + raw_byte_delta: crate::shim::sector::StoragePower::from(1024u64), + quality_adjusted_delta: crate::shim::sector::StoragePower::from(2048u64), + }, + ), + ] } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - raw_byte_delta: lotus_json.raw_byte_delta, - quality_adjusted_delta: lotus_json.quality_adjusted_delta, + fn into_lotus_json(self) -> Self::LotusJson { + UpdateClaimedPowerParamsLotusJson { + raw_byte_delta: self.raw_byte_delta, + quality_adjusted_delta: self.quality_adjusted_delta, + } + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + raw_byte_delta: lotus_json.raw_byte_delta, + quality_adjusted_delta: lotus_json.quality_adjusted_delta, + } } } } @@ -177,36 +198,45 @@ macro_rules! impl_lotus_json_for_power_enroll_cron_event_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_power_state::[]::EnrollCronEventParams { - type LotusJson = EnrollCronEventParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - json!({ - "EventEpoch": 12345, - "Payload": "ESIzRFU=", - }), - Self { - event_epoch: 12345, - payload: RawBytes::new(hex::decode("1122334455").unwrap()), - }, - ), - ] + mod [] { + use super::*; + type T = fil_actor_power_state::[]::EnrollCronEventParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - EnrollCronEventParamsLotusJson { - event_epoch: self.event_epoch, - payload: self.payload, + impl HasLotusJson for T { + type LotusJson = EnrollCronEventParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + json!({ + "EventEpoch": 12345, + "Payload": "ESIzRFU=", + }), + Self { + event_epoch: 12345, + payload: RawBytes::new(hex::decode("1122334455").unwrap()), + }, + ), + ] } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - event_epoch: lotus_json.event_epoch, - payload: lotus_json.payload, + fn into_lotus_json(self) -> Self::LotusJson { + EnrollCronEventParamsLotusJson { + event_epoch: self.event_epoch, + payload: self.payload, + } + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + event_epoch: lotus_json.event_epoch, + payload: lotus_json.payload, + } } } } @@ -220,30 +250,37 @@ macro_rules! impl_lotus_json_for_power_update_pledge_total_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_power_state::[]::UpdatePledgeTotalParams { - type LotusJson = UpdatePledgeTotalParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - json!({ - "PledgeDelta": "1000000000000000000", - }), - Self { - pledge_delta: TokenAmount::from_atto(1000000000000000000u64).into(), - }, - ), - ] + mod [] { + use super::*; + type T = fil_actor_power_state::[]::UpdatePledgeTotalParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - UpdatePledgeTotalParamsLotusJson(self.pledge_delta.into()) - } + impl HasLotusJson for T { + type LotusJson = UpdatePledgeTotalParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + json!("1000000000000000000"), + Self { + pledge_delta: TokenAmount::from_atto(1000000000000000000u64).into(), + }, + ), + ] + } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - pledge_delta: lotus_json.0.into(), + fn into_lotus_json(self) -> Self::LotusJson { + UpdatePledgeTotalParamsLotusJson(self.pledge_delta.into()) + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + pledge_delta: lotus_json.0.into(), + } } } } @@ -257,30 +294,37 @@ macro_rules! impl_lotus_json_for_power_miner_raw_power_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_power_state::[]::MinerRawPowerParams { - type LotusJson = MinerRawPowerParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - json!({ - "Miner": 1001, - }), - Self { - miner: 1001, - }, - ), - ] + mod [] { + use super::*; + type T = fil_actor_power_state::[]::MinerRawPowerParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - MinerRawPowerParamsLotusJson(self.miner) - } + impl HasLotusJson for T { + type LotusJson = MinerRawPowerParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + json!(1001), + Self { + miner: 1001, + }, + ), + ] + } + + fn into_lotus_json(self) -> Self::LotusJson { + MinerRawPowerParamsLotusJson(self.miner) + } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - miner: lotus_json.0, + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + miner: lotus_json.0, + } } } } @@ -290,50 +334,68 @@ macro_rules! impl_lotus_json_for_power_miner_raw_power_params { } // Implementations for MinerPowerParams (only present in the power actor v16 and v17) -impl HasLotusJson for fil_actor_power_state::v16::MinerPowerParams { - type LotusJson = MinerPowerParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![( - json!({ - "Miner": 1002, - }), - Self { miner: 1002 }, - )] +mod impl_power_miner_power_params_v16 { + use super::*; + type T = fil_actor_power_state::v16::MinerPowerParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - MinerPowerParamsLotusJson { miner: self.miner } - } + impl HasLotusJson for T { + type LotusJson = MinerPowerParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![( + json!({ + "Miner": 1002, + }), + Self { miner: 1002 }, + )] + } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - miner: lotus_json.miner, + fn into_lotus_json(self) -> Self::LotusJson { + MinerPowerParamsLotusJson { miner: self.miner } + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + miner: lotus_json.miner, + } } } } -impl HasLotusJson for fil_actor_power_state::v17::MinerPowerParams { - type LotusJson = MinerPowerParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![( - json!({ - "Miner": 1002, - }), - Self { miner: 1002 }, - )] +mod impl_power_miner_power_params_v17 { + use super::*; + type T = fil_actor_power_state::v17::MinerPowerParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - MinerPowerParamsLotusJson { miner: self.miner } - } + impl HasLotusJson for T { + type LotusJson = MinerPowerParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![( + json!({ + "Miner": 1002, + }), + Self { miner: 1002 }, + )] + } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - miner: lotus_json.miner, + fn into_lotus_json(self) -> Self::LotusJson { + MinerPowerParamsLotusJson { miner: self.miner } + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + miner: lotus_json.miner, + } } } } diff --git a/src/lotus_json/actors/params/reward_params.rs b/src/lotus_json/actors/params/reward_params.rs index 5d005d765c53..92b335af18e8 100644 --- a/src/lotus_json/actors/params/reward_params.rs +++ b/src/lotus_json/actors/params/reward_params.rs @@ -45,34 +45,43 @@ macro_rules! impl_reward_constructor_params { ($type_suffix:path: $($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_reward_state::[]::ConstructorParams { - type LotusJson = RewardConstructorParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - json!(null), - Self { - power: None, - }, - ), - ( - json!("1000"), - Self { - power: Some($type_suffix::bigint_ser::BigIntDe(BigInt::from(1000))), - }, - ), - ] + mod [] { + use super::*; + type T = fil_actor_reward_state::[]::ConstructorParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - RewardConstructorParamsLotusJson(self.power.map(|p| p.0)) - } + impl HasLotusJson for T { + type LotusJson = RewardConstructorParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + json!(null), + Self { + power: None, + }, + ), + ( + json!("1000"), + Self { + power: Some($type_suffix::bigint_ser::BigIntDe(BigInt::from(1000))), + }, + ), + ] + } + + fn into_lotus_json(self) -> Self::LotusJson { + RewardConstructorParamsLotusJson(self.power.map(|p| p.0)) + } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - power: lotus_json.0.map(|p| $type_suffix::bigint_ser::BigIntDe(p)), + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + power: lotus_json.0.map(|p| $type_suffix::bigint_ser::BigIntDe(p)), + } } } } @@ -86,44 +95,53 @@ macro_rules! impl_award_block_reward_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_reward_state::[]::AwardBlockRewardParams { - type LotusJson = AwardBlockRewardParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - json!({ - "Miner": "f01234", - "Penalty": "0", - "GasReward": "1000", - "WinCount": 1 - }), - Self { - miner: Address::new_id(1234).into(), - penalty: TokenAmount::from_atto(0).into(), - gas_reward: TokenAmount::from_atto(1000).into(), - win_count: 1, - }, - ), - ] + mod [] { + use super::*; + type T = fil_actor_reward_state::[]::AwardBlockRewardParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - AwardBlockRewardParamsLotusJson { - miner: self.miner.into(), - penalty: self.penalty.into(), - gas_reward: self.gas_reward.into(), - win_count: self.win_count, + impl HasLotusJson for T { + type LotusJson = AwardBlockRewardParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + json!({ + "Miner": "f01234", + "Penalty": "0", + "GasReward": "1000", + "WinCount": 1 + }), + Self { + miner: Address::new_id(1234).into(), + penalty: TokenAmount::from_atto(0).into(), + gas_reward: TokenAmount::from_atto(1000).into(), + win_count: 1, + }, + ), + ] } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - miner: lotus_json.miner.into(), - penalty: TokenAmount::from(lotus_json.penalty).into(), - gas_reward: TokenAmount::from(lotus_json.gas_reward).into(), - win_count: lotus_json.win_count, + fn into_lotus_json(self) -> Self::LotusJson { + AwardBlockRewardParamsLotusJson { + miner: self.miner.into(), + penalty: self.penalty.into(), + gas_reward: self.gas_reward.into(), + win_count: self.win_count, + } + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + miner: lotus_json.miner.into(), + penalty: TokenAmount::from(lotus_json.penalty).into(), + gas_reward: TokenAmount::from(lotus_json.gas_reward).into(), + win_count: lotus_json.win_count, + } } } } @@ -137,34 +155,43 @@ macro_rules! impl_update_network_kpi_params { ($type_suffix:path: $($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_reward_state::[]::UpdateNetworkKPIParams { - type LotusJson = UpdateNetworkKPIParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![ - ( - json!(null), - Self { - curr_realized_power: None, - }, - ), - ( - json!("2000"), - Self { - curr_realized_power: Some($type_suffix::bigint_ser::BigIntDe(BigInt::from(2000))), - }, - ), - ] + mod [] { + use super::*; + type T = fil_actor_reward_state::[]::UpdateNetworkKPIParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - UpdateNetworkKPIParamsLotusJson(self.curr_realized_power.map(|p| p.0)) - } + impl HasLotusJson for T { + type LotusJson = UpdateNetworkKPIParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![ + ( + json!(null), + Self { + curr_realized_power: None, + }, + ), + ( + json!("2000"), + Self { + curr_realized_power: Some($type_suffix::bigint_ser::BigIntDe(BigInt::from(2000))), + }, + ), + ] + } + + fn into_lotus_json(self) -> Self::LotusJson { + UpdateNetworkKPIParamsLotusJson(self.curr_realized_power.map(|p| p.0)) + } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - curr_realized_power: lotus_json.0.map(|p| $type_suffix::bigint_ser::BigIntDe(p)), + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + curr_realized_power: lotus_json.0.map(|p| $type_suffix::bigint_ser::BigIntDe(p)), + } } } } diff --git a/src/lotus_json/actors/params/verified_reg_params.rs b/src/lotus_json/actors/params/verified_reg_params.rs index 3317150482ea..e599becd92ed 100644 --- a/src/lotus_json/actors/params/verified_reg_params.rs +++ b/src/lotus_json/actors/params/verified_reg_params.rs @@ -270,28 +270,35 @@ macro_rules! impl_constructor_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_verifreg_state::[]::ConstructorParams { - type LotusJson = ConstructorParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![( - json!({ - "RootKey": "f01234", - }), - Self { - root_key: Address::new_id(1234).into(), - }, - )] + mod [] { + use super::*; + type T = fil_actor_verifreg_state::[]::ConstructorParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - ConstructorParamsLotusJson(self.root_key.into()) - } + impl HasLotusJson for T { + type LotusJson = ConstructorParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![( + json!("f01234"), + Self { + root_key: Address::new_id(1234).into(), + }, + )] + } + + fn into_lotus_json(self) -> Self::LotusJson { + ConstructorParamsLotusJson(self.root_key.into()) + } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - root_key: lotus_json.0.into(), + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + root_key: lotus_json.0.into(), + } } } } @@ -304,34 +311,43 @@ macro_rules! impl_verifier_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_verifreg_state::[]::VerifierParams { - type LotusJson = VerifierParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![( - json!({ - "Address": "f01234", - "Allowance": "1000000000000000000", - }), - Self { - address: Address::new_id(1234).into(), - allowance: BigInt::from(1000000000000000000u64), - }, - )] + mod [] { + use super::*; + type T = fil_actor_verifreg_state::[]::VerifierParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - VerifierParamsLotusJson { - address: self.address.into(), - allowance: self.allowance, + impl HasLotusJson for T { + type LotusJson = VerifierParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![( + json!({ + "Address": "f01234", + "Allowance": "1000000000000000000", + }), + Self { + address: Address::new_id(1234).into(), + allowance: BigInt::from(1000000000000000000u64), + }, + )] } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - address: lotus_json.address.into(), - allowance: lotus_json.allowance, + fn into_lotus_json(self) -> Self::LotusJson { + VerifierParamsLotusJson { + address: self.address.into(), + allowance: self.allowance, + } + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + address: lotus_json.address.into(), + allowance: lotus_json.allowance, + } } } } @@ -345,28 +361,35 @@ macro_rules! impl_remove_verifier_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_verifreg_state::[]::RemoveVerifierParams { - type LotusJson = RemoveVerifierParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![( - json!({ - "Verifier": "f01234", - }), - Self { - verifier: Address::new_id(1234).into(), - }, - )] + mod [] { + use super::*; + type T = fil_actor_verifreg_state::[]::RemoveVerifierParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - RemoveVerifierParamsLotusJson(self.verifier.into()) - } + impl HasLotusJson for T { + type LotusJson = RemoveVerifierParamsLotusJson; - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - verifier: lotus_json.0.into(), + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![( + json!("f01234"), + Self { + verifier: Address::new_id(1234).into(), + }, + )] + } + + fn into_lotus_json(self) -> Self::LotusJson { + RemoveVerifierParamsLotusJson(self.verifier.into()) + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + verifier: lotus_json.0.into(), + } } } } @@ -380,34 +403,43 @@ macro_rules! impl_remove_expired_allocations_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_verifreg_state::[]::RemoveExpiredAllocationsParams { - type LotusJson = RemoveExpiredAllocationsParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![( - json!({ - "Client": 1001, - "AllocationIds": [1, 2, 3], - }), - Self { - client: 1001, - allocation_ids: vec![1, 2, 3], - }, - )] + mod [] { + use super::*; + type T = fil_actor_verifreg_state::[]::RemoveExpiredAllocationsParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - RemoveExpiredAllocationsParamsLotusJson { - client: self.client, - allocation_ids: self.allocation_ids, + impl HasLotusJson for T { + type LotusJson = RemoveExpiredAllocationsParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![( + json!({ + "Client": 1001, + "AllocationIds": [1, 2, 3], + }), + Self { + client: 1001, + allocation_ids: vec![1, 2, 3], + }, + )] } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - client: lotus_json.client, - allocation_ids: lotus_json.allocation_ids, + fn into_lotus_json(self) -> Self::LotusJson { + RemoveExpiredAllocationsParamsLotusJson { + client: self.client, + allocation_ids: self.allocation_ids, + } + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + client: lotus_json.client, + allocation_ids: lotus_json.allocation_ids, + } } } } @@ -421,34 +453,43 @@ macro_rules! impl_get_claims_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_verifreg_state::[]::GetClaimsParams { - type LotusJson = GetClaimsParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![( - json!({ - "Provider": 1001, - "ClaimIds": [1, 2, 3], - }), - Self { - provider: 1001, - claim_ids: vec![1, 2, 3], - }, - )] + mod [] { + use super::*; + type T = fil_actor_verifreg_state::[]::GetClaimsParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - GetClaimsParamsLotusJson { - provider: self.provider, - claim_ids: self.claim_ids, + impl HasLotusJson for T { + type LotusJson = GetClaimsParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![( + json!({ + "Provider": 1001, + "ClaimIds": [1, 2, 3], + }), + Self { + provider: 1001, + claim_ids: vec![1, 2, 3], + }, + )] } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - provider: lotus_json.provider, - claim_ids: lotus_json.claim_ids, + fn into_lotus_json(self) -> Self::LotusJson { + GetClaimsParamsLotusJson { + provider: self.provider, + claim_ids: self.claim_ids, + } + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + provider: lotus_json.provider, + claim_ids: lotus_json.claim_ids, + } } } } @@ -462,34 +503,43 @@ macro_rules! impl_remove_expired_claims_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_verifreg_state::[]::RemoveExpiredClaimsParams { - type LotusJson = RemoveExpiredClaimsParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![( - json!({ - "Provider": 1001, - "ClaimIds": [1, 2, 3], - }), - Self { - provider: 1001, - claim_ids: vec![1, 2, 3], - }, - )] + mod [] { + use super::*; + type T = fil_actor_verifreg_state::[]::RemoveExpiredClaimsParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - RemoveExpiredClaimsParamsLotusJson { - provider: self.provider, - claim_ids: self.claim_ids, + impl HasLotusJson for T { + type LotusJson = RemoveExpiredClaimsParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![( + json!({ + "Provider": 1001, + "ClaimIds": [1, 2, 3], + }), + Self { + provider: 1001, + claim_ids: vec![1, 2, 3], + }, + )] } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - provider: lotus_json.provider, - claim_ids: lotus_json.claim_ids, + fn into_lotus_json(self) -> Self::LotusJson { + RemoveExpiredClaimsParamsLotusJson { + provider: self.provider, + claim_ids: self.claim_ids, + } + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + provider: lotus_json.provider, + claim_ids: lotus_json.claim_ids, + } } } } @@ -536,56 +586,65 @@ macro_rules! impl_extend_claim_terms_params { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_verifreg_state::[]::ExtendClaimTermsParams { - type LotusJson = ExtendClaimTermsParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![( - json!({ - "Terms": [ - { - "Provider": 1001, - "ClaimId": 1, - "TermMax": 12345, - } - ], - }), - Self { - terms: vec![fil_actor_verifreg_state::[]::ClaimTerm { - provider: 1001, - claim_id: 1, - term_max: 12345, - }], - }, - )] + mod [] { + use super::*; + type T = fil_actor_verifreg_state::[]::ExtendClaimTermsParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - ExtendClaimTermsParamsLotusJson { - terms: self - .terms - .into_iter() - .map(|term| ClaimTermLotusJson { - provider: term.provider, - claim_id: term.claim_id, - term_max: term.term_max, - }) - .collect(), + impl HasLotusJson for T { + type LotusJson = ExtendClaimTermsParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![( + json!({ + "Terms": [ + { + "Provider": 1001, + "ClaimId": 1, + "TermMax": 12345, + } + ], + }), + Self { + terms: vec![fil_actor_verifreg_state::[]::ClaimTerm { + provider: 1001, + claim_id: 1, + term_max: 12345, + }], + }, + )] + } + + fn into_lotus_json(self) -> Self::LotusJson { + ExtendClaimTermsParamsLotusJson { + terms: self + .terms + .into_iter() + .map(|term| ClaimTermLotusJson { + provider: term.provider, + claim_id: term.claim_id, + term_max: term.term_max, + }) + .collect(), + } } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - terms: lotus_json - .terms - .into_iter() - .map(|term| fil_actor_verifreg_state::[]::ClaimTerm { - provider: term.provider, - claim_id: term.claim_id, - term_max: term.term_max, - }) - .collect(), + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + terms: lotus_json + .terms + .into_iter() + .map(|term| fil_actor_verifreg_state::[]::ClaimTerm { + provider: term.provider, + claim_id: term.claim_id, + term_max: term.term_max, + }) + .collect(), + } } } } @@ -599,78 +658,87 @@ macro_rules! impl_remove_data_cap_params_v2 { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_verifreg_state::[]::RemoveDataCapParams { - type LotusJson = RemoveDataCapParamsV2LotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![( - json!({ - "VerifiedClientToRemove": "f01234", - "DataCapAmountToRemove": "1000000000000000000", - "VerifierRequest1": { - "Verifier": "f01235", - "Signature": { - "Type": 1, - "Data": "dGVzdA==", - } + mod [] { + use super::*; + type T = fil_actor_verifreg_state::[]::RemoveDataCapParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); + } + + impl HasLotusJson for T { + type LotusJson = RemoveDataCapParamsV2LotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![( + json!({ + "VerifiedClientToRemove": "f01234", + "DataCapAmountToRemove": "1000000000000000000", + "VerifierRequest1": { + "Verifier": "f01235", + "VerifierSignature": { + "Type": 1, + "Data": "dGVzdA==", + } + }, + "VerifierRequest2": { + "Verifier": "f01236", + "VerifierSignature": { + "Type": 1, + "Data": "dGVzdA==", + } + }, + }), + Self { + verified_client_to_remove: Address::new_id(1234).into(), + data_cap_amount_to_remove: BigInt::from(1000000000000000000u64), + verifier_request_1: fil_actor_verifreg_state::[]::RemoveDataCapRequest { + verifier: Address::new_id(1235).into(), + signature: fvm_shared2::crypto::signature::Signature { + sig_type: fvm_shared2::crypto::signature::SignatureType::Secp256k1, + bytes: b"test".to_vec(), + }, + }, + verifier_request_2: fil_actor_verifreg_state::[]::RemoveDataCapRequest { + verifier: Address::new_id(1236).into(), + signature: fvm_shared2::crypto::signature::Signature { + sig_type: fvm_shared2::crypto::signature::SignatureType::Secp256k1, + bytes: b"test".to_vec(), + }, + }, + }, + )] + } + + fn into_lotus_json(self) -> Self::LotusJson { + RemoveDataCapParamsV2LotusJson { + verified_client_to_remove: self.verified_client_to_remove.into(), + data_cap_amount_to_remove: self.data_cap_amount_to_remove, + verifier_request_1: RemoveDataCapRequestV2LotusJson { + verifier: self.verifier_request_1.verifier.into(), + signature: self.verifier_request_1.signature, }, - "VerifierRequest2": { - "Verifier": "f01236", - "Signature": { - "Type": 1, - "Data": "dGVzdA==", - } + verifier_request_2: RemoveDataCapRequestV2LotusJson { + verifier: self.verifier_request_2.verifier.into(), + signature: self.verifier_request_2.signature, }, - }), + } + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { Self { - verified_client_to_remove: Address::new_id(1234).into(), - data_cap_amount_to_remove: BigInt::from(1000000000000000000u64), + verified_client_to_remove: lotus_json.verified_client_to_remove.into(), + data_cap_amount_to_remove: lotus_json.data_cap_amount_to_remove, verifier_request_1: fil_actor_verifreg_state::[]::RemoveDataCapRequest { - verifier: Address::new_id(1235).into(), - signature: fvm_shared2::crypto::signature::Signature { - sig_type: fvm_shared2::crypto::signature::SignatureType::Secp256k1, - bytes: b"test".to_vec(), - }, + verifier: lotus_json.verifier_request_1.verifier.into(), + signature: lotus_json.verifier_request_1.signature, }, verifier_request_2: fil_actor_verifreg_state::[]::RemoveDataCapRequest { - verifier: Address::new_id(1236).into(), - signature: fvm_shared2::crypto::signature::Signature { - sig_type: fvm_shared2::crypto::signature::SignatureType::Secp256k1, - bytes: b"test".to_vec(), - }, + verifier: lotus_json.verifier_request_2.verifier.into(), + signature: lotus_json.verifier_request_2.signature, }, - }, - )] - } - - fn into_lotus_json(self) -> Self::LotusJson { - RemoveDataCapParamsV2LotusJson { - verified_client_to_remove: self.verified_client_to_remove.into(), - data_cap_amount_to_remove: self.data_cap_amount_to_remove, - verifier_request_1: RemoveDataCapRequestV2LotusJson { - verifier: self.verifier_request_1.verifier.into(), - signature: self.verifier_request_1.signature, - }, - verifier_request_2: RemoveDataCapRequestV2LotusJson { - verifier: self.verifier_request_2.verifier.into(), - signature: self.verifier_request_2.signature, - }, - } - } - - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - verified_client_to_remove: lotus_json.verified_client_to_remove.into(), - data_cap_amount_to_remove: lotus_json.data_cap_amount_to_remove, - verifier_request_1: fil_actor_verifreg_state::[]::RemoveDataCapRequest { - verifier: lotus_json.verifier_request_1.verifier.into(), - signature: lotus_json.verifier_request_1.signature, - }, - verifier_request_2: fil_actor_verifreg_state::[]::RemoveDataCapRequest { - verifier: lotus_json.verifier_request_2.verifier.into(), - signature: lotus_json.verifier_request_2.signature, - }, + } } } } @@ -683,78 +751,87 @@ macro_rules! impl_remove_data_cap_params_v3 { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_verifreg_state::[]::RemoveDataCapParams { - type LotusJson = RemoveDataCapParamsV3LotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![( - json!({ - "VerifiedClientToRemove": "f01234", - "DataCapAmountToRemove": "1000000000000000000", - "VerifierRequest1": { - "Verifier": "f01235", - "VerifierSignature": { - "Type": 1, - "Data": "dGVzdA==", - } + mod [] { + use super::*; + type T = fil_actor_verifreg_state::[]::RemoveDataCapParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); + } + + impl HasLotusJson for T { + type LotusJson = RemoveDataCapParamsV3LotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![( + json!({ + "VerifiedClientToRemove": "f01234", + "DataCapAmountToRemove": "1000000000000000000", + "VerifierRequest1": { + "Verifier": "f01235", + "VerifierSignature": { + "Type": 1, + "Data": "dGVzdA==", + } + }, + "VerifierRequest2": { + "Verifier": "f01236", + "VerifierSignature": { + "Type": 1, + "Data": "dGVzdA==", + } + }, + }), + Self { + verified_client_to_remove: Address::new_id(1234).into(), + data_cap_amount_to_remove: BigInt::from(1000000000000000000u64), + verifier_request_1: fil_actor_verifreg_state::[]::RemoveDataCapRequest { + verifier: Address::new_id(1235).into(), + signature: fvm_shared3::crypto::signature::Signature { + sig_type: fvm_shared3::crypto::signature::SignatureType::Secp256k1, + bytes: b"test".to_vec(), + }, + }, + verifier_request_2: fil_actor_verifreg_state::[]::RemoveDataCapRequest { + verifier: Address::new_id(1236).into(), + signature: fvm_shared3::crypto::signature::Signature { + sig_type: fvm_shared3::crypto::signature::SignatureType::Secp256k1, + bytes: b"test".to_vec(), + }, + }, + }, + )] + } + + fn into_lotus_json(self) -> Self::LotusJson { + RemoveDataCapParamsV3LotusJson { + verified_client_to_remove: self.verified_client_to_remove.into(), + data_cap_amount_to_remove: self.data_cap_amount_to_remove, + verifier_request_1: RemoveDataCapRequestV3LotusJson { + verifier: self.verifier_request_1.verifier.into(), + signature: self.verifier_request_1.signature, }, - "VerifierRequest2": { - "Verifier": "f01236", - "VerifierSignature": { - "Type": 1, - "Data": "dGVzdA==", - } + verifier_request_2: RemoveDataCapRequestV3LotusJson { + verifier: self.verifier_request_2.verifier.into(), + signature: self.verifier_request_2.signature, }, - }), + } + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { Self { - verified_client_to_remove: Address::new_id(1234).into(), - data_cap_amount_to_remove: BigInt::from(1000000000000000000u64), + verified_client_to_remove: lotus_json.verified_client_to_remove.into(), + data_cap_amount_to_remove: lotus_json.data_cap_amount_to_remove, verifier_request_1: fil_actor_verifreg_state::[]::RemoveDataCapRequest { - verifier: Address::new_id(1235).into(), - signature: fvm_shared3::crypto::signature::Signature { - sig_type: fvm_shared3::crypto::signature::SignatureType::Secp256k1, - bytes: b"test".to_vec(), - }, + verifier: lotus_json.verifier_request_1.verifier.into(), + signature: lotus_json.verifier_request_1.signature, }, verifier_request_2: fil_actor_verifreg_state::[]::RemoveDataCapRequest { - verifier: Address::new_id(1236).into(), - signature: fvm_shared3::crypto::signature::Signature { - sig_type: fvm_shared3::crypto::signature::SignatureType::Secp256k1, - bytes: b"test".to_vec(), - }, + verifier: lotus_json.verifier_request_2.verifier.into(), + signature: lotus_json.verifier_request_2.signature, }, - }, - )] - } - - fn into_lotus_json(self) -> Self::LotusJson { - RemoveDataCapParamsV3LotusJson { - verified_client_to_remove: self.verified_client_to_remove.into(), - data_cap_amount_to_remove: self.data_cap_amount_to_remove, - verifier_request_1: RemoveDataCapRequestV3LotusJson { - verifier: self.verifier_request_1.verifier.into(), - signature: self.verifier_request_1.signature, - }, - verifier_request_2: RemoveDataCapRequestV3LotusJson { - verifier: self.verifier_request_2.verifier.into(), - signature: self.verifier_request_2.signature, - }, - } - } - - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - verified_client_to_remove: lotus_json.verified_client_to_remove.into(), - data_cap_amount_to_remove: lotus_json.data_cap_amount_to_remove, - verifier_request_1: fil_actor_verifreg_state::[]::RemoveDataCapRequest { - verifier: lotus_json.verifier_request_1.verifier.into(), - signature: lotus_json.verifier_request_1.signature, - }, - verifier_request_2: fil_actor_verifreg_state::[]::RemoveDataCapRequest { - verifier: lotus_json.verifier_request_2.verifier.into(), - signature: lotus_json.verifier_request_2.signature, - }, + } } } } @@ -767,78 +844,87 @@ macro_rules! impl_remove_data_cap_params_v4 { ($($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_verifreg_state::[]::RemoveDataCapParams { - type LotusJson = RemoveDataCapParamsV4LotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![( - json!({ - "VerifiedClientToRemove": "f01234", - "DataCapAmountToRemove": "1000000000000000000", - "VerifierRequest1": { - "Verifier": "f01235", - "VerifierSignature": { - "Type": 1, - "Data": "dGVzdA==", - } + mod [] { + use super::*; + type T = fil_actor_verifreg_state::[]::RemoveDataCapParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); + } + + impl HasLotusJson for T { + type LotusJson = RemoveDataCapParamsV4LotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![( + json!({ + "VerifiedClientToRemove": "f01234", + "DataCapAmountToRemove": "1000000000000000000", + "VerifierRequest1": { + "Verifier": "f01235", + "VerifierSignature": { + "Type": 1, + "Data": "dGVzdA==", + } + }, + "VerifierRequest2": { + "Verifier": "f01236", + "VerifierSignature": { + "Type": 1, + "Data": "dGVzdA==", + } + }, + }), + Self { + verified_client_to_remove: Address::new_id(1234).into(), + data_cap_amount_to_remove: BigInt::from(1000000000000000000u64), + verifier_request_1: fil_actor_verifreg_state::[]::RemoveDataCapRequest { + verifier: Address::new_id(1235).into(), + signature: fvm_shared4::crypto::signature::Signature { + sig_type: fvm_shared4::crypto::signature::SignatureType::Secp256k1, + bytes: b"test".to_vec(), + }, + }, + verifier_request_2: fil_actor_verifreg_state::[]::RemoveDataCapRequest { + verifier: Address::new_id(1236).into(), + signature: fvm_shared4::crypto::signature::Signature { + sig_type: fvm_shared4::crypto::signature::SignatureType::Secp256k1, + bytes: b"test".to_vec(), + }, + }, + }, + )] + } + + fn into_lotus_json(self) -> Self::LotusJson { + RemoveDataCapParamsV4LotusJson { + verified_client_to_remove: self.verified_client_to_remove.into(), + data_cap_amount_to_remove: self.data_cap_amount_to_remove, + verifier_request_1: RemoveDataCapRequestV4LotusJson { + verifier: self.verifier_request_1.verifier.into(), + signature: self.verifier_request_1.signature, }, - "VerifierRequest2": { - "Verifier": "f01236", - "VerifierSignature": { - "Type": 1, - "Data": "dGVzdA==", - } + verifier_request_2: RemoveDataCapRequestV4LotusJson { + verifier: self.verifier_request_2.verifier.into(), + signature: self.verifier_request_2.signature, }, - }), + } + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { Self { - verified_client_to_remove: Address::new_id(1234).into(), - data_cap_amount_to_remove: BigInt::from(1000000000000000000u64), + verified_client_to_remove: lotus_json.verified_client_to_remove.into(), + data_cap_amount_to_remove: lotus_json.data_cap_amount_to_remove, verifier_request_1: fil_actor_verifreg_state::[]::RemoveDataCapRequest { - verifier: Address::new_id(1235).into(), - signature: fvm_shared4::crypto::signature::Signature { - sig_type: fvm_shared4::crypto::signature::SignatureType::Secp256k1, - bytes: b"test".to_vec(), - }, + verifier: lotus_json.verifier_request_1.verifier.into(), + signature: lotus_json.verifier_request_1.signature, }, verifier_request_2: fil_actor_verifreg_state::[]::RemoveDataCapRequest { - verifier: Address::new_id(1236).into(), - signature: fvm_shared4::crypto::signature::Signature { - sig_type: fvm_shared4::crypto::signature::SignatureType::Secp256k1, - bytes: b"test".to_vec(), - }, + verifier: lotus_json.verifier_request_2.verifier.into(), + signature: lotus_json.verifier_request_2.signature, }, - }, - )] - } - - fn into_lotus_json(self) -> Self::LotusJson { - RemoveDataCapParamsV4LotusJson { - verified_client_to_remove: self.verified_client_to_remove.into(), - data_cap_amount_to_remove: self.data_cap_amount_to_remove, - verifier_request_1: RemoveDataCapRequestV4LotusJson { - verifier: self.verifier_request_1.verifier.into(), - signature: self.verifier_request_1.signature, - }, - verifier_request_2: RemoveDataCapRequestV4LotusJson { - verifier: self.verifier_request_2.verifier.into(), - signature: self.verifier_request_2.signature, - }, - } - } - - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - verified_client_to_remove: lotus_json.verified_client_to_remove.into(), - data_cap_amount_to_remove: lotus_json.data_cap_amount_to_remove, - verifier_request_1: fil_actor_verifreg_state::[]::RemoveDataCapRequest { - verifier: lotus_json.verifier_request_1.verifier.into(), - signature: lotus_json.verifier_request_1.signature, - }, - verifier_request_2: fil_actor_verifreg_state::[]::RemoveDataCapRequest { - verifier: lotus_json.verifier_request_2.verifier.into(), - signature: lotus_json.verifier_request_2.signature, - }, + } } } } @@ -852,95 +938,104 @@ macro_rules! impl_claim_allocations_params_v12_plus { ($type_suffix:path: $($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_verifreg_state::[]::ClaimAllocationsParams { - type LotusJson = ClaimAllocationsParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![( - json!({ - "Sectors": [ - { - "Sector": 1, - "Expiry": 12345, - "Claims": [ - { - "Client": 1001, - "AllocationId": 1, - "Data": {"/": "bafk2bzacedbdmwqy4jrh4tgm7l77vz5fxb27jgmb2xkuprzzudbe2xj5u2nzm"}, - "Size": 2048, - } - ], - } - ], - "AllOrNothing": true, - }), - Self { - sectors: vec![fil_actor_verifreg_state::[]::SectorAllocationClaims { - sector: 1, - expiry: 12345, - claims: vec![fil_actor_verifreg_state::[]::AllocationClaim { - client: 1001, - allocation_id: 1, - data: Cid::try_from( - "bafk2bzacedbdmwqy4jrh4tgm7l77vz5fxb27jgmb2xkuprzzudbe2xj5u2nzm", - ) - .unwrap(), - size: $type_suffix::piece::PaddedPieceSize(2048), - }], - }], - all_or_nothing: true, - }, - )] + mod [] { + use super::*; + type T = fil_actor_verifreg_state::[]::ClaimAllocationsParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - ClaimAllocationsParamsLotusJson { - sectors: self - .sectors - .into_iter() - .map(|sector| SectorAllocationClaimsLotusJson { - sector: sector.sector, - expiry: sector.expiry, - claims: sector - .claims - .into_iter() - .map(|claim| AllocationClaimLotusJson { - client: claim.client, - allocation_id: claim.allocation_id, - data: claim.data, - size: claim.size.0, - }) - .collect(), - }) - .collect(), - all_or_nothing: self.all_or_nothing, + impl HasLotusJson for T { + type LotusJson = ClaimAllocationsParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![( + json!({ + "Sectors": [ + { + "Sector": 1, + "SectorExpiry": 12345, + "Claims": [ + { + "Client": 1001, + "AllocationId": 1, + "Data": {"/": "bafk2bzacedbdmwqy4jrh4tgm7l77vz5fxb27jgmb2xkuprzzudbe2xj5u2nzm"}, + "Size": 2048, + } + ], + } + ], + "AllOrNothing": true, + }), + Self { + sectors: vec![fil_actor_verifreg_state::[]::SectorAllocationClaims { + sector: 1, + expiry: 12345, + claims: vec![fil_actor_verifreg_state::[]::AllocationClaim { + client: 1001, + allocation_id: 1, + data: Cid::try_from( + "bafk2bzacedbdmwqy4jrh4tgm7l77vz5fxb27jgmb2xkuprzzudbe2xj5u2nzm", + ) + .unwrap(), + size: $type_suffix::piece::PaddedPieceSize(2048), + }], + }], + all_or_nothing: true, + }, + )] } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - sectors: lotus_json - .sectors - .into_iter() - .map( - |sector| fil_actor_verifreg_state::[]::SectorAllocationClaims { + fn into_lotus_json(self) -> Self::LotusJson { + ClaimAllocationsParamsLotusJson { + sectors: self + .sectors + .into_iter() + .map(|sector| SectorAllocationClaimsLotusJson { sector: sector.sector, expiry: sector.expiry, claims: sector .claims .into_iter() - .map(|claim| fil_actor_verifreg_state::[]::AllocationClaim { + .map(|claim| AllocationClaimLotusJson { client: claim.client, allocation_id: claim.allocation_id, data: claim.data, - size: $type_suffix::piece::PaddedPieceSize(claim.size), + size: claim.size.0, }) .collect(), - }, - ) - .collect(), - all_or_nothing: lotus_json.all_or_nothing, + }) + .collect(), + all_or_nothing: self.all_or_nothing, + } + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + sectors: lotus_json + .sectors + .into_iter() + .map( + |sector| fil_actor_verifreg_state::[]::SectorAllocationClaims { + sector: sector.sector, + expiry: sector.expiry, + claims: sector + .claims + .into_iter() + .map(|claim| fil_actor_verifreg_state::[]::AllocationClaim { + client: claim.client, + allocation_id: claim.allocation_id, + data: claim.data, + size: $type_suffix::piece::PaddedPieceSize(claim.size), + }) + .collect(), + }, + ) + .collect(), + all_or_nothing: lotus_json.all_or_nothing, + } } } } @@ -954,75 +1049,84 @@ macro_rules! impl_claim_allocations_params_v11 { ($type_suffix:path: $($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_verifreg_state::[]::ClaimAllocationsParams { - type LotusJson = ClaimAllocationsParamsV11LotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![( - json!({ - "Sectors": [ - { - "Client": 1001, - "AllocationId": 1, - "Data": {"/": "bafk2bzacedbdmwqy4jrh4tgm7l77vz5fxb27jgmb2xkuprzzudbe2xj5u2nzm"}, - "Size": 2048, - "Sector": 1, - "SectorExpiry": 12345, - } - ], - "AllOrNothing": true, - }), - Self { - sectors: vec![fil_actor_verifreg_state::[]::SectorAllocationClaim { - client: 1001, - allocation_id: 1, - data: Cid::try_from( - "bafk2bzacedbdmwqy4jrh4tgm7l77vz5fxb27jgmb2xkuprzzudbe2xj5u2nzm", - ) - .unwrap(), - size: $type_suffix::piece::PaddedPieceSize(2048), - sector: 1, - sector_expiry: 12345, - }], - all_or_nothing: true, - }, - )] + mod [] { + use super::*; + type T = fil_actor_verifreg_state::[]::ClaimAllocationsParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - ClaimAllocationsParamsV11LotusJson { - sectors: self - .sectors - .into_iter() - .map(|sector| SectorAllocationClaimV11LotusJson { - client: sector.client, - allocation_id: sector.allocation_id, - data: sector.data, - size: sector.size.0, - sector: sector.sector, - sector_expiry: sector.sector_expiry, - }) - .collect(), - all_or_nothing: self.all_or_nothing, + impl HasLotusJson for T { + type LotusJson = ClaimAllocationsParamsV11LotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![( + json!({ + "Sectors": [ + { + "Client": 1001, + "AllocationId": 1, + "Data": {"/": "bafk2bzacedbdmwqy4jrh4tgm7l77vz5fxb27jgmb2xkuprzzudbe2xj5u2nzm"}, + "Size": 2048, + "Sector": 1, + "SectorExpiry": 12345, + } + ], + "AllOrNothing": true, + }), + Self { + sectors: vec![fil_actor_verifreg_state::[]::SectorAllocationClaim { + client: 1001, + allocation_id: 1, + data: Cid::try_from( + "bafk2bzacedbdmwqy4jrh4tgm7l77vz5fxb27jgmb2xkuprzzudbe2xj5u2nzm", + ) + .unwrap(), + size: $type_suffix::piece::PaddedPieceSize(2048), + sector: 1, + sector_expiry: 12345, + }], + all_or_nothing: true, + }, + )] + } + + fn into_lotus_json(self) -> Self::LotusJson { + ClaimAllocationsParamsV11LotusJson { + sectors: self + .sectors + .into_iter() + .map(|sector| SectorAllocationClaimV11LotusJson { + client: sector.client, + allocation_id: sector.allocation_id, + data: sector.data, + size: sector.size.0, + sector: sector.sector, + sector_expiry: sector.sector_expiry, + }) + .collect(), + all_or_nothing: self.all_or_nothing, + } } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - sectors: lotus_json - .sectors - .into_iter() - .map(|sector| fil_actor_verifreg_state::[]::SectorAllocationClaim { - client: sector.client, - allocation_id: sector.allocation_id, - data: sector.data, - size: $type_suffix::piece::PaddedPieceSize(sector.size), - sector: sector.sector, - sector_expiry: sector.sector_expiry, - }) - .collect(), - all_or_nothing: lotus_json.all_or_nothing, + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + sectors: lotus_json + .sectors + .into_iter() + .map(|sector| fil_actor_verifreg_state::[]::SectorAllocationClaim { + client: sector.client, + allocation_id: sector.allocation_id, + data: sector.data, + size: $type_suffix::piece::PaddedPieceSize(sector.size), + sector: sector.sector, + sector_expiry: sector.sector_expiry, + }) + .collect(), + all_or_nothing: lotus_json.all_or_nothing, + } } } } @@ -1036,101 +1140,110 @@ macro_rules! impl_allocation_requests { ($type_suffix:path: $($version:literal),+) => { $( paste! { - impl HasLotusJson for fil_actor_verifreg_state::[]::AllocationRequests { - type LotusJson = AllocationRequestsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![( - json!({ - "Allocations": [ - { - "Provider": 1001, - "Data": {"/": "bafk2bzacedbdmwqy4jrh4tgm7l77vz5fxb27jgmb2xkuprzzudbe2xj5u2nzm"}, - "Size": 2048, - "TermMin": 1000, - "TermMax": 2000, - "Expiration": 12345, - } - ], - "Extensions": [ - { - "Provider": 1002, - "Claim": 1, - "TermMax": 3000, - } - ], - }), - Self { - allocations: vec![fil_actor_verifreg_state::[]::AllocationRequest { - provider: 1001, - data: Cid::try_from( - "bafk2bzacedbdmwqy4jrh4tgm7l77vz5fxb27jgmb2xkuprzzudbe2xj5u2nzm", - ) - .unwrap(), - size: $type_suffix::piece::PaddedPieceSize(2048), - term_min: 1000, - term_max: 2000, - expiration: 12345, - }], - extensions: vec![fil_actor_verifreg_state::[]::ClaimExtensionRequest { - provider: 1002, - claim: 1, - term_max: 3000, - }], - }, - )] + mod [] { + use super::*; + type T = fil_actor_verifreg_state::[]::AllocationRequests; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - AllocationRequestsLotusJson { - allocations: self - .allocations - .into_iter() - .map(|alloc| AllocationRequestLotusJson { - provider: alloc.provider, - data: alloc.data, - size: PaddedPieceSize(alloc.size.0), - term_min: alloc.term_min, - term_max: alloc.term_max, - expiration: alloc.expiration, - }) - .collect(), - extensions: self - .extensions - .into_iter() - .map(|ext| ClaimExtensionRequestLotusJson { - provider: ext.provider, - claim: ext.claim, - term_max: ext.term_max, - }) - .collect(), + impl HasLotusJson for T { + type LotusJson = AllocationRequestsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![( + json!({ + "Allocations": [ + { + "Provider": 1001, + "Data": {"/": "bafk2bzacedbdmwqy4jrh4tgm7l77vz5fxb27jgmb2xkuprzzudbe2xj5u2nzm"}, + "Size": 2048, + "TermMin": 1000, + "TermMax": 2000, + "Expiration": 12345, + } + ], + "Extensions": [ + { + "Provider": 1002, + "Claim": 1, + "TermMax": 3000, + } + ], + }), + Self { + allocations: vec![fil_actor_verifreg_state::[]::AllocationRequest { + provider: 1001, + data: Cid::try_from( + "bafk2bzacedbdmwqy4jrh4tgm7l77vz5fxb27jgmb2xkuprzzudbe2xj5u2nzm", + ) + .unwrap(), + size: $type_suffix::piece::PaddedPieceSize(2048), + term_min: 1000, + term_max: 2000, + expiration: 12345, + }], + extensions: vec![fil_actor_verifreg_state::[]::ClaimExtensionRequest { + provider: 1002, + claim: 1, + term_max: 3000, + }], + }, + )] + } + + fn into_lotus_json(self) -> Self::LotusJson { + AllocationRequestsLotusJson { + allocations: self + .allocations + .into_iter() + .map(|alloc| AllocationRequestLotusJson { + provider: alloc.provider, + data: alloc.data, + size: PaddedPieceSize(alloc.size.0), + term_min: alloc.term_min, + term_max: alloc.term_max, + expiration: alloc.expiration, + }) + .collect(), + extensions: self + .extensions + .into_iter() + .map(|ext| ClaimExtensionRequestLotusJson { + provider: ext.provider, + claim: ext.claim, + term_max: ext.term_max, + }) + .collect(), + } } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - allocations: lotus_json - .allocations - .into_iter() - .map(|alloc| fil_actor_verifreg_state::[]::AllocationRequest { - provider: alloc.provider, - data: alloc.data, - size: $type_suffix::piece::PaddedPieceSize(alloc.size.0), - term_min: alloc.term_min, - term_max: alloc.term_max, - expiration: alloc.expiration, - }) - .collect(), - extensions: lotus_json - .extensions - .into_iter() - .map(|ext| fil_actor_verifreg_state::[]::ClaimExtensionRequest { - provider: ext.provider, - claim: ext.claim, - term_max: ext.term_max, - }) - .collect(), + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + allocations: lotus_json + .allocations + .into_iter() + .map(|alloc| fil_actor_verifreg_state::[]::AllocationRequest { + provider: alloc.provider, + data: alloc.data, + size: $type_suffix::piece::PaddedPieceSize(alloc.size.0), + term_min: alloc.term_min, + term_max: alloc.term_max, + expiration: alloc.expiration, + }) + .collect(), + extensions: lotus_json + .extensions + .into_iter() + .map(|ext| fil_actor_verifreg_state::[]::ClaimExtensionRequest { + provider: ext.provider, + claim: ext.claim, + term_max: ext.term_max, + }) + .collect(), + } } } } @@ -1140,98 +1253,125 @@ macro_rules! impl_allocation_requests { } // v8 has unique BytesParams for UseBytes/RestoreBytes methods -impl HasLotusJson for fil_actor_verifreg_state::v8::BytesParams { - type LotusJson = BytesParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![( - json!({ - "Address": "f01234", - "DealSize": "1048576", // 1MB - }), - Self { - address: Address::new_id(1234).into(), - deal_size: BigInt::from(1048576u64), - }, - )] +mod impl_verifreg_bytes_params_v8 { + use super::*; + type T = fil_actor_verifreg_state::v8::BytesParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - BytesParamsLotusJson { - address: self.address.into(), - deal_size: self.deal_size, + impl HasLotusJson for T { + type LotusJson = BytesParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![( + json!({ + "Address": "f01234", + "DealSize": "1048576", // 1MB + }), + Self { + address: Address::new_id(1234).into(), + deal_size: BigInt::from(1048576u64), + }, + )] } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - address: lotus_json.address.into(), - deal_size: lotus_json.deal_size, + fn into_lotus_json(self) -> Self::LotusJson { + BytesParamsLotusJson { + address: self.address.into(), + deal_size: self.deal_size, + } + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + address: lotus_json.address.into(), + deal_size: lotus_json.deal_size, + } } } } -impl HasLotusJson for fil_actor_verifreg_state::v8::VerifierParams { - type LotusJson = VerifierParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![( - json!({ - "Address": "f01234", - "Allowance": "1000000000000000000", - }), - Self { - address: Address::new_id(1234).into(), - allowance: BigInt::from(1000000000000000000u64), - }, - )] +mod impl_verifreg_verifier_params_v8 { + use super::*; + type T = fil_actor_verifreg_state::v8::VerifierParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - VerifierParamsLotusJson { - address: self.address.into(), - allowance: self.allowance, + impl HasLotusJson for T { + type LotusJson = VerifierParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![( + json!({ + "Address": "f01234", + "Allowance": "1000000000000000000", + }), + Self { + address: Address::new_id(1234).into(), + allowance: BigInt::from(1000000000000000000u64), + }, + )] } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - address: lotus_json.address.into(), - allowance: lotus_json.allowance, + fn into_lotus_json(self) -> Self::LotusJson { + VerifierParamsLotusJson { + address: self.address.into(), + allowance: self.allowance, + } + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + address: lotus_json.address.into(), + allowance: lotus_json.allowance, + } } } } -impl HasLotusJson for fil_actor_verifreg_state::v9::AddVerifierClientParams { - type LotusJson = VerifierParamsLotusJson; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![( - json!({ - "Address": "f01234", - "Allowance": "1000000000000000000", - }), - Self { - address: Address::new_id(1234).into(), - allowance: BigInt::from(1000000000000000000u64), - }, - )] +mod impl_verifreg_add_verifier_client_params_v9 { + use super::*; + type T = fil_actor_verifreg_state::v9::AddVerifierClientParams; + #[test] + fn snapshots() { + crate::lotus_json::assert_all_snapshots::(); } - fn into_lotus_json(self) -> Self::LotusJson { - VerifierParamsLotusJson { - address: self.address.into(), - allowance: self.allowance, + impl HasLotusJson for T { + type LotusJson = VerifierParamsLotusJson; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![( + json!({ + "Address": "f01234", + "Allowance": "1000000000000000000", + }), + Self { + address: Address::new_id(1234).into(), + allowance: BigInt::from(1000000000000000000u64), + }, + )] } - } - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self { - address: lotus_json.address.into(), - allowance: lotus_json.allowance, + fn into_lotus_json(self) -> Self::LotusJson { + VerifierParamsLotusJson { + address: self.address.into(), + allowance: self.allowance, + } + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self { + address: lotus_json.address.into(), + allowance: lotus_json.allowance, + } } } }