Skip to content

Commit

Permalink
Add test case instantiate2_address_impl_matches_wasmd_for_len_24
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Feb 6, 2025
1 parent e093f62 commit 7c14883
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/std/src/addresses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,28 @@ mod tests {
}
}

#[test]
fn instantiate2_address_impl_matches_wasmd_for_len_24() {
// Manual test data generated with wasmd and bech32 CLI as follows
// 1. Install https://github.com/cmoog/bech32
// 2. Check out wasmd main and change to `var ContractAddrLen = 24`
// 3. Run `make build`
// 4. Run `./build/wasmd q wasm build-address 1122112211221122112211221122112211221122112211221122112211221122 wasm1xvenxvenxvenxvenxvenxvenxvenxvenkz5vxp aabbaabb | bech32 -d | xxd -p`

let checksum =
HexBinary::from_hex("1122112211221122112211221122112211221122112211221122112211221122")
.unwrap();
let creator = CanonicalAddr::from(hex!("3333333333333333333333333333333333333333"));
let salt = hex!("aabbaabb");

let expected =
CanonicalAddr::from(hex!["da1aaec9d0ddc75b873079eb1b4f7ddd73a0e3170225fec4"]);
assert_eq!(
instantiate2_address_impl(&checksum, &creator, &salt, b"", 24).unwrap(),
expected
);
}

#[test]
fn instantiate2_address_impl_works_for_cosmjs_test_vectors() {
// Test data from https://github.com/cosmos/cosmjs/pull/1253
Expand Down

0 comments on commit 7c14883

Please sign in to comment.