Skip to content

Commit 9937c41

Browse files
committed
regressions check for serialization
1 parent b071ab9 commit 9937c41

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

libsigner/src/v0/messages.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,11 +2049,11 @@ mod test {
20492049
#[test]
20502050
fn test_deserialize_state_machine_update() {
20512051
let signer_message = StateMachineUpdate {
2052-
burn_block: ConsensusHash::from_bytes(&[0x55; 20]).unwrap(),
2052+
burn_block: ConsensusHash([0x55; 20]),
20532053
burn_block_height: 100,
2054-
current_miner_pkh: Hash160::from_data(&[0xab; 32]),
2055-
parent_tenure_id: ConsensusHash::from_bytes(&[0x22; 20]).unwrap(),
2056-
parent_tenure_last_block: StacksBlockId([0x33u8; 32]),
2054+
current_miner_pkh: Hash160([0xab; 20]),
2055+
parent_tenure_id: ConsensusHash([0x22; 20]),
2056+
parent_tenure_last_block: StacksBlockId([0x33; 32]),
20572057
parent_tenure_last_block_height: 1,
20582058
active_signer_protocol_version: 2,
20592059
local_supported_signer_protocol_version: 3,
@@ -2062,6 +2062,20 @@ mod test {
20622062
let mut bytes = vec![];
20632063
signer_message.consensus_serialize(&mut bytes).unwrap();
20642064

2065+
// check for raw content for avoiding regressions when structure changes
2066+
let raw_signer_message: Vec<&[u8]> = vec![
2067+
/* burn_block*/ &[0x55; 20],
2068+
/* burn_block_height*/ &[0, 0, 0, 0, 0, 0, 0, 100],
2069+
/* current_miner_pkh */ &[0xab; 20],
2070+
/* parent_tenure_id*/ &[0x22; 20],
2071+
/* parent_tenure_last_block */ &[0x33; 32],
2072+
/* parent_tenure_last_block_height*/ &[0, 0, 0, 0, 0, 0, 0, 1],
2073+
/* active_signer_protocol_version*/ &[0, 0, 0, 0, 0, 0, 0, 2],
2074+
/* local_supported_signer_protocol_version*/ &[0, 0, 0, 0, 0, 0, 0, 3],
2075+
];
2076+
2077+
assert_eq!(bytes, raw_signer_message.concat());
2078+
20652079
let signer_message_deserialized =
20662080
StateMachineUpdate::consensus_deserialize(&mut &bytes[..]).unwrap();
20672081

0 commit comments

Comments
 (0)