The blockstack_lib::address::c32::c32_address_decode function sometimes successfully decodes its input into a (version, decoded) tuple that is encoded into something different by blockstack_lib::address::c32::c32_address.
It seems like these two functions should be inverses, but this is not the case.
Example
I added the following test case to my copy of src/address/c32.rs:
#[test]
fn test_roundtrip() {
let s1 = "d9AK57BKNW";
let (decoded_version, decoded_bytes) = c32_address_decode(s1).unwrap();
let s2 = c32_address(decoded_version, &decoded_bytes).unwrap();
assert_eq!(s1, s2);
}
Then, running that test case:
$ cargo test test_roundtrip
Compiling blockstack-core v0.0.1 (/home/blarsen/audit-blockstack-core)
Finished test [unoptimized + debuginfo] target(s) in 16.21s
Running target/debug/deps/blockstack_lib-a4f91b892dca4f5f
running 1 test
test address::c32::test::test_roundtrip ... FAILED
failures:
---- address::c32::test::test_roundtrip stdout ----
thread 'address::c32::test::test_roundtrip' panicked at 'assertion failed: `(left == right)`
left: `"d9AK57BKNW"`,
right: `"S9AK57BKNW"`', src/address/c32.rs:404:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
failures:
address::c32::test::test_roundtrip
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 933 filtered out
error: test failed, to rerun pass '--lib'
Description
The
blockstack_lib::address::c32::c32_address_decode
function sometimes successfully decodes its input into a(version, decoded)
tuple that is encoded into something different byblockstack_lib::address::c32::c32_address
.It seems like these two functions should be inverses, but this is not the case.
Example
I added the following test case to my copy of
src/address/c32.rs
:Then, running that test case: