Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: returns descriptive error in case no sequencer registered on the hub #305

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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