Skip to content

Commit

Permalink
cometbft: update SignVoteRequest domain type
Browse files Browse the repository at this point in the history
The sign_extension field was renamed to skip_extension_signing
with flipped value semantics.
  • Loading branch information
mzabaluev committed Mar 6, 2024
1 parent e62c99a commit 70455f2
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions cometbft/src/vote/sign_vote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ pub struct SignVoteRequest {
pub vote: Vote,
/// Chain ID
pub chain_id: chain::Id,
pub sign_extension: bool,
/// Whether to skip signing the extension bytes.
pub skip_extension_signing: bool,
}

impl SignVoteRequest {
Expand Down Expand Up @@ -60,11 +61,12 @@ mod v1 {

let chain_id = value.chain_id.try_into()?;

let sign_extension = value.sign_extension;
let skip_extension_signing = value.skip_extension_signing;

Ok(SignVoteRequest {
vote,
chain_id,
sign_extension,
skip_extension_signing,
})
}
}
Expand All @@ -74,7 +76,7 @@ mod v1 {
RawSignVoteRequest {
vote: Some(value.vote.into()),
chain_id: value.chain_id.as_str().to_owned(),
sign_extension: value.sign_extension,
skip_extension_signing: value.skip_extension_signing,
}
}
}
Expand Down Expand Up @@ -123,7 +125,7 @@ mod v1beta1 {
Ok(SignVoteRequest {
vote,
chain_id,
sign_extension: true,
skip_extension_signing: false,
})
}
}
Expand Down Expand Up @@ -220,7 +222,7 @@ mod tests {
let request = SignVoteRequest {
vote,
chain_id: ChainId::from_str("test_chain_id").unwrap(),
sign_extension: false,
skip_extension_signing: false,
};

// Option 1 using bytes:
Expand Down Expand Up @@ -306,7 +308,7 @@ mod tests {
let request = SignVoteRequest {
vote,
chain_id: ChainId::from_str("test_chain_id").unwrap(),
sign_extension: false,
skip_extension_signing: false,
};

let got = request.into_signable_vec();
Expand Down Expand Up @@ -492,7 +494,7 @@ mod tests {
let want = SignVoteRequest {
vote,
chain_id: ChainId::from_str("test_chain_id").unwrap(),
sign_extension: false,
skip_extension_signing: false,
};
let got =
<SignVoteRequest as Protobuf<RawSignVoteRequest>>::decode_vec(&encoded).unwrap();
Expand Down Expand Up @@ -548,7 +550,7 @@ mod tests {
let svr = SignVoteRequest {
vote,
chain_id: ChainId::from_str("test_chain_id").unwrap(),
sign_extension: false,
skip_extension_signing: false,
};
let mut got = vec![];
let _have = Protobuf::<RawSignVoteRequest>::encode(svr.clone(), &mut got);
Expand Down

0 comments on commit 70455f2

Please sign in to comment.