Skip to content

Commit

Permalink
test: add atom unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoguang1010 committed Dec 13, 2023
1 parent 3e3db9a commit 52c1283
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion token-core/tcx-atom/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ impl ToString for AtomAddress {

#[cfg(test)]
mod tests {

use crate::address::AtomAddress;
use std::str::FromStr;
use tcx_keystore::Address;

use tcx_common::FromHex;
Expand Down Expand Up @@ -121,4 +121,22 @@ mod tests {
assert!(AtomAddress::is_valid(addr, &get_test_coin()));
}
}

#[test]
fn test_address_is_invalid() {
let valid_addresses = vec![
"cosmos1r5v5srda7xfth3hn2s26txvrcrntldjumt8mhll",
"cosmos1pt9904aqg739q6p9kgc2v0puqvj6atqxw0dax",
];
for addr in valid_addresses {
assert!(!AtomAddress::is_valid(addr, &get_test_coin()));
}
}

#[test]
fn test_address_from_str() {
let address = "cosmos1r5v5srda7xfth3hn2s26txvrcrntldjumt8mhl";
let atom_address = AtomAddress::from_str(address).unwrap();
assert_eq!(atom_address.to_string(), address);
}
}

0 comments on commit 52c1283

Please sign in to comment.