Skip to content

Commit 0e3a371

Browse files
committed
Still fix some tests
1 parent cd39189 commit 0e3a371

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

gnovm/stdlibs/std/crypto.gno

+21-2
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,18 @@ func EncodeBech32(prefix string, bz [20]byte) Address {
3030
}
3131

3232
func DecodeBech32(addr Address) (string, [20]byte, bool) {
33-
prefix, bz, err := bech32.Decode(string(addr))
33+
prefix, bz, err := decodeAndConvert(string(addr))
3434
if err != nil || len(bz) != 20 {
3535
return "", [20]byte{}, false
3636
}
37-
return prefix, [20]byte(bz), true
37+
/* For some reason [20]byte(bz) fails with: 'cannot convert []uint8 to ArrayKind'
38+
Maybe there is an issue to create
39+
*/
40+
result := [20]byte{}
41+
for index, b := range bz {
42+
result[index] = b
43+
}
44+
return prefix, result, true
3845
}
3946

4047
func convertAndEncode(hrp string, data []byte) (string, error) {
@@ -44,3 +51,15 @@ func convertAndEncode(hrp string, data []byte) (string, error) {
4451
}
4552
return bech32.Encode(hrp, converted)
4653
}
54+
55+
func decodeAndConvert(bech string) (string, []byte, error) {
56+
hrp, data, err := bech32.Decode(bech)
57+
if err != nil {
58+
return "", nil, errors.New("decoding bech32 failed" + err.Error())
59+
}
60+
converted, err := bech32.ConvertBits(data, 5, 8, false)
61+
if err != nil {
62+
return "", nil, errors.New("decoding bech32 failed" + err.Error())
63+
}
64+
return hrp, converted, nil
65+
}

gnovm/tests/files/std5.gno

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func main() {
1313

1414
// Stacktrace:
1515
// panic: frame not found
16-
// callerAt<VPBlock(3,48)>(n<VPBlock(1,0)>)
16+
// callerAt<VPBlock(3,49)>(n<VPBlock(1,0)>)
1717
// gonative:std.callerAt
1818
// std<VPBlock(2,0)>.GetCallerAt(2)
1919
// std/native.gno:45

gnovm/tests/files/std8.gno

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func main() {
2323

2424
// Stacktrace:
2525
// panic: frame not found
26-
// callerAt<VPBlock(3,48)>(n<VPBlock(1,0)>)
26+
// callerAt<VPBlock(3,49)>(n<VPBlock(1,0)>)
2727
// gonative:std.callerAt
2828
// std<VPBlock(2,0)>.GetCallerAt(4)
2929
// std/native.gno:45

gnovm/tests/files/zrealm_natbind0.gno

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func main() {
6969
// "Closure": {
7070
// "@type": "/gno.RefValue",
7171
// "Escaped": true,
72-
// "ObjectID": "a7f5397443359ea76c50be82c77f1f893a060925:9"
72+
// "ObjectID": "a7f5397443359ea76c50be82c77f1f893a060925:10"
7373
// },
7474
// "FileName": "native.gno",
7575
// "IsMethod": false,

0 commit comments

Comments
 (0)