Skip to content

Commit

Permalink
fix: panic on invalid destination (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpetrun5 authored Jul 10, 2024
1 parent 75c4bcb commit 258996b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion relayer/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (r *Relayer) Start(ctx context.Context, msgChan chan []*message.Message) {
func (r *Relayer) route(msgs []*message.Message) {
destChain, ok := r.relayedChains[msgs[0].Destination]
if !ok {
log.Error().Uint8("domainID", destChain.DomainID()).Msgf("No chain registered for destination domain")
log.Error().Uint8("domainID", msgs[0].Destination).Msgf("No chain registered for destination domain")
return
}

Expand Down
15 changes: 15 additions & 0 deletions relayer/relayer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,18 @@ func (s *RouteTestSuite) TestWritesToChain() {
{Destination: 1},
})
}

func (s *RouteTestSuite) Test_Route_ChainDoesNotExist() {
props := make([]*proposal.Proposal, 1)
prop := &proposal.Proposal{}
props[0] = prop
chains := make(map[uint8]RelayedChain)
chains[1] = s.mockRelayedChain
relayer := NewRelayer(
chains,
)

relayer.route([]*message.Message{
{Destination: 11},
})
}

0 comments on commit 258996b

Please sign in to comment.