Skip to content

Commit

Permalink
cleaning up tests around big int
Browse files Browse the repository at this point in the history
  • Loading branch information
kasey committed May 18, 2022
1 parent 06ca739 commit 142711f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 6 additions & 0 deletions api/client/builder/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ func TestClient_Status(t *testing.T) {
hc := &http.Client{
Transport: roundtrip(func(r *http.Request) (*http.Response, error) {
defer func() {
if r.Body == nil {
return
}
require.NoError(t, r.Body.Close())
}()
require.Equal(t, statusPath, r.URL.Path)
Expand All @@ -47,6 +50,9 @@ func TestClient_Status(t *testing.T) {
hc = &http.Client{
Transport: roundtrip(func(r *http.Request) (*http.Response, error) {
defer func() {
if r.Body == nil {
return
}
require.NoError(t, r.Body.Close())
}()
require.Equal(t, statusPath, r.URL.Path)
Expand Down
9 changes: 5 additions & 4 deletions api/client/builder/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ var testExampleHeaderResponse = `{
func TestExecutionHeaderResponseUnmarshal(t *testing.T) {
hr := &ExecHeaderResponse{}
require.NoError(t, json.Unmarshal([]byte(testExampleHeaderResponse), hr))
bidValue, err := hr.Data.Message.Value.MarshalText()
require.NoError(t, err)
cases := []struct {
expected string
actual string
Expand All @@ -95,7 +93,7 @@ func TestExecutionHeaderResponseUnmarshal(t *testing.T) {
},
{
expected: "1",
actual: string(bidValue),
actual: hr.Data.Message.Value.String(),
name: "ExecHeaderResponse.Value",
},
{
Expand Down Expand Up @@ -201,6 +199,9 @@ func TestExecutionHeaderResponseToProto(t *testing.T) {
require.NoError(t, err)
txRoot, err := hexutil.Decode("0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2")
require.NoError(t, err)
value := big.NewInt(0)
value, ok := value.SetString("1", 10)
require.Equal(t, true, ok)
expected := &eth.SignedBuilderBid{
Message: &eth.BuilderBid{
Header: &eth.ExecutionPayloadHeader{
Expand All @@ -221,7 +222,7 @@ func TestExecutionHeaderResponseToProto(t *testing.T) {
TransactionsRoot: txRoot,
},
// TODO assumes weird byte slice field
Value: []byte(strconv.FormatUint(uint64(1), 10)),
Value: value.Bytes(),
Pubkey: pubkey,
},
Signature: signature,
Expand Down

0 comments on commit 142711f

Please sign in to comment.