Cosmos-sdk: x/ibc: dont rely on mocks from tendermint

Created on 27 Aug 2020  Â·  6Comments  Â·  Source: cosmos/cosmos-sdk

There are places in the x/ibc test code that utilizes tmypes.NewMockPV. The ibc package should define its own mock for private validator instead of relying on one in a different repo. Generally it is not a good practice for repos to rely on mocks of a library as there is no guarantee that they won't break in minor releases.

cc @fedekunze @colin-axner @AdityaSripal


For Admin Use

  • [ ] Not duplicate issue
  • [ ] Appropriate labels applied
  • [ ] Appropriate contributors tagged
  • [ ] Contributor assigned/self-assigned
code-hygiene good first issue tests ibc

Most helpful comment

Hi, can I work on this?

All 6 comments

could we just use the actual private validator code (if possible... I'm not sure where this would be)? Why do we need a mock?

could we just use the actual private validator code (if possible... I'm not sure where this would be)? Why do we need a mock?

You could, we use the mock everywhere we aren't testing privval. Defining your own mock for privval may be the easiest.

given that we I think we literally only use the GetPubKey() func and the struct of the PrivValidator for hashes. I think we should just have the simplest mock possible and return nil on:

SignVote(chainID string, vote *tmproto.Vote) error
SignProposal(chainID string, proposal *tmproto.Proposal) error

this should make maintenance pretty straightforward.

Hi, can I work on this?

yup! I'd suggest making a privval.go file in x/ibc/testing to host the mock of the PrivValidator

given that we I think we literally only use the GetPubKey() func and the struct of the PrivValidator for hashes. I think we should just have the simplest mock possible and return nil on:

SignVote(chainID string, vote *tmproto.Vote) error
SignProposal(chainID string, proposal *tmproto.Proposal) error

this should make maintenance pretty straightforward.

@colin-axner , tests are failing if I simply return nil for the above functions.
So I did keep the mock privValidator interface almost the same as the tendermint one in the PR #7241.

Was this page helpful?
0 / 5 - 0 ratings