Skip to content

Commit

Permalink
Fix some unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed Apr 19, 2024
1 parent 9a7743a commit 38f0d64
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 48 deletions.
14 changes: 7 additions & 7 deletions x/crosschain/types/authz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
2 changes: 1 addition & 1 deletion zetaclient/zetabridge/broadcast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}).
Expand Down
62 changes: 31 additions & 31 deletions zetaclient/zetabridge/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
18 changes: 9 additions & 9 deletions zetaclient/zetabridge/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}).
Expand All @@ -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{}).
Expand All @@ -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{}).
Expand All @@ -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{}).
Expand All @@ -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{}).
Expand All @@ -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{}).
Expand All @@ -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{}).
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 38f0d64

Please sign in to comment.