Skip to content

Commit

Permalink
Merge branch 'develop' into update-geth-to-v1.14
Browse files Browse the repository at this point in the history
  • Loading branch information
james-prysm authored Nov 4, 2024
2 parents 9d891bb + bcb4155 commit 29b93ec
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve
- Changed the signature of `ProcessPayload`.
- Only Build the Protobuf state once during serialization.
- Capella blocks are execution.
- Fixed panic when http request to subscribe to event stream fails.
- updated geth to 1.14 ~
- e2e tests start from capella

Expand Down
1 change: 1 addition & 0 deletions api/client/event/event_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func (h *EventStream) Subscribe(eventsChannel chan<- *Event) {
EventType: EventConnectionError,
Data: []byte(errors.Wrap(err, client.ErrConnectionIssue.Error()).Error()),
}
return
}

defer func() {
Expand Down
22 changes: 21 additions & 1 deletion api/client/event/event_stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestNewEventStream(t *testing.T) {

func TestEventStream(t *testing.T) {
mux := http.NewServeMux()
mux.HandleFunc("/eth/v1/events", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/eth/v1/events", func(w http.ResponseWriter, _ *http.Request) {
flusher, ok := w.(http.Flusher)
require.Equal(t, true, ok)
for i := 1; i <= 3; i++ {
Expand Down Expand Up @@ -79,3 +79,23 @@ func TestEventStream(t *testing.T) {
}
}
}

func TestEventStreamRequestError(t *testing.T) {
topics := []string{"head"}
eventsChannel := make(chan *Event, 1)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

// use valid url that will result in failed request with nil body
stream, err := NewEventStream(ctx, http.DefaultClient, "http://badhost:1234", topics)
require.NoError(t, err)

// error will happen when request is made, should be received over events channel
go stream.Subscribe(eventsChannel)

event := <-eventsChannel
if event.EventType != EventConnectionError {
t.Errorf("Expected event type %q, got %q", EventConnectionError, event.EventType)
}

}

0 comments on commit 29b93ec

Please sign in to comment.