Skip to content

Commit b76a872

Browse files
committed
feat: add test with fixture of older response
1 parent b57f792 commit b76a872

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

libsigner/src/v0/messages.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,4 +1965,20 @@ mod test {
19651965
assert_eq!(block_accepted.signature, block_accepted_old.signature);
19661966
assert_eq!(block_accepted.metadata, block_accepted_old.metadata);
19671967
}
1968+
1969+
#[test]
1970+
fn test_deserialize_old_block_response() {
1971+
// Fixture of an older version of a block response that has a tenure_extend_timestamp
1972+
// but _not_ a reject_reason.
1973+
let hex_str = "01006dc371d2313be71f93ac759f3302e5a0e4ff77dd0e73f13bb491936b5489d5390032208fc53bd0984c84abaac44ecd777e473e3e325066217e9d7314baa5cdfe1847363e1036f364b4bf7982f4d103079b17c19bf8a19904e822c2d62a5021c19700000036737461636b732d7369676e657220302e302e3120283a2c2072656c65617365206275696c642c206c696e7578205b7838365f36345d290200000008000000006751c76e";
1974+
let bytes = hex_bytes(hex_str).unwrap();
1975+
let block_response = read_next::<SignerMessage, _>(&mut &bytes[..]).unwrap();
1976+
let SignerMessage::BlockResponse(BlockResponse::Accepted(accepted)) = block_response else {
1977+
panic!("Expected BlockResponse::Accepted");
1978+
};
1979+
assert_eq!(
1980+
accepted.response_data.reject_reason,
1981+
RejectReason::NotRejected
1982+
);
1983+
}
19681984
}

0 commit comments

Comments
 (0)