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

[code health] rename cont to ok #497

Merged
merged 6 commits into from
Aug 3, 2023
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
12 changes: 6 additions & 6 deletions services/api/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1671,8 +1671,8 @@ func (api *RelayAPI) handleSubmitNewBlock(w http.ResponseWriter, req *http.Reque
return
}

cont := api.checkSubmissionSlotDetails(w, log, headSlot, payload)
if !cont {
ok := api.checkSubmissionSlotDetails(w, log, headSlot, payload)
if !ok {
return
}

Expand Down Expand Up @@ -1708,8 +1708,8 @@ func (api *RelayAPI) handleSubmitNewBlock(w http.ResponseWriter, req *http.Reque

log = log.WithField("timestampAfterChecks1", time.Now().UTC().UnixMilli())

gasLimit, cont := api.checkSubmissionFeeRecipient(w, log, payload)
if !cont {
gasLimit, ok := api.checkSubmissionFeeRecipient(w, log, payload)
if !ok {
return
}

Expand All @@ -1730,8 +1730,8 @@ func (api *RelayAPI) handleSubmitNewBlock(w http.ResponseWriter, req *http.Reque

log = log.WithField("timestampBeforeAttributesCheck", time.Now().UTC().UnixMilli())

cont = api.checkSubmissionPayloadAttrs(w, log, payload)
if !cont {
ok = api.checkSubmissionPayloadAttrs(w, log, payload)
if !ok {
return
}

Expand Down
36 changes: 18 additions & 18 deletions services/api/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ func TestCheckSubmissionFeeRecipient(t *testing.T) {
description string
slotDuty *common.BuilderGetValidatorsResponseEntry
payload *common.BuilderSubmitBlockRequest
expectCont bool
expectOk bool
expectGasLimit uint64
}{
{
Expand All @@ -529,7 +529,7 @@ func TestCheckSubmissionFeeRecipient(t *testing.T) {
},
},
},
expectCont: true,
expectOk: true,
expectGasLimit: testGasLimit,
},
{
Expand All @@ -542,7 +542,7 @@ func TestCheckSubmissionFeeRecipient(t *testing.T) {
},
},
},
expectCont: false,
expectOk: false,
expectGasLimit: 0,
},
{
Expand All @@ -563,7 +563,7 @@ func TestCheckSubmissionFeeRecipient(t *testing.T) {
},
},
},
expectCont: false,
expectOk: false,
expectGasLimit: 0,
},
}
Expand All @@ -579,7 +579,7 @@ func TestCheckSubmissionFeeRecipient(t *testing.T) {
log := logrus.NewEntry(logger)
gasLimit, cont := backend.relay.checkSubmissionFeeRecipient(w, log, tc.payload)
require.Equal(t, tc.expectGasLimit, gasLimit)
require.Equal(t, tc.expectCont, cont)
require.Equal(t, tc.expectOk, cont)
})
}
}
Expand All @@ -596,7 +596,7 @@ func TestCheckSubmissionPayloadAttrs(t *testing.T) {
description string
attrs payloadAttributesHelper
payload *common.BuilderSubmitBlockRequest
expectCont bool
expectOk bool
}{
{
description: "success",
Expand Down Expand Up @@ -624,7 +624,7 @@ func TestCheckSubmissionPayloadAttrs(t *testing.T) {
},
},
},
expectCont: true,
expectOk: true,
},
{
description: "failure_attrs_not_known",
Expand All @@ -638,7 +638,7 @@ func TestCheckSubmissionPayloadAttrs(t *testing.T) {
},
},
},
expectCont: false,
expectOk: false,
},
{
description: "failure_wrong_prev_randao",
Expand All @@ -659,7 +659,7 @@ func TestCheckSubmissionPayloadAttrs(t *testing.T) {
},
},
},
expectCont: false,
expectOk: false,
},
{
description: "failure_nil_withdrawals",
Expand All @@ -681,7 +681,7 @@ func TestCheckSubmissionPayloadAttrs(t *testing.T) {
},
},
},
expectCont: false,
expectOk: false,
},
{
description: "failure_wrong_withdrawal_root",
Expand Down Expand Up @@ -709,7 +709,7 @@ func TestCheckSubmissionPayloadAttrs(t *testing.T) {
},
},
},
expectCont: false,
expectOk: false,
},
}
for _, tc := range cases {
Expand All @@ -724,7 +724,7 @@ func TestCheckSubmissionPayloadAttrs(t *testing.T) {
logger := logrus.New()
log := logrus.NewEntry(logger)
cont := backend.relay.checkSubmissionPayloadAttrs(w, log, tc.payload)
require.Equal(t, tc.expectCont, cont)
require.Equal(t, tc.expectOk, cont)
})
}
}
Expand All @@ -733,7 +733,7 @@ func TestCheckSubmissionSlotDetails(t *testing.T) {
cases := []struct {
description string
payload *common.BuilderSubmitBlockRequest
expectCont bool
expectOk bool
}{
{
description: "success",
Expand All @@ -747,14 +747,14 @@ func TestCheckSubmissionSlotDetails(t *testing.T) {
},
},
},
expectCont: true,
expectOk: true,
},
{
description: "failure_nil_capella",
payload: &common.BuilderSubmitBlockRequest{
Capella: nil, // nil to cause error
},
expectCont: false,
expectOk: false,
},
{
description: "failure_past_slot",
Expand All @@ -765,7 +765,7 @@ func TestCheckSubmissionSlotDetails(t *testing.T) {
},
},
},
expectCont: false,
expectOk: false,
},
{
description: "failure_wrong_timestamp",
Expand All @@ -779,7 +779,7 @@ func TestCheckSubmissionSlotDetails(t *testing.T) {
},
},
},
expectCont: false,
expectOk: false,
},
}
for _, tc := range cases {
Expand All @@ -791,7 +791,7 @@ func TestCheckSubmissionSlotDetails(t *testing.T) {
logger := logrus.New()
log := logrus.NewEntry(logger)
cont := backend.relay.checkSubmissionSlotDetails(w, log, headSlot, tc.payload)
require.Equal(t, tc.expectCont, cont)
require.Equal(t, tc.expectOk, cont)
})
}
}
Expand Down
Loading