Skip to content

Commit

Permalink
fix the mock prover's CreateInitialLightClientState to check that t…
Browse files Browse the repository at this point in the history
…he given height <= the latest finalized height

Signed-off-by: Masanori Yoshida <[email protected]>
  • Loading branch information
siburu committed Nov 20, 2023
1 parent 27cfff3 commit 523478c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions provers/mock/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ func (pr *Prover) SetupForRelay(ctx context.Context) error {

// CreateInitialLightClientState creates a pair of ClientState and ConsensusState for building MsgCreateClient submitted to the counterparty chain
func (pr *Prover) CreateInitialLightClientState(height exported.Height) (exported.ClientState, exported.ConsensusState, error) {
if height == nil {
if head, err := pr.GetLatestFinalizedHeader(); err != nil {
return nil, nil, fmt.Errorf("failed to get the latest finalized header: %v", err)
} else {
height = head.GetHeight()
}
if head, err := pr.GetLatestFinalizedHeader(); err != nil {
return nil, nil, fmt.Errorf("failed to get the latest finalized header: %v", err)
} else if height == nil {
height = head.GetHeight()
} else if height.GT(head.GetHeight()) {
return nil, nil, fmt.Errorf("the given height is greater than the latest finalized height: %v > %v", height, head)
}

clientState := &mocktypes.ClientState{
Expand Down

0 comments on commit 523478c

Please sign in to comment.