From 2d54a1d3d6925b1080a7f3173f94da929e84882f Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Mon, 24 Jul 2023 21:16:33 +0800 Subject: [PATCH] fix: use a constant for badAddress in tx_test.go (#1533) * use a constant * use a constant for badAddress --- x/wasm/types/tx_test.go | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/x/wasm/types/tx_test.go b/x/wasm/types/tx_test.go index 95bd3542ec..6739510923 100644 --- a/x/wasm/types/tx_test.go +++ b/x/wasm/types/tx_test.go @@ -11,10 +11,12 @@ import ( "github.com/stretchr/testify/require" ) -const firstCodeID = 1 +const ( + firstCodeID = 1 + badAddress = "abcd" +) func TestStoreCodeValidation(t *testing.T) { - badAddress := "abcd" // proper address size goodAddress := sdk.AccAddress(make([]byte, ContractAddrLen)).String() sdk.GetConfig().SetAddressVerifier(VerifyAddressLen()) @@ -76,7 +78,6 @@ func TestStoreCodeValidation(t *testing.T) { } func TestInstantiateContractValidation(t *testing.T) { - badAddress := "abcd" // proper address size goodAddress := sdk.AccAddress(make([]byte, 20)).String() sdk.GetConfig().SetAddressVerifier(VerifyAddressLen()) @@ -182,7 +183,6 @@ func TestInstantiateContractValidation(t *testing.T) { } func TestInstantiateContract2Validation(t *testing.T) { - badAddress := "abcd" // proper address size goodAddress := sdk.AccAddress(make([]byte, 20)).String() sdk.GetConfig().SetAddressVerifier(VerifyAddressLen()) @@ -316,7 +316,6 @@ func TestInstantiateContract2Validation(t *testing.T) { } func TestExecuteContractValidation(t *testing.T) { - badAddress := "abcd" // proper address size goodAddress := sdk.AccAddress(make([]byte, 20)).String() @@ -423,7 +422,6 @@ func TestExecuteContractValidation(t *testing.T) { } func TestMsgUpdateAdministrator(t *testing.T) { - badAddress := "abcd" // proper address size goodAddress := sdk.AccAddress(make([]byte, 20)).String() otherGoodAddress := sdk.AccAddress(bytes.Repeat([]byte{0x1}, 20)).String() @@ -493,7 +491,6 @@ func TestMsgUpdateAdministrator(t *testing.T) { } func TestMsgClearAdministrator(t *testing.T) { - badAddress := "abcd" // proper address size goodAddress := sdk.AccAddress(make([]byte, 20)).String() anotherGoodAddress := sdk.AccAddress(bytes.Repeat([]byte{0x2}, 20)).String() @@ -542,7 +539,6 @@ func TestMsgClearAdministrator(t *testing.T) { } func TestMsgMigrateContract(t *testing.T) { - badAddress := "abcd" // proper address size goodAddress := sdk.AccAddress(make([]byte, 20)).String() anotherGoodAddress := sdk.AccAddress(bytes.Repeat([]byte{0x2}, 20)).String() @@ -666,7 +662,6 @@ func TestMsgJsonSignBytes(t *testing.T) { } func TestMsgUpdateInstantiateConfig(t *testing.T) { - badAddress := "abcd" // proper address size goodAddress := sdk.AccAddress(make([]byte, 20)).String() anotherGoodAddress := sdk.AccAddress(bytes.Repeat([]byte{0x2}, 20)).String() @@ -726,7 +721,6 @@ func TestMsgUpdateInstantiateConfig(t *testing.T) { } func TestMsgUpdateParamsValidation(t *testing.T) { - badAddress := "abcd" // proper address size goodAddress := sdk.AccAddress(make([]byte, 20)).String() @@ -828,7 +822,6 @@ func TestMsgAddCodeUploadParamsAddressesValidation(t *testing.T) { } func TestMsgRemoveCodeUploadParamsAddressesValidation(t *testing.T) { - badAddress := "abcd" // proper address size goodAddress := sdk.AccAddress(make([]byte, 20)).String() @@ -889,7 +882,6 @@ func TestMsgRemoveCodeUploadParamsAddressesValidation(t *testing.T) { } func TestMsgPinCodesValidation(t *testing.T) { - badAddress := "abcd" // proper address size goodAddress := sdk.AccAddress(make([]byte, 20)).String() @@ -936,7 +928,6 @@ func TestMsgPinCodesValidation(t *testing.T) { } func TestMsgUnpinCodesValidation(t *testing.T) { - badAddress := "abcd" // proper address size goodAddress := sdk.AccAddress(make([]byte, 20)).String() @@ -1058,7 +1049,6 @@ func TestMsgSudoContractValidation(t *testing.T) { } func TestMsgStoreAndInstantiateContractValidation(t *testing.T) { - badAddress := "abcd" // proper address size goodAddress := sdk.AccAddress(make([]byte, 20)).String() sdk.GetConfig().SetAddressVerifier(VerifyAddressLen())