Skip to content

Commit

Permalink
Fix test lengths (comments/code)
Browse files Browse the repository at this point in the history
  • Loading branch information
eloylp committed Jul 9, 2024
1 parent e43bbb3 commit 02fb8f9
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/axelar-wasm-std/src/msg_id/base_58_solana_event_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ mod tests {

use super::*;

#[test]
fn asda() {
let signature = "1111KKdpXH2QMB5Jm11YR48cLqUJb9Cwq2YL3tveVTPeFkZaLP8cdcH5UphVPJ7kYwCUCRLnywd3xkUhb4ZYWtf5";

let a = bs58::decode(signature).into_vec().unwrap();

println!("{}", a.len())
}

fn random_bytes() -> [u8; 64] {
let mut bytes = [0; 64];
for b in &mut bytes {
Expand Down Expand Up @@ -169,7 +178,7 @@ mod tests {

#[test]
fn should_not_parse_msg_id_with_correct_length_base58_but_wrong_length_hex() {
// this is 88 chars and valid base58, but will decode to 33 bytes
// this is 88 chars and valid base58, but will decode to 66 bytes
// the leading 1s are encoded as 00 in hex and thus result in too many bytes
let tx_digest = "1111KKdpXH2QMB5Jm11YR48cLqUJb9Cwq2YL3tveVTPeFkZaLP8cdcH5UphVPJ7kYwCUCRLnywd3xkUhb4ZYWtf5";
let event_index = random_event_index();
Expand All @@ -181,8 +190,8 @@ mod tests {

// this is 44 chars and valid base 58, but will encode to 33 bytes
// (z is the largest base58 digit, and so this will overflow 2^256)
let tx_digest = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
assert_eq!(tx_digest.len(), 44);
let tx_digest = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
assert_eq!(tx_digest.len(), 88);
let msg_id = format!("{}-{}", tx_digest, event_index);

assert!(REGEX.captures(&msg_id).is_some());
Expand Down

0 comments on commit 02fb8f9

Please sign in to comment.