Skip to content

Commit a50760f

Browse files
committed
fix test to use simple hex macro
1 parent 7a69f2e commit a50760f

File tree

3 files changed

+17
-23
lines changed

3 files changed

+17
-23
lines changed

crates/natives/src/move_stdlib/hash.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::{
2020
/***************************************************************************************************
2121
* native fun sha2_256
2222
*
23-
* gas cost: base_cost + unit_cost * max(input_length_in_bytes, legacy_min_input_len)
23+
* gas cost: base_cost + unit_cost * input_length_in_bytes
2424
*
2525
**************************************************************************************************/
2626
#[inline]
@@ -48,7 +48,7 @@ fn native_sha2_256(
4848
/***************************************************************************************************
4949
* native fun sha3_256
5050
*
51-
* gas cost: base_cost + unit_cost * max(input_length_in_bytes, legacy_min_input_len)
51+
* gas cost: base_cost + unit_cost * input_length_in_bytes
5252
*
5353
**************************************************************************************************/
5454
#[inline]
@@ -76,7 +76,7 @@ fn native_sha3_256(
7676
/***************************************************************************************************
7777
* native fun ripemd160
7878
*
79-
* gas cost: base_cost + unit_cost * max(input_length_in_bytes, legacy_min_input_len)
79+
* gas cost: base_cost + unit_cost * input_length_in_bytes
8080
*
8181
**************************************************************************************************/
8282
#[inline]

precompile/modules/initia_stdlib/sources/bech32.move

+7-10
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,32 @@ module initia_std::bech32 {
66

77
#[test_only]
88
use initia_std::string;
9-
#[test_only]
10-
use initia_std::hex;
9+
1110
#[test]
12-
fun test_encode() {
11+
fun test_bech32_encode() {
1312
let prefix = string::utf8(b"init");
14-
let data = hex::decode_string(&string::utf8(b"12eafdba79c3dd7b90e3712ee475423153a722c7"));
13+
let data = x"12eafdba79c3dd7b90e3712ee475423153a722c7";
1514
let got = encode(prefix, data);
1615
let expected = string::utf8(b"init1zt40mwnec0whhy8rwyhwga2zx9f6wgk8p3x098");
1716
assert!(got == expected, 0);
1817

1918
let prefix = string::utf8(b"celestia");
20-
let data = hex::decode_string(&string::utf8(b"12eafdba79c3dd7b90e3712ee475423153a722c7"));
19+
let data = x"12eafdba79c3dd7b90e3712ee475423153a722c7";
2120
let got = encode(prefix, data);
2221
let expected = string::utf8(b"celestia1zt40mwnec0whhy8rwyhwga2zx9f6wgk87dhv5g");
2322
assert!(got == expected, 1);
2423
}
2524

2625
#[test]
27-
fun test_decode() {
26+
fun test_bech32_decode() {
2827
let addr = string::utf8(b"init1zt40mwnec0whhy8rwyhwga2zx9f6wgk8p3x098");
2928
let (prefix, data) = decode(addr);
3029
assert!(prefix == string::utf8(b"init"), 0);
31-
let data = *string::bytes(&hex::encode_to_string(&data));
32-
assert!(data == b"12eafdba79c3dd7b90e3712ee475423153a722c7", 1);
30+
assert!(data == x"12eafdba79c3dd7b90e3712ee475423153a722c7", 1);
3331

3432
let addr = string::utf8(b"celestia1zt40mwnec0whhy8rwyhwga2zx9f6wgk87dhv5g");
3533
let (prefix, data) = decode(addr);
3634
assert!(prefix == string::utf8(b"celestia"), 2);
37-
let data = *string::bytes(&hex::encode_to_string(&data));
38-
assert!(data == b"12eafdba79c3dd7b90e3712ee475423153a722c7", 3);
35+
assert!(data == x"12eafdba79c3dd7b90e3712ee475423153a722c7", 3);
3936
}
4037
}

precompile/modules/minitia_stdlib/sources/bech32.move

+7-10
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,32 @@ module minitia_std::bech32 {
66

77
#[test_only]
88
use minitia_std::string;
9-
#[test_only]
10-
use minitia_std::hex;
9+
1110
#[test]
12-
fun test_encode() {
11+
fun test_bech32_encode() {
1312
let prefix = string::utf8(b"init");
14-
let data = hex::decode_string(&string::utf8(b"12eafdba79c3dd7b90e3712ee475423153a722c7"));
13+
let data = x"12eafdba79c3dd7b90e3712ee475423153a722c7";
1514
let got = encode(prefix, data);
1615
let expected = string::utf8(b"init1zt40mwnec0whhy8rwyhwga2zx9f6wgk8p3x098");
1716
assert!(got == expected, 0);
1817

1918
let prefix = string::utf8(b"celestia");
20-
let data = hex::decode_string(&string::utf8(b"12eafdba79c3dd7b90e3712ee475423153a722c7"));
19+
let data = x"12eafdba79c3dd7b90e3712ee475423153a722c7";
2120
let got = encode(prefix, data);
2221
let expected = string::utf8(b"celestia1zt40mwnec0whhy8rwyhwga2zx9f6wgk87dhv5g");
2322
assert!(got == expected, 1);
2423
}
2524

2625
#[test]
27-
fun test_decode() {
26+
fun test_bech32_decode() {
2827
let addr = string::utf8(b"init1zt40mwnec0whhy8rwyhwga2zx9f6wgk8p3x098");
2928
let (prefix, data) = decode(addr);
3029
assert!(prefix == string::utf8(b"init"), 0);
31-
let data = *string::bytes(&hex::encode_to_string(&data));
32-
assert!(data == b"12eafdba79c3dd7b90e3712ee475423153a722c7", 1);
30+
assert!(data == x"12eafdba79c3dd7b90e3712ee475423153a722c7", 1);
3331

3432
let addr = string::utf8(b"celestia1zt40mwnec0whhy8rwyhwga2zx9f6wgk87dhv5g");
3533
let (prefix, data) = decode(addr);
3634
assert!(prefix == string::utf8(b"celestia"), 2);
37-
let data = *string::bytes(&hex::encode_to_string(&data));
38-
assert!(data == b"12eafdba79c3dd7b90e3712ee475423153a722c7", 3);
35+
assert!(data == x"12eafdba79c3dd7b90e3712ee475423153a722c7", 3);
3936
}
4037
}

0 commit comments

Comments
 (0)