diff --git a/testutil/keeper/mocks/lightclient/authority.go b/testutil/keeper/mocks/lightclient/authority.go index 3db36d6ce0..8592036260 100644 --- a/testutil/keeper/mocks/lightclient/authority.go +++ b/testutil/keeper/mocks/lightclient/authority.go @@ -4,7 +4,6 @@ package mocks import ( mock "github.com/stretchr/testify/mock" - authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" types "github.com/cosmos/cosmos-sdk/types" ) @@ -32,24 +31,6 @@ func (_m *LightclientAuthorityKeeper) CheckAuthorization(ctx types.Context, msg return r0 } -// IsAuthorized provides a mock function with given fields: ctx, address, policyType -func (_m *LightclientAuthorityKeeper) IsAuthorized(ctx types.Context, address string, policyType authoritytypes.PolicyType) bool { - ret := _m.Called(ctx, address, policyType) - - if len(ret) == 0 { - panic("no return value specified for IsAuthorized") - } - - var r0 bool - if rf, ok := ret.Get(0).(func(types.Context, string, authoritytypes.PolicyType) bool); ok { - r0 = rf(ctx, address, policyType) - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - // NewLightclientAuthorityKeeper creates a new instance of LightclientAuthorityKeeper. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewLightclientAuthorityKeeper(t interface { diff --git a/x/authority/keeper/msg_server_add_authorization_test.go b/x/authority/keeper/msg_server_add_authorization_test.go index 858281739a..eac12945f2 100644 --- a/x/authority/keeper/msg_server_add_authorization_test.go +++ b/x/authority/keeper/msg_server_add_authorization_test.go @@ -90,32 +90,35 @@ func TestMsgServer_AddAuthorization(t *testing.T) { require.Equal(t, prevLen+1, len(authorizationList.Authorizations)) }) - t.Run("successfully add authorization to list containing only authorization for AddAuthorization", func(t *testing.T) { - k, ctx := keepertest.AuthorityKeeper(t) - admin := keepertest.SetAdminPolicies(ctx, k) - k.SetAuthorizationList(ctx, types.AuthorizationList{ - Authorizations: []types.Authorization{ - AddAuthorization, - }, - }) - msgServer := keeper.NewMsgServerImpl(*k) - - msg := &types.MsgAddAuthorization{ - Creator: admin, - MsgUrl: url, - AuthorizedPolicy: types.PolicyType_groupAdmin, - } - - _, err := msgServer.AddAuthorization(sdk.WrapSDKContext(ctx), msg) - require.NoError(t, err) - - authorizationList, found := k.GetAuthorizationList(ctx) - require.True(t, found) - policy, err := authorizationList.GetAuthorizedPolicy(url) - require.NoError(t, err) - require.Equal(t, types.PolicyType_groupAdmin, policy) - require.Equal(t, 2, len(authorizationList.Authorizations)) - }) + t.Run( + "successfully add authorization to list containing only authorization for AddAuthorization", + func(t *testing.T) { + k, ctx := keepertest.AuthorityKeeper(t) + admin := keepertest.SetAdminPolicies(ctx, k) + k.SetAuthorizationList(ctx, types.AuthorizationList{ + Authorizations: []types.Authorization{ + AddAuthorization, + }, + }) + msgServer := keeper.NewMsgServerImpl(*k) + + msg := &types.MsgAddAuthorization{ + Creator: admin, + MsgUrl: url, + AuthorizedPolicy: types.PolicyType_groupAdmin, + } + + _, err := msgServer.AddAuthorization(sdk.WrapSDKContext(ctx), msg) + require.NoError(t, err) + + authorizationList, found := k.GetAuthorizationList(ctx) + require.True(t, found) + policy, err := authorizationList.GetAuthorizedPolicy(url) + require.NoError(t, err) + require.Equal(t, types.PolicyType_groupAdmin, policy) + require.Equal(t, 2, len(authorizationList.Authorizations)) + }, + ) t.Run("unable to add authorization to empty authorization list", func(t *testing.T) { k, ctx := keepertest.AuthorityKeeper(t) diff --git a/x/crosschain/keeper/msg_server_abort_stuck_cctx_test.go b/x/crosschain/keeper/msg_server_abort_stuck_cctx_test.go index 3a1d991c30..cdc38b36f2 100644 --- a/x/crosschain/keeper/msg_server_abort_stuck_cctx_test.go +++ b/x/crosschain/keeper/msg_server_abort_stuck_cctx_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/stretchr/testify/require" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" diff --git a/x/crosschain/keeper/msg_server_add_outbound_tracker_test.go b/x/crosschain/keeper/msg_server_add_outbound_tracker_test.go index f01f5cf7d5..e43800b2ac 100644 --- a/x/crosschain/keeper/msg_server_add_outbound_tracker_test.go +++ b/x/crosschain/keeper/msg_server_add_outbound_tracker_test.go @@ -6,12 +6,12 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/proofs" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" + authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" "github.com/zeta-chain/zetacore/x/crosschain/keeper" "github.com/zeta-chain/zetacore/x/crosschain/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" diff --git a/x/crosschain/keeper/msg_server_migrate_tss_funds_test.go b/x/crosschain/keeper/msg_server_migrate_tss_funds_test.go index 7cc346d15c..fbd3c870bf 100644 --- a/x/crosschain/keeper/msg_server_migrate_tss_funds_test.go +++ b/x/crosschain/keeper/msg_server_migrate_tss_funds_test.go @@ -8,12 +8,12 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/gas" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" + authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" "github.com/zeta-chain/zetacore/x/crosschain/keeper" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" diff --git a/x/crosschain/keeper/msg_server_remove_outbound_tracker_test.go b/x/crosschain/keeper/msg_server_remove_outbound_tracker_test.go index e4a5a4eb6b..34c40044b5 100644 --- a/x/crosschain/keeper/msg_server_remove_outbound_tracker_test.go +++ b/x/crosschain/keeper/msg_server_remove_outbound_tracker_test.go @@ -4,10 +4,10 @@ import ( "testing" "github.com/stretchr/testify/require" - authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" + authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" "github.com/zeta-chain/zetacore/x/crosschain/keeper" "github.com/zeta-chain/zetacore/x/crosschain/types" ) diff --git a/x/crosschain/keeper/msg_server_update_tss_test.go b/x/crosschain/keeper/msg_server_update_tss_test.go index 7999475b0b..4e894e1586 100644 --- a/x/crosschain/keeper/msg_server_update_tss_test.go +++ b/x/crosschain/keeper/msg_server_update_tss_test.go @@ -4,10 +4,10 @@ import ( "testing" "github.com/stretchr/testify/require" - authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" + authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" "github.com/zeta-chain/zetacore/x/crosschain/keeper" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" "github.com/zeta-chain/zetacore/x/observer/types" diff --git a/x/fungible/keeper/msg_server_update_contract_bytecode.go b/x/fungible/keeper/msg_server_update_contract_bytecode.go index 2125a8344f..8dfa6a0ada 100644 --- a/x/fungible/keeper/msg_server_update_contract_bytecode.go +++ b/x/fungible/keeper/msg_server_update_contract_bytecode.go @@ -33,7 +33,11 @@ func (k msgServer) UpdateContractBytecode( // fetch account to update if !ethcommon.IsHexAddress(msg.ContractAddress) { - return nil, cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid contract address (%s)", msg.ContractAddress) + return nil, cosmoserrors.Wrapf( + sdkerrors.ErrInvalidAddress, + "invalid contract address (%s)", + msg.ContractAddress, + ) } contractAddress := ethcommon.HexToAddress(msg.ContractAddress) acct := k.evmKeeper.GetAccount(ctx, contractAddress) diff --git a/x/observer/keeper/msg_server_update_observer.go b/x/observer/keeper/msg_server_update_observer.go index 74a38c2e5e..a1e4c134d1 100644 --- a/x/observer/keeper/msg_server_update_observer.go +++ b/x/observer/keeper/msg_server_update_observer.go @@ -6,8 +6,8 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" + authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" "github.com/zeta-chain/zetacore/x/observer/types" )