Skip to content

Commit 9394faf

Browse files
committed
Maybe this will fix the problem.
1 parent 99ade09 commit 9394faf

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

x/wasm/keeper/addresses_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package keeper
33
import (
44
"encoding/json"
55
"fmt"
6+
tmbytes "github.com/cometbft/cometbft/libs/bytes"
67
"testing"
78

8-
tmbytes "github.com/cometbft/cometbft/libs/bytes"
99
"github.com/stretchr/testify/require"
1010

1111
sdk "github.com/cosmos/cosmos-sdk/types"
@@ -14,12 +14,18 @@ import (
1414
func TestBuildContractAddressClassic(t *testing.T) {
1515
// preserve current Bech32 settings and restore them after test completion
1616
x, y := sdk.GetConfig().GetBech32AccountAddrPrefix(), sdk.GetConfig().GetBech32AccountPubPrefix()
17+
c := sdk.IsAddrCacheEnabled()
1718
t.Cleanup(func() {
1819
sdk.GetConfig().SetBech32PrefixForAccount(x, y)
20+
sdk.SetAddrCacheEnabled(c)
1921
})
2022

2123
// set custom Bech32 settings
2224
sdk.GetConfig().SetBech32PrefixForAccount("purple", "purple")
25+
// disables address cache, AccAddress -> String conversion is then slower,
26+
// but does not lead to errors like:
27+
// runtime error: invalid memory address or nil pointer dereference
28+
sdk.SetAddrCacheEnabled(false)
2329

2430
// prepare test data
2531
type Spec struct {
@@ -112,7 +118,7 @@ func TestBuildContractAddressPredictable(t *testing.T) {
112118
t.Run(fmt.Sprintf("case %d", i), func(t *testing.T) {
113119
// when
114120
gotAddr := BuildContractAddressPredictable(spec.In.Checksum, spec.In.Creator, spec.In.Salt.Bytes(), []byte(spec.In.Msg))
115-
121+
// then
116122
require.Equal(t, spec.Out.Address.String(), gotAddr.String())
117123
require.NoError(t, sdk.VerifyAddressFormat(gotAddr))
118124
})

0 commit comments

Comments
 (0)