diff --git a/wormchain/x/wormhole/keeper/allowlist_test.go b/wormchain/x/wormhole/keeper/allowlist_test.go index 3da54e9257..4feefe1cc9 100644 --- a/wormchain/x/wormhole/keeper/allowlist_test.go +++ b/wormchain/x/wormhole/keeper/allowlist_test.go @@ -10,13 +10,18 @@ import ( "github.com/wormhole-foundation/wormhole/sdk/vaa" ) -// TestAllowedAddressStore tests the setting, getting, and removing of allowed addresses +const ( + WormholeAddress1 = "wormhole1du4amsmvx8yqr8whw7qc5m3c0zpwknmzelwqy6" + WormholeAddress2 = "wormhole13ztxpktzsng3ewkepe2w39ugxzfdf23teptu9n" +) + +// TestAllowedAddressStore tests the setting, getting, and removing of allowed addresses. func TestAllowedAddressStore(t *testing.T) { k, ctx := keepertest.WormholeKeeper(t) value := types.ValidatorAllowedAddress{ - ValidatorAddress: "wormhole1du4amsmvx8yqr8whw7qc5m3c0zpwknmzelwqy6", - AllowedAddress: "wormhole13ztxpktzsng3ewkepe2w39ugxzfdf23teptu9n", + ValidatorAddress: WormholeAddress1, + AllowedAddress: WormholeAddress2, Name: "User1", } @@ -53,6 +58,7 @@ func TestAllowedAddressStore(t *testing.T) { require.False(t, hasAddr) } +// TestValidatorAsAllowedAddress tests if a validator is a guardian or future validator. func TestValidatorAsAllowedAddress(t *testing.T) { k, ctx := keepertest.WormholeKeeper(t) @@ -83,8 +89,8 @@ func TestValidatorAsAllowedAddress(t *testing.T) { require.True(t, isVal) // Check invalid addresses - _, found = k.GetGuardianValidatorByValidatorAddress(ctx, "wormhole13ztxpktzsng3ewkepe2w39ugxzfdf23teptu9n") + _, found = k.GetGuardianValidatorByValidatorAddress(ctx, WormholeAddress1) require.False(t, found) - isVal = k.IsAddressValidatorOrFutureValidator(ctx, "wormhole13ztxpktzsng3ewkepe2w39ugxzfdf23teptu9n") + isVal = k.IsAddressValidatorOrFutureValidator(ctx, WormholeAddress1) require.False(t, isVal) } diff --git a/wormchain/x/wormhole/keeper/grpc_query_allowlist_test.go b/wormchain/x/wormhole/keeper/grpc_query_allowlist_test.go index 0095e04852..ea285a903a 100644 --- a/wormchain/x/wormhole/keeper/grpc_query_allowlist_test.go +++ b/wormchain/x/wormhole/keeper/grpc_query_allowlist_test.go @@ -8,7 +8,7 @@ import ( "github.com/wormhole-foundation/wormchain/x/wormhole/types" ) -// TestQueryAllowlist tests the allow list queries +// TestQueryAllowlist tests the allow list queries. func TestQueryAllowlist(t *testing.T) { k, ctx := keepertest.WormholeKeeper(t) @@ -19,8 +19,8 @@ func TestQueryAllowlist(t *testing.T) { require.Equal(t, 0, len(res.Allowlist)) value := types.ValidatorAllowedAddress{ - ValidatorAddress: "wormhole1du4amsmvx8yqr8whw7qc5m3c0zpwknmzelwqy6", - AllowedAddress: "wormhole13ztxpktzsng3ewkepe2w39ugxzfdf23teptu9n", + ValidatorAddress: WormholeAddress1, + AllowedAddress: WormholeAddress2, Name: "User1", } diff --git a/wormchain/x/wormhole/keeper/grpc_query_ibc_composability_mw_test.go b/wormchain/x/wormhole/keeper/grpc_query_ibc_composability_mw_test.go index 3d96bc445b..c45e146cc2 100644 --- a/wormchain/x/wormhole/keeper/grpc_query_ibc_composability_mw_test.go +++ b/wormchain/x/wormhole/keeper/grpc_query_ibc_composability_mw_test.go @@ -8,7 +8,7 @@ import ( "github.com/wormhole-foundation/wormchain/x/wormhole/types" ) -// TestQueryIbcComposabilityMwContract tests querying of the IbcComposabilityMwContract +// TestQueryIbcComposabilityMwContract tests querying of the IbcComposabilityMwContract. func TestQueryIbcComposabilityMwContract(t *testing.T) { k, ctx := keepertest.WormholeKeeper(t) @@ -23,7 +23,7 @@ func TestQueryIbcComposabilityMwContract(t *testing.T) { require.Equal(t, "", res.ContractAddress) // Set the contract in state store - contractAddr := "wormhole1du4amsmvx8yqr8whw7qc5m3c0zpwknmzelwqy6" + contractAddr := WormholeContractAddress1 k.StoreIbcComposabilityMwContract(ctx, types.IbcComposabilityMwContract{ ContractAddress: contractAddr, }) diff --git a/wormchain/x/wormhole/keeper/grpc_query_latest_guardian_set_index_test.go b/wormchain/x/wormhole/keeper/grpc_query_latest_guardian_set_index_test.go index 827f43c8f9..c58772143f 100644 --- a/wormchain/x/wormhole/keeper/grpc_query_latest_guardian_set_index_test.go +++ b/wormchain/x/wormhole/keeper/grpc_query_latest_guardian_set_index_test.go @@ -10,7 +10,7 @@ import ( "github.com/wormhole-foundation/wormhole/sdk/vaa" ) -// TestLatestGuardianSetIndex tests the querying of the latest guardian set index +// TestLatestGuardianSetIndex tests the querying of the latest guardian set index. func TestLatestGuardianSetIndex(t *testing.T) { k, ctx := keepertest.WormholeKeeper(t) diff --git a/wormchain/x/wormhole/keeper/grpc_query_wasm_instantiate_allowlist_test.go b/wormchain/x/wormhole/keeper/grpc_query_wasm_instantiate_allowlist_test.go index 02b4e124e7..bd11bd2445 100644 --- a/wormchain/x/wormhole/keeper/grpc_query_wasm_instantiate_allowlist_test.go +++ b/wormchain/x/wormhole/keeper/grpc_query_wasm_instantiate_allowlist_test.go @@ -8,7 +8,7 @@ import ( "github.com/wormhole-foundation/wormchain/x/wormhole/types" ) -// TestWasmInstantiateAllowlistAll tests the querying of the wasm instantiate allow list +// TestWasmInstantiateAllowlistAll tests the querying of the wasm instantiate allow list. func TestWasmInstantiateAllowlistAll(t *testing.T) { k, ctx := keepertest.WormholeKeeper(t) @@ -24,7 +24,7 @@ func TestWasmInstantiateAllowlistAll(t *testing.T) { // Set contract in allow list contract := types.WasmInstantiateAllowedContractCodeId{ - ContractAddress: "wormhole1du4amsmvx8yqr8whw7qc5m3c0zpwknmzelwqy6", + ContractAddress: WormholeContractAddress1, CodeId: 1, } k.SetWasmInstantiateAllowlist(ctx, contract) diff --git a/wormchain/x/wormhole/keeper/ibc_composability_mw_test.go b/wormchain/x/wormhole/keeper/ibc_composability_mw_test.go index b8b5e85c9e..5856b3c4c7 100644 --- a/wormchain/x/wormhole/keeper/ibc_composability_mw_test.go +++ b/wormchain/x/wormhole/keeper/ibc_composability_mw_test.go @@ -8,7 +8,7 @@ import ( "github.com/wormhole-foundation/wormchain/x/wormhole/types" ) -// TestIbcComposabilityMwContractStore tests the setting and getting of the contract +// TestIbcComposabilityMwContractStore tests the setting and getting of the contract. func TestIbcComposabilityMwContractStore(t *testing.T) { k, ctx := keepertest.WormholeKeeper(t) diff --git a/wormchain/x/wormhole/keeper/msg_server_execute_gateway_governance_vaa_test.go b/wormchain/x/wormhole/keeper/msg_server_execute_gateway_governance_vaa_test.go index 2578b3abf0..c64808e84b 100644 --- a/wormchain/x/wormhole/keeper/msg_server_execute_gateway_governance_vaa_test.go +++ b/wormchain/x/wormhole/keeper/msg_server_execute_gateway_governance_vaa_test.go @@ -9,7 +9,7 @@ import ( "github.com/wormhole-foundation/wormhole/sdk/vaa" ) -// TestExecuteGatewayGovernanceVaaUpgrades tests creating and cancelling upgrades +// TestExecuteGatewayGovernanceVaaUpgrades tests creating and cancelling upgrades. func TestExecuteGatewayGovernanceVaaUpgrades(t *testing.T) { _, ctx, msgServer, privateKeys, signer, guardianSet := setupWormholeMessageServer(t) @@ -51,12 +51,12 @@ func TestExecuteGatewayGovernanceVaaUpgrades(t *testing.T) { require.NotNil(t, res) } -// TestExecuteGatewayGovernanceVaaSetIbcComposabilityMwContract tests setting the IBC composability contract +// TestExecuteGatewayGovernanceVaaSetIbcComposabilityMwContract tests setting the IBC composability contract. func TestExecuteGatewayGovernanceVaaSetIbcComposabilityMwContract(t *testing.T) { k, ctx, msgServer, privateKeys, signer, guardianSet := setupWormholeMessageServer(t) // Get contract bytes - contractAddr := "wormhole1466nf3zuxpya8q9emxukd7vftaf6h4psr0a07srl5zw74zh84yjq4lyjmh" + contractAddr := WormholeContractAddress1 contractAddrBz, err := sdk.AccAddressFromBech32(contractAddr) require.NoError(t, err) @@ -84,7 +84,7 @@ func TestExecuteGatewayGovernanceVaaSetIbcComposabilityMwContract(t *testing.T) require.Equal(t, contractAddr, contract.ContractAddress) } -// TestExecuteGatewayGovernanceVaaUnknownAction tests submitting an unknown action +// TestExecuteGatewayGovernanceVaaUnknownAction tests submitting an unknown action. func TestExecuteGatewayGovernanceVaaUnknownAction(t *testing.T) { _, ctx, msgServer, privateKeys, signer, guardianSet := setupWormholeMessageServer(t) @@ -105,7 +105,7 @@ func TestExecuteGatewayGovernanceVaaUnknownAction(t *testing.T) { require.Error(t, err) } -// TestExecuteGatewayGovernanceVaaInvalidVAA tests submitting an invalid VAA +// TestExecuteGatewayGovernanceVaaInvalidVAA tests submitting an invalid VAA. func TestExecuteGatewayGovernanceVaaInvalidVAA(t *testing.T) { _, ctx, msgServer, _, signer, guardianSet := setupWormholeMessageServer(t) diff --git a/wormchain/x/wormhole/keeper/msg_server_governance_wormhole_message_proposal_test.go b/wormchain/x/wormhole/keeper/msg_server_governance_wormhole_message_proposal_test.go index 0af50e7429..7b27b69fb4 100644 --- a/wormchain/x/wormhole/keeper/msg_server_governance_wormhole_message_proposal_test.go +++ b/wormchain/x/wormhole/keeper/msg_server_governance_wormhole_message_proposal_test.go @@ -12,7 +12,7 @@ import ( "github.com/wormhole-foundation/wormhole/sdk/vaa" ) -// TestPostMessageProposal tests possible scenarios for how a governance wormhole message proposal can be handled +// TestPostMessageProposal tests possible scenarios for how a governance wormhole message proposal can be handled. func TestPostMessageProposal(t *testing.T) { // get app & ctx app, ctx := keepertest.SetupWormchainAndContext(t) diff --git a/wormchain/x/wormhole/keeper/msg_server_guardian_set_update_proposal_test.go b/wormchain/x/wormhole/keeper/msg_server_guardian_set_update_proposal_test.go index c37e55a83c..49b9e8ef3f 100644 --- a/wormchain/x/wormhole/keeper/msg_server_guardian_set_update_proposal_test.go +++ b/wormchain/x/wormhole/keeper/msg_server_guardian_set_update_proposal_test.go @@ -12,7 +12,7 @@ import ( "github.com/wormhole-foundation/wormhole/sdk/vaa" ) -// TestGuardianSetUpdateProposal tests possible scenarios for how a guardian set update proposal can be handled +// TestGuardianSetUpdateProposal tests possible scenarios for how a guardian set update proposal can be handled. func TestGuardianSetUpdateProposal(t *testing.T) { // get app & ctx app, ctx := keepertest.SetupWormchainAndContext(t) diff --git a/wormchain/x/wormhole/keeper/msg_server_wasm_instantiate_allowlist_test.go b/wormchain/x/wormhole/keeper/msg_server_wasm_instantiate_allowlist_test.go index a57c57b0ed..8fb1c5ca21 100644 --- a/wormchain/x/wormhole/keeper/msg_server_wasm_instantiate_allowlist_test.go +++ b/wormchain/x/wormhole/keeper/msg_server_wasm_instantiate_allowlist_test.go @@ -12,8 +12,13 @@ import ( "github.com/wormhole-foundation/wormhole/sdk/vaa" ) +const ( + WormholeContractAddress1 = "wormhole1466nf3zuxpya8q9emxukd7vftaf6h4psr0a07srl5zw74zh84yjq4lyjmh" + WormholeContractAddress2 = "wormhole1qg5ega6dykkxc307y25pecuufrjkxkaggkkxh7nad0vhyhtuhw3svg697z" +) + // setupWormholeMessageServer creates a keeper, context, msg server, private keys, signer, and guardian set for -// testing the wasm allowlist msg server +// testing the wasm allowlist msg server. func setupWormholeMessageServer(t *testing.T) (keeper.Keeper, sdk.Context, types.MsgServer, []*ecdsa.PrivateKey, sdk.AccAddress, *types.GuardianSet) { k, ctx := keepertest.WormholeKeeper(t) msgServer := keeper.NewMsgServerImpl(*k) @@ -34,11 +39,11 @@ func setupWormholeMessageServer(t *testing.T) (keeper.Keeper, sdk.Context, types return *k, ctx, msgServer, privateKeys, signer, guardianSet } -// TestWasmAllowlistMsgServer tests the endpoints of the wasm allowlist msg server (happy path) +// TestWasmAllowlistMsgServer tests the endpoints of the wasm allowlist msg server (happy path). func TestWasmAllowlistMsgServer(t *testing.T) { k, ctx, msgServer, privateKeys, signer, guardianSet := setupWormholeMessageServer(t) - bech32ContractAddr := "wormhole1466nf3zuxpya8q9emxukd7vftaf6h4psr0a07srl5zw74zh84yjq4lyjmh" + bech32ContractAddr := WormholeContractAddress1 codeId := uint64(1) contractAddr, err := sdk.AccAddressFromBech32(bech32ContractAddr) @@ -98,11 +103,11 @@ func TestWasmAllowlistMsgServer(t *testing.T) { } // TestWasmAllowlistMsgServerMismatchedCodeId tests the endpoints of the wasm allowlist msg server -// with mismatched code id +// with mismatched code id. func TestWasmAllowlistMsgServerMismatchedCodeId(t *testing.T) { _, ctx, msgServer, privateKeys, signer, guardianSet := setupWormholeMessageServer(t) - bech32ContractAddr := "wormhole1466nf3zuxpya8q9emxukd7vftaf6h4psr0a07srl5zw74zh84yjq4lyjmh" + bech32ContractAddr := WormholeContractAddress1 codeId := uint64(1) contractAddr, err := sdk.AccAddressFromBech32(bech32ContractAddr) @@ -133,14 +138,14 @@ func TestWasmAllowlistMsgServerMismatchedCodeId(t *testing.T) { } // TestWasmAllowlistMsgServerMismatchedContractAddr tests the endpoints of the wasm allowlist msg server -// with mismatched contract addresses +// with mismatched contract addresses. func TestWasmAllowlistMsgServerMismatchedContractAddr(t *testing.T) { _, ctx, msgServer, privateKeys, signer, guardianSet := setupWormholeMessageServer(t) - bech32ContractAddr := "wormhole1466nf3zuxpya8q9emxukd7vftaf6h4psr0a07srl5zw74zh84yjq4lyjmh" + bech32ContractAddr := WormholeContractAddress1 codeId := uint64(1) - contractAddr2, err := sdk.AccAddressFromBech32("wormhole1qg5ega6dykkxc307y25pecuufrjkxkaggkkxh7nad0vhyhtuhw3svg697z") + contractAddr2, err := sdk.AccAddressFromBech32(WormholeContractAddress2) require.NoError(t, err) // Create payload with mismatched contract address @@ -164,11 +169,11 @@ func TestWasmAllowlistMsgServerMismatchedContractAddr(t *testing.T) { } // TestWasmAllowlistMsgServerMismatchedVaaAction tests the endpoints of the wasm allowlist msg server -// with mismatched vaa action +// with mismatched vaa action. func TestWasmAllowlistMsgServerMismatchedVaaAction(t *testing.T) { _, ctx, msgServer, privateKeys, signer, guardianSet := setupWormholeMessageServer(t) - bech32ContractAddr := "wormhole1466nf3zuxpya8q9emxukd7vftaf6h4psr0a07srl5zw74zh84yjq4lyjmh" + bech32ContractAddr := WormholeContractAddress1 codeId := uint64(1) contractAddr, err := sdk.AccAddressFromBech32(bech32ContractAddr) @@ -195,11 +200,11 @@ func TestWasmAllowlistMsgServerMismatchedVaaAction(t *testing.T) { } // TestWasmAllowlistMsgServerInvalidVAA tests the endpoints of the wasm allowlist msg server -// with invalid vaa +// with invalid vaa. func TestWasmAllowlistMsgServerInvalidVAA(t *testing.T) { _, ctx, msgServer, _, signer, guardianSet := setupWormholeMessageServer(t) - bech32ContractAddr := "wormhole1466nf3zuxpya8q9emxukd7vftaf6h4psr0a07srl5zw74zh84yjq4lyjmh" + bech32ContractAddr := WormholeContractAddress1 codeId := uint64(1) contractAddr, err := sdk.AccAddressFromBech32(bech32ContractAddr) diff --git a/wormchain/x/wormhole/keeper/wasm_instantiate_allowlist_test.go b/wormchain/x/wormhole/keeper/wasm_instantiate_allowlist_test.go index 4cc891a6ab..d3f9ac3153 100644 --- a/wormchain/x/wormhole/keeper/wasm_instantiate_allowlist_test.go +++ b/wormchain/x/wormhole/keeper/wasm_instantiate_allowlist_test.go @@ -8,13 +8,13 @@ import ( "github.com/wormhole-foundation/wormchain/x/wormhole/types" ) -// TestWasmInstantiateAllowlist tests the setting, getting, and removing of allowed addresses +// TestWasmInstantiateAllowlist tests the setting, getting, and removing of allowed addresses. func TestWasmInstantiateAllowlist(t *testing.T) { k, ctx := keepertest.WormholeKeeper(t) // Create entry entry := types.WasmInstantiateAllowedContractCodeId{ - ContractAddress: "wormhole1du4amsmvx8yqr8whw7qc5m3c0zpwknmzelwqy6", + ContractAddress: WormholeContractAddress1, CodeId: 1, }