Skip to content

Commit 387e51c

Browse files
authored
feat: verifreg: serialize RemoveDataCapProposalID as tuple (#574)
1 parent 95f952a commit 387e51c

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

actors/verifreg/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -730,13 +730,13 @@ where
730730
)
731731
})?;
732732

733-
let curr_id = if let Some(RemoveDataCapProposalID(id)) = maybe_id {
734-
RemoveDataCapProposalID(*id)
733+
let curr_id = if let Some(RemoveDataCapProposalID { id }) = maybe_id {
734+
RemoveDataCapProposalID { id: *id }
735735
} else {
736-
RemoveDataCapProposalID(0)
736+
RemoveDataCapProposalID { id: 0 }
737737
};
738738

739-
let next_id = RemoveDataCapProposalID(curr_id.0 + 1);
739+
let next_id = RemoveDataCapProposalID { id: curr_id.id + 1 };
740740
proposal_ids.set(BytesKey::from(key.to_bytes()), next_id).map_err(|e| {
741741
actor_error!(
742742
illegal_state,

actors/verifreg/src/types.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use fvm_shared::address::Address;
77
use fvm_shared::bigint::bigint_ser;
88
use fvm_shared::crypto::signature::Signature;
99
use fvm_shared::sector::StoragePower;
10-
use serde::{Deserialize, Serialize};
1110

1211
#[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)]
1312
pub struct VerifierParams {
@@ -66,9 +65,10 @@ pub struct RemoveDataCapReturn {
6665
pub data_cap_removed: DataCap,
6766
}
6867

69-
#[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Eq)]
70-
#[serde(transparent)]
71-
pub struct RemoveDataCapProposalID(pub u64);
68+
#[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)]
69+
pub struct RemoveDataCapProposalID {
70+
pub id: u64,
71+
}
7272

7373
#[derive(Debug, Serialize_tuple, Deserialize_tuple)]
7474
pub struct RemoveDataCapProposal {

test_vm/tests/verifreg_remove_datacap_test.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ fn remove_datacap_simple_successful_path() {
104104
let mut verifier1_proposal = RemoveDataCapProposal {
105105
verified_client: verified_client_id_addr,
106106
data_cap_amount: allowance_to_remove.clone(),
107-
removal_proposal_id: RemoveDataCapProposalID(0),
107+
removal_proposal_id: RemoveDataCapProposalID { id: 0 },
108108
};
109109

110110
let mut verifier1_proposal_ser = to_vec(&verifier1_proposal).unwrap();
@@ -114,7 +114,7 @@ fn remove_datacap_simple_successful_path() {
114114
let mut verifier2_proposal = RemoveDataCapProposal {
115115
verified_client: verified_client_id_addr,
116116
data_cap_amount: allowance_to_remove.clone(),
117-
removal_proposal_id: RemoveDataCapProposalID(0),
117+
removal_proposal_id: RemoveDataCapProposalID { id: 0 },
118118
};
119119

120120
let mut verifier2_proposal_ser = to_vec(&verifier2_proposal).unwrap();
@@ -185,14 +185,14 @@ fn remove_datacap_simple_successful_path() {
185185
.unwrap()
186186
.unwrap();
187187

188-
assert_eq!(1u64, verifier1_proposal_id.0);
188+
assert_eq!(1u64, verifier1_proposal_id.id);
189189

190190
let verifier2_proposal_id: &RemoveDataCapProposalID = proposal_ids
191191
.get(&AddrPairKey::new(verifier2_id_addr, verified_client_id_addr).to_bytes())
192192
.unwrap()
193193
.unwrap();
194194

195-
assert_eq!(1u64, verifier2_proposal_id.0);
195+
assert_eq!(1u64, verifier2_proposal_id.id);
196196

197197
// remove the second half of the client's allowance, this causes the client to be deleted
198198

@@ -276,13 +276,13 @@ fn remove_datacap_simple_successful_path() {
276276
.unwrap()
277277
.unwrap();
278278

279-
assert_eq!(2u64, verifier1_proposal_id.0);
279+
assert_eq!(2u64, verifier1_proposal_id.id);
280280

281281
let verifier2_proposal_id: &RemoveDataCapProposalID = proposal_ids
282282
.get(&AddrPairKey::new(verifier2_id_addr, verified_client_id_addr).to_bytes())
283283
.unwrap()
284284
.unwrap();
285285

286-
assert_eq!(2u64, verifier2_proposal_id.0);
286+
assert_eq!(2u64, verifier2_proposal_id.id);
287287
v.assert_state_invariants();
288288
}

0 commit comments

Comments
 (0)