Skip to content

Commit 4fb5934

Browse files
committed
primitives - ValidatorId
adapter - ethereum - fix test
1 parent cb656e7 commit 4fb5934

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

adapter/src/ethereum.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ mod test {
424424
let whoami = eth_adapter.whoami();
425425
assert_eq!(
426426
whoami.to_string(),
427-
"0x2bdeafae53940669daa6f519373f686c1f3d3393",
427+
"0x2bDeAFAE53940669DaA6F519373f686c1f3d3393",
428428
"failed to get correct whoami"
429429
);
430430

@@ -542,7 +542,7 @@ mod test {
542542
.expect("Failed to set balance");
543543

544544
let leader_validator_desc = ValidatorDesc {
545-
// keystore.json addresss (same with js)
545+
// keystore.json address (same with js)
546546
id: ValidatorId::try_from("2bdeafae53940669daa6f519373f686c1f3d3393")
547547
.expect("failed to create id"),
548548
url: "http://localhost:8005".to_string(),
@@ -551,7 +551,7 @@ mod test {
551551
};
552552

553553
let follower_validator_desc = ValidatorDesc {
554-
// keystore2.json addresss (same with js)
554+
// keystore2.json address (same with js)
555555
id: ValidatorId::try_from("6704Fbfcd5Ef766B287262fA2281C105d57246a6")
556556
.expect("failed to create id"),
557557
url: "http://localhost:8006".to_string(),
@@ -605,7 +605,7 @@ mod test {
605605
.expect("open channel");
606606

607607
let contract_addr = <[u8; 20]>::from_hex(&format!("{:?}", adex_contract.address())[2..])
608-
.expect("failed to deserialise contract addr");
608+
.expect("failed to deserialize contract addr");
609609

610610
let channel_id = eth_channel.hash(&contract_addr).expect("hash hex");
611611
// set id to proper id

primitives/src/validator.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use chrono::{DateTime, Utc};
2-
use serde::{Deserialize, Serialize};
2+
use serde::{Deserialize, Serialize, Serializer};
33
use serde_hex::{SerHex, StrictPfx};
44
use std::fmt;
55

@@ -14,7 +14,7 @@ pub enum ValidatorError {
1414
InvalidTransition,
1515
}
1616

17-
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
17+
#[derive(Deserialize, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
1818
#[serde(transparent)]
1919
pub struct ValidatorId(#[serde(with = "SerHex::<StrictPfx>")] [u8; 20]);
2020

@@ -36,6 +36,16 @@ impl ValidatorId {
3636

3737
impl ToETHChecksum for ValidatorId {}
3838

39+
impl Serialize for ValidatorId {
40+
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
41+
where
42+
S: Serializer,
43+
{
44+
let checksum = self.to_checksum();
45+
serializer.serialize_str(&checksum)
46+
}
47+
}
48+
3949
impl From<&[u8; 20]> for ValidatorId {
4050
fn from(bytes: &[u8; 20]) -> Self {
4151
Self(*bytes)

0 commit comments

Comments
 (0)