Skip to content

Commit

Permalink
fix: returns descriptive error in case no sequencer registered on the…
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsitrin authored Apr 30, 2023
1 parent c217bda commit 1f3cc05
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
3 changes: 0 additions & 3 deletions settlement/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ func (b *BaseLayerClient) Init(config []byte, pubsub *pubsub.Server, logger log.
b.logger.Info("Updated latest height from settlement layer", "latestHeight", endHeight)
b.sequencersList, err = b.fetchSequencersList()
if err != nil {
if err == ErrNoSequencerForRollapp {
panic(err)
}
return err
}
b.logger.Info("Updated sequencers list from settlement layer", "sequencersList", b.sequencersList)
Expand Down
3 changes: 0 additions & 3 deletions settlement/dymension/dymension.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,6 @@ func (d *HubClient) GetBatchAtIndex(rollappID string, index uint64) (*settlement
func (d *HubClient) GetSequencers(rollappID string) ([]*types.Sequencer, error) {
sequencers, err := d.sequencerQueryClient.SequencersByRollapp(d.ctx, &sequencertypes.QueryGetSequencersByRollappRequest{RollappId: d.config.RollappID})
if err != nil {
return nil, err
}
if sequencers == nil {
return nil, settlement.ErrNoSequencerForRollapp
}
sequencersList := []*types.Sequencer{}
Expand Down
2 changes: 1 addition & 1 deletion settlement/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ var (
// ErrBatchNotFound is returned when a batch is not found for the rollapp.
ErrBatchNotFound = errors.New("batch not found")
// ErrNoSequencerForRollapp is returned when a sequencer is not found for the rollapp.
ErrNoSequencerForRollapp = errors.New("no sequencer for rollapp")
ErrNoSequencerForRollapp = errors.New("no sequencer registered on the hub for this rollapp")
)
6 changes: 5 additions & 1 deletion settlement/settlement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ func TestGetSequencersEmptyList(t *testing.T) {
options := []settlement.Option{
settlement.WithHubClient(hubClientMock),
}
assert.Panics(t, func() { initClient(t, settlementClient, options...) })

pubsubServer := pubsub.NewServer()
pubsubServer.Start()
err := settlementClient.Init([]byte{}, pubsubServer, test.NewLogger(t), options...)
assert.Error(t, err, "empty sequencer list should return an error")

}

Expand Down

0 comments on commit 1f3cc05

Please sign in to comment.