Skip to content

Commit 2af6403

Browse files
committed
[test] primitives - ValidatorId - check serialization
1 parent 4fb5934 commit 2af6403

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

primitives/src/validator.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,19 @@ pub mod postgres {
221221
}
222222
}
223223
}
224+
225+
#[cfg(test)]
226+
mod test {
227+
use super::*;
228+
229+
#[test]
230+
fn validator_id_is_checksummed_when_serialized() {
231+
let validator_id_checksum_str = "0xce07CbB7e054514D590a0262C93070D838bFBA2e";
232+
233+
let validator_id =
234+
ValidatorId::try_from(validator_id_checksum_str).expect("Valid string was provided");
235+
let actual_json = serde_json::to_string(&validator_id).expect("Should serialize");
236+
let expected_json = format!(r#""{}""#, validator_id_checksum_str);
237+
assert_eq!(expected_json, actual_json);
238+
}
239+
}

0 commit comments

Comments
 (0)