Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Leshiy committed Aug 7, 2023
1 parent 190d1fc commit 5f44d65
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
34 changes: 34 additions & 0 deletions src/catalyst-toolbox/snapshot-lib/src/registration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,40 @@ mod tests {
}
}

#[cfg(test)]
#[test]
fn reward_address_serde_test() {
assert_eq!(
serde_json::to_value(&RewardAddress(
"0x01cd3be59b212a45b99f2d26bd179c7119e2851c3b7ada415eff504683c7a5c447ebee137a684b65750e8ab5227ffb3199017bdaf069464c11".to_string()
)).unwrap(),
serde_json::json!("addr1q8xnhevmyy4ytwvl95nt69uuwyv79pgu8dad5s27lagydq785hzy06lwzdaxsjm9w58g4dfz0lanrxgp00d0q62xfsgsh7dfml")
);

assert_eq!(
serde_json::to_value(&RewardAddress(
"0xe1b8d7b8e56a3ed89ee21bc062d284d537f843b50b68b905618b130297".to_string()
))
.unwrap(),
serde_json::json!("stake1uxud0w89dgld38hzr0qx955y65mlssa4pd5tjptp3vfs99cj39wag")
);

assert_eq!(
serde_json::to_value(&RewardAddress(
"0x00cd3be59b212a45b99f2d26bd179c7119e2851c3b7ada415eff504683c7a5c447ebee137a684b65750e8ab5227ffb3199017bdaf069464c11".to_string()
)).unwrap(),
serde_json::json!("addr_test1qrxnhevmyy4ytwvl95nt69uuwyv79pgu8dad5s27lagydq785hzy06lwzdaxsjm9w58g4dfz0lanrxgp00d0q62xfsgs5gsfhq")
);

assert_eq!(
serde_json::to_value(&RewardAddress(
"0xe0b8d7b8e56a3ed89ee21bc062d284d537f843b50b68b905618b130297".to_string()
))
.unwrap(),
serde_json::json!("stake_test1uzud0w89dgld38hzr0qx955y65mlssa4pd5tjptp3vfs99c4m0ve4")
);
}

#[cfg(test)]
#[test]
fn parse_example() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,9 @@ pub fn voters_with_at_least_one_vote() {
assert_eq!(
records
.iter()
.find(|(x, _y)| **x
== RewardAddress(alice_wallet.reward_address().to_address().to_hex()))
.find(
|(x, _y)| **x == RewardAddress(alice_wallet.reward_address().to_address().to_hex())
)
.unwrap()
.1,
&50u32.into()
Expand All @@ -168,8 +169,7 @@ pub fn voters_with_at_least_one_vote() {
assert_eq!(
records
.iter()
.find(|(x, _y)| **x
== RewardAddress(bob_wallet.reward_address().to_address().to_hex()))
.find(|(x, _y)| **x == RewardAddress(bob_wallet.reward_address().to_address().to_hex()))
.unwrap()
.1,
&50u32.into()
Expand Down

0 comments on commit 5f44d65

Please sign in to comment.