Skip to content

Commit

Permalink
Add test for IsExecutionRequestError
Browse files Browse the repository at this point in the history
  • Loading branch information
terencechain committed Jan 31, 2025
1 parent 784bf13 commit b481921
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions beacon-chain/core/electra/error_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package electra

import (
"testing"

"github.com/pkg/errors"
)

func TestIsExecutionRequestError(t *testing.T) {
tests := []struct {
name string
err error
want bool
}{
{
name: "nil error",
err: nil,
want: false,
},
{
name: "random error",
err: errors.New("some error"),
want: false,
},
{
name: "execution request error",
err: execReqErr{errors.New("execution request failed")},
want: true,
},
{
name: "wrapped execution request error",
err: errors.Wrap(execReqErr{errors.New("execution request failed")}, "wrapped"),
want: true,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := IsExecutionRequestError(tt.err)
if got != tt.want {
t.Errorf("IsExecutionRequestError(%v) = %v, want %v", tt.err, got, tt.want)
}
})
}
}

0 comments on commit b481921

Please sign in to comment.