From 38f0d64941e09fbfe3aa120f167555335cc2b0a9 Mon Sep 17 00:00:00 2001 From: skosito Date: Sat, 20 Apr 2024 01:26:50 +0200 Subject: [PATCH] Fix some unit tests --- x/crosschain/types/authz_test.go | 14 +++--- zetaclient/zetabridge/broadcast_test.go | 2 +- zetaclient/zetabridge/query_test.go | 62 ++++++++++++------------- zetaclient/zetabridge/tx_test.go | 18 +++---- 4 files changed, 48 insertions(+), 48 deletions(-) diff --git a/x/crosschain/types/authz_test.go b/x/crosschain/types/authz_test.go index 7407a7f28b..d8a581bd07 100644 --- a/x/crosschain/types/authz_test.go +++ b/x/crosschain/types/authz_test.go @@ -8,12 +8,12 @@ import ( ) func TestGetAllAuthzZetaclientTxTypes(t *testing.T) { - require.Equal(t, []string{"/crosschain.MsgVoteGasPrice", - "/crosschain.MsgVoteOnObservedInboundTx", - "/crosschain.MsgVoteOnObservedOutboundTx", - "/crosschain.MsgAddToOutTxTracker", - "/observer.MsgVoteTSS", - "/observer.MsgAddBlameVote", - "/observer.MsgVoteBlockHeader"}, + require.Equal(t, []string{"/zetachain.zetacore.crosschain.MsgVoteGasPrice", + "/zetachain.zetacore.crosschain.MsgVoteOnObservedInboundTx", + "/zetachain.zetacore.crosschain.MsgVoteOnObservedOutboundTx", + "/zetachain.zetacore.crosschain.MsgAddToOutTxTracker", + "/zetachain.zetacore.observer.MsgVoteTSS", + "/zetachain.zetacore.observer.MsgAddBlameVote", + "/zetachain.zetacore.observer.MsgVoteBlockHeader"}, crosschaintypes.GetAllAuthzZetaclientTxTypes()) } diff --git a/zetaclient/zetabridge/broadcast_test.go b/zetaclient/zetabridge/broadcast_test.go index 2686168a90..4d838358b0 100644 --- a/zetaclient/zetabridge/broadcast_test.go +++ b/zetaclient/zetabridge/broadcast_test.go @@ -50,7 +50,7 @@ func TestBroadcast(t *testing.T) { grpcmock.WithPlanner(planner.FirstMatch()), grpcmock.WithListener(listener), func(s *grpcmock.Server) { - method := "/crosschain.Query/LastZetaHeight" + method := "/zetachain.zetacore.crosschain.Query/LastZetaHeight" s.ExpectUnary(method). UnlimitedTimes(). WithPayload(crosschaintypes.QueryLastZetaHeightRequest{}). diff --git a/zetaclient/zetabridge/query_test.go b/zetaclient/zetabridge/query_test.go index d15db862e9..7b3c5b7c37 100644 --- a/zetaclient/zetabridge/query_test.go +++ b/zetaclient/zetabridge/query_test.go @@ -68,7 +68,7 @@ func TestZetaCoreBridge_GetBallot(t *testing.T) { BallotStatus: 0, } input := observertypes.QueryBallotByIdentifierRequest{BallotIdentifier: "123"} - method := "observer.Query/BallotByIdentifier" + method := "zetachain.zetacore.observer.Query/BallotByIdentifier" server := setupMockServer(t, observertypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -89,7 +89,7 @@ func TestZetaCoreBridge_GetCrosschainFlags(t *testing.T) { BlockHeaderVerificationFlags: nil, }} input := observertypes.QueryGetCrosschainFlagsRequest{} - method := "observer.Query/CrosschainFlags" + method := "zetachain.zetacore.observer.Query/CrosschainFlags" server := setupMockServer(t, observertypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -108,7 +108,7 @@ func TestZetaCoreBridge_GetVerificationFlags(t *testing.T) { BtcTypeChainEnabled: false, }} input := lightclienttypes.QueryVerificationFlagsRequest{} - method := "lightclient.Query/VerificationFlags" + method := "zetachain.zetacore.lightclient.Query/VerificationFlags" server := setupMockServer(t, lightclienttypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -128,7 +128,7 @@ func TestZetaCoreBridge_GetChainParamsForChainID(t *testing.T) { MinObserverDelegation: types.ZeroDec(), }} input := observertypes.QueryGetChainParamsForChainRequest{ChainId: 123} - method := "observer.Query/GetChainParamsForChain" + method := "zetachain.zetacore.observer.Query/GetChainParamsForChain" server := setupMockServer(t, observertypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -152,7 +152,7 @@ func TestZetaCoreBridge_GetChainParams(t *testing.T) { }, }} input := observertypes.QueryGetChainParamsRequest{} - method := "observer.Query/GetChainParams" + method := "zetachain.zetacore.observer.Query/GetChainParams" server := setupMockServer(t, observertypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -196,7 +196,7 @@ func TestZetaCoreBridge_GetAllCctx(t *testing.T) { Pagination: nil, } input := crosschainTypes.QueryAllCctxRequest{} - method := "crosschain.Query/CctxAll" + method := "zetachain.zetacore.crosschain.Query/CctxAll" server := setupMockServer(t, crosschainTypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -214,7 +214,7 @@ func TestZetaCoreBridge_GetCctxByHash(t *testing.T) { Index: "9c8d02b6956b9c78ecb6090a8160faaa48e7aecfd0026fcdf533721d861436a3", }} input := crosschainTypes.QueryGetCctxRequest{Index: "9c8d02b6956b9c78ecb6090a8160faaa48e7aecfd0026fcdf533721d861436a3"} - method := "crosschain.Query/Cctx" + method := "zetachain.zetacore.crosschain.Query/Cctx" server := setupMockServer(t, crosschainTypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -235,7 +235,7 @@ func TestZetaCoreBridge_GetCctxByNonce(t *testing.T) { ChainID: 7000, Nonce: 55, } - method := "crosschain.Query/CctxByNonce" + method := "zetachain.zetacore.crosschain.Query/CctxByNonce" server := setupMockServer(t, crosschainTypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -257,7 +257,7 @@ func TestZetaCoreBridge_GetObserverList(t *testing.T) { }, } input := observertypes.QueryObserverSet{} - method := "observer.Query/ObserverSet" + method := "zetachain.zetacore.observer.Query/ObserverSet" server := setupMockServer(t, observertypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -280,7 +280,7 @@ func TestZetaCoreBridge_ListPendingCctx(t *testing.T) { TotalPending: 1, } input := crosschainTypes.QueryListCctxPendingRequest{ChainId: 7000} - method := "crosschain.Query/CctxListPending" + method := "zetachain.zetacore.crosschain.Query/CctxListPending" server := setupMockServer(t, crosschainTypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -297,7 +297,7 @@ func TestZetaCoreBridge_ListPendingCctx(t *testing.T) { func TestZetaCoreBridge_GetAbortedZetaAmount(t *testing.T) { expectedOutput := crosschainTypes.QueryZetaAccountingResponse{AbortedZetaAmount: "1080999"} input := crosschainTypes.QueryZetaAccountingRequest{} - method := "crosschain.Query/ZetaAccounting" + method := "zetachain.zetacore.crosschain.Query/ZetaAccounting" server := setupMockServer(t, crosschainTypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -346,7 +346,7 @@ func TestZetaCoreBridge_GetLastBlockHeight(t *testing.T) { }, } input := crosschainTypes.QueryAllLastBlockHeightRequest{} - method := "crosschain.Query/LastBlockHeightAll" + method := "zetachain.zetacore.crosschain.Query/LastBlockHeightAll" server := setupMockServer(t, crosschainTypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -413,7 +413,7 @@ func TestZetaCoreBridge_GetLastBlockHeightByChain(t *testing.T) { }, } input := crosschainTypes.QueryGetLastBlockHeightRequest{Index: index.ChainName.String()} - method := "crosschain.Query/LastBlockHeight" + method := "zetachain.zetacore.crosschain.Query/LastBlockHeight" server := setupMockServer(t, crosschainTypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -429,7 +429,7 @@ func TestZetaCoreBridge_GetLastBlockHeightByChain(t *testing.T) { func TestZetaCoreBridge_GetZetaBlockHeight(t *testing.T) { expectedOutput := crosschainTypes.QueryLastZetaHeightResponse{Height: 12345} input := crosschainTypes.QueryLastZetaHeightRequest{} - method := "crosschain.Query/LastZetaHeight" + method := "zetachain.zetacore.crosschain.Query/LastZetaHeight" server := setupMockServer(t, crosschainTypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -483,7 +483,7 @@ func TestZetaCoreBridge_GetNonceByChain(t *testing.T) { }, } input := observertypes.QueryGetChainNoncesRequest{Index: chain.ChainName.String()} - method := "observer.Query/ChainNonces" + method := "zetachain.zetacore.observer.Query/ChainNonces" server := setupMockServer(t, observertypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -508,7 +508,7 @@ func TestZetaCoreBridge_GetAllNodeAccounts(t *testing.T) { }, } input := observertypes.QueryAllNodeAccountRequest{} - method := "observer.Query/NodeAccountAll" + method := "zetachain.zetacore.observer.Query/NodeAccountAll" server := setupMockServer(t, observertypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -529,7 +529,7 @@ func TestZetaCoreBridge_GetKeyGen(t *testing.T) { BlockNumber: 5646, }} input := observertypes.QueryGetKeygenRequest{} - method := "observer.Query/Keygen" + method := "zetachain.zetacore.observer.Query/Keygen" server := setupMockServer(t, observertypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -547,7 +547,7 @@ func TestZetaCoreBridge_GetBallotByID(t *testing.T) { BallotIdentifier: "ballot1235", } input := observertypes.QueryBallotByIdentifierRequest{BallotIdentifier: "ballot1235"} - method := "observer.Query/BallotByIdentifier" + method := "zetachain.zetacore.observer.Query/BallotByIdentifier" server := setupMockServer(t, observertypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -572,7 +572,7 @@ func TestZetaCoreBridge_GetInboundTrackersForChain(t *testing.T) { }, } input := crosschainTypes.QueryAllInTxTrackerByChainRequest{ChainId: chainID} - method := "crosschain.Query/InTxTrackerAllByChain" + method := "zetachain.zetacore.crosschain.Query/InTxTrackerAllByChain" server := setupMockServer(t, crosschainTypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -596,7 +596,7 @@ func TestZetaCoreBridge_GetCurrentTss(t *testing.T) { }, } input := observertypes.QueryGetTSSRequest{} - method := "observer.Query/TSS" + method := "zetachain.zetacore.observer.Query/TSS" server := setupMockServer(t, observertypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -615,7 +615,7 @@ func TestZetaCoreBridge_GetEthTssAddress(t *testing.T) { Btc: "bc1qm24wp577nk8aacckv8np465z3dvmu7ry45el6y", } input := observertypes.QueryGetTssAddressRequest{} - method := "observer.Query/GetTssAddress" + method := "zetachain.zetacore.observer.Query/GetTssAddress" server := setupMockServer(t, observertypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -634,7 +634,7 @@ func TestZetaCoreBridge_GetBtcTssAddress(t *testing.T) { Btc: "bc1qm24wp577nk8aacckv8np465z3dvmu7ry45el6y", } input := observertypes.QueryGetTssAddressRequest{BitcoinChainId: 8332} - method := "observer.Query/GetTssAddress" + method := "zetachain.zetacore.observer.Query/GetTssAddress" server := setupMockServer(t, observertypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -660,7 +660,7 @@ func TestZetaCoreBridge_GetTssHistory(t *testing.T) { }, } input := observertypes.QueryTssHistoryRequest{} - method := "observer.Query/TssHistory" + method := "zetachain.zetacore.observer.Query/TssHistory" server := setupMockServer(t, observertypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -687,7 +687,7 @@ func TestZetaCoreBridge_GetOutTxTracker(t *testing.T) { ChainID: chain.ChainId, Nonce: 456, } - method := "crosschain.Query/OutTxTracker" + method := "zetachain.zetacore.crosschain.Query/OutTxTracker" server := setupMockServer(t, crosschainTypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -722,7 +722,7 @@ func TestZetaCoreBridge_GetAllOutTxTrackerByChain(t *testing.T) { Reverse: false, }, } - method := "crosschain.Query/OutTxTrackerAllByChain" + method := "zetachain.zetacore.crosschain.Query/OutTxTrackerAllByChain" server := setupMockServer(t, crosschainTypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -749,7 +749,7 @@ func TestZetaCoreBridge_GetPendingNoncesByChain(t *testing.T) { }, } input := observertypes.QueryPendingNoncesByChainRequest{ChainId: chains.EthChain().ChainId} - method := "observer.Query/PendingNoncesByChain" + method := "zetachain.zetacore.observer.Query/PendingNoncesByChain" server := setupMockServer(t, observertypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -771,7 +771,7 @@ func TestZetaCoreBridge_GetBlockHeaderChainState(t *testing.T) { LatestBlockHash: nil, }} input := lightclienttypes.QueryGetChainStateRequest{ChainId: chainID} - method := "lightclient.Query/ChainState" + method := "zetachain.zetacore.lightclient.Query/ChainState" server := setupMockServer(t, lightclienttypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -796,7 +796,7 @@ func TestZetaCoreBridge_GetSupportedChains(t *testing.T) { }, } input := observertypes.QuerySupportedChains{} - method := "observer.Query/SupportedChains" + method := "zetachain.zetacore.observer.Query/SupportedChains" server := setupMockServer(t, observertypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -821,7 +821,7 @@ func TestZetaCoreBridge_GetPendingNonces(t *testing.T) { }, } input := observertypes.QueryAllPendingNoncesRequest{} - method := "observer.Query/PendingNoncesAll" + method := "zetachain.zetacore.observer.Query/PendingNoncesAll" server := setupMockServer(t, observertypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -849,7 +849,7 @@ func TestZetaCoreBridge_Prove(t *testing.T) { BlockHash: blockHash, TxIndex: int64(txIndex), } - method := "lightclient.Query/Prove" + method := "zetachain.zetacore.lightclient.Query/Prove" server := setupMockServer(t, lightclienttypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -868,7 +868,7 @@ func TestZetaCoreBridge_HasVoted(t *testing.T) { BallotIdentifier: "123456asdf", VoterAddress: "zeta1l40mm7meacx03r4lp87s9gkxfan32xnznp42u6", } - method := "observer.Query/HasVoted" + method := "zetachain.zetacore.observer.Query/HasVoted" server := setupMockServer(t, observertypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) diff --git a/zetaclient/zetabridge/tx_test.go b/zetaclient/zetabridge/tx_test.go index b7630bc7a2..4fd2ee19fb 100644 --- a/zetaclient/zetabridge/tx_test.go +++ b/zetaclient/zetabridge/tx_test.go @@ -210,7 +210,7 @@ func TestZetaCoreBridge_UpdateZetaCoreContext(t *testing.T) { grpcmock.WithPlanner(planner.FirstMatch()), grpcmock.WithListener(listener), func(s *grpcmock.Server) { - method := "/crosschain.Query/LastZetaHeight" + method := "/zetachain.zetacore.crosschain.Query/LastZetaHeight" s.ExpectUnary(method). UnlimitedTimes(). WithPayload(crosschaintypes.QueryLastZetaHeightRequest{}). @@ -227,7 +227,7 @@ func TestZetaCoreBridge_UpdateZetaCoreContext(t *testing.T) { }, }) - method = "/observer.Query/GetChainParams" + method = "/zetachain.zetacore.observer.Query/GetChainParams" s.ExpectUnary(method). UnlimitedTimes(). WithPayload(observertypes.QueryGetChainParamsRequest{}). @@ -239,7 +239,7 @@ func TestZetaCoreBridge_UpdateZetaCoreContext(t *testing.T) { }, }}) - method = "/observer.Query/SupportedChains" + method = "/zetachain.zetacore.observer.Query/SupportedChains" s.ExpectUnary(method). UnlimitedTimes(). WithPayload(observertypes.QuerySupportedChains{}). @@ -254,7 +254,7 @@ func TestZetaCoreBridge_UpdateZetaCoreContext(t *testing.T) { }, }) - method = "/observer.Query/Keygen" + method = "/zetachain.zetacore.observer.Query/Keygen" s.ExpectUnary(method). UnlimitedTimes(). WithPayload(observertypes.QueryGetKeygenRequest{}). @@ -265,7 +265,7 @@ func TestZetaCoreBridge_UpdateZetaCoreContext(t *testing.T) { BlockNumber: 5646, }}) - method = "/observer.Query/TSS" + method = "/zetachain.zetacore.observer.Query/TSS" s.ExpectUnary(method). UnlimitedTimes(). WithPayload(observertypes.QueryGetTSSRequest{}). @@ -279,7 +279,7 @@ func TestZetaCoreBridge_UpdateZetaCoreContext(t *testing.T) { }, }) - method = "/observer.Query/CrosschainFlags" + method = "/zetachain.zetacore.observer.Query/CrosschainFlags" s.ExpectUnary(method). UnlimitedTimes(). WithPayload(observertypes.QueryGetCrosschainFlagsRequest{}). @@ -290,7 +290,7 @@ func TestZetaCoreBridge_UpdateZetaCoreContext(t *testing.T) { BlockHeaderVerificationFlags: nil, }}) - method = "/lightclient.Query/VerificationFlags" + method = "/zetachain.zetacore.lightclient.Query/VerificationFlags" s.ExpectUnary(method). UnlimitedTimes(). WithPayload(lightclienttypes.QueryVerificationFlagsRequest{}). @@ -370,7 +370,7 @@ func TestZetaCoreBridge_PostVoteInbound(t *testing.T) { BallotIdentifier: "0x2d10e9b7ce7921fa6b61ada3020d1c797d5ec52424cdcf86ef31cbbbcd45db58", VoterAddress: address.String(), } - method := "/observer.Query/HasVoted" + method := "/zetachain.zetacore.observer.Query/HasVoted" server := setupMockServer(t, observertypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -437,7 +437,7 @@ func TestZetaCoreBridge_PostVoteOutbound(t *testing.T) { BallotIdentifier: "0xc507c67847209b403def6d944486ff888c442eccf924cf9ebdc48714b22b5347", VoterAddress: address.String(), } - method := "/observer.Query/HasVoted" + method := "/zetachain.zetacore.observer.Query/HasVoted" server := setupMockServer(t, observertypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server)