Skip to content

Commit

Permalink
Add a Makefile with a fmt rule
Browse files Browse the repository at this point in the history
  • Loading branch information
jtraglia committed Apr 5, 2024
1 parent 2d68bcd commit c44a9ea
Show file tree
Hide file tree
Showing 36 changed files with 52 additions and 46 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fmt:
gofmt -s -w .
gofumpt -extra -w .
gci write .
go mod tidy
2 changes: 1 addition & 1 deletion api/v1/attesterduty_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"testing"

api "github.com/attestantio/go-eth2-client/api/v1"
require "github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
require "github.com/stretchr/testify/require"
)

func TestAttesterDutyJSON(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/v1/beaconblockheader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"testing"

api "github.com/attestantio/go-eth2-client/api/v1"
require "github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
require "github.com/stretchr/testify/require"
)

func TestBeaconBlockHeaderJSON(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/v1/beaconcommittee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"testing"

api "github.com/attestantio/go-eth2-client/api/v1"
require "github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
require "github.com/stretchr/testify/require"
)

func TestBeaconCommitteeJSON(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/v1/beaconcommitteesubscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"testing"

api "github.com/attestantio/go-eth2-client/api/v1"
require "github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
require "github.com/stretchr/testify/require"
)

func TestBeaconCommitteeSubscriptionJSON(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/v1/blockevent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"testing"

api "github.com/attestantio/go-eth2-client/api/v1"
require "github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
require "github.com/stretchr/testify/require"
)

func TestBlockEventJSON(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/v1/capella/blindedbeaconblock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (

"github.com/attestantio/go-eth2-client/api/v1/capella"
"github.com/goccy/go-yaml"
require "github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
require "github.com/stretchr/testify/require"
)

func TestBlindedBeaconBlockJSON(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/v1/capella/signedblindedbeaconblock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (

"github.com/attestantio/go-eth2-client/api/v1/capella"
"github.com/goccy/go-yaml"
require "github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
require "github.com/stretchr/testify/require"
)

func TestSignedBlindedBeaconBlockJSON(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/v1/chainreorgevent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"testing"

api "github.com/attestantio/go-eth2-client/api/v1"
require "github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
require "github.com/stretchr/testify/require"
)

func TestChainReorgEventJSON(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/v1/depositcontract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"testing"

api "github.com/attestantio/go-eth2-client/api/v1"
require "github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
require "github.com/stretchr/testify/require"
)

func TestDepositContractJSON(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/v1/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"testing"

api "github.com/attestantio/go-eth2-client/api/v1"
require "github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
require "github.com/stretchr/testify/require"
)

func TestEvent(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/v1/finality_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"testing"

api "github.com/attestantio/go-eth2-client/api/v1"
require "github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
require "github.com/stretchr/testify/require"
)

func TestFinalityJSON(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/v1/finalizedcheckpointevent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"testing"

api "github.com/attestantio/go-eth2-client/api/v1"
require "github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
require "github.com/stretchr/testify/require"
)

func TestFinalizedCheckpointEventJSON(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/v1/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"testing"

api "github.com/attestantio/go-eth2-client/api/v1"
require "github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
require "github.com/stretchr/testify/require"
)

func TestGenesisJSON(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/v1/headevent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"testing"

api "github.com/attestantio/go-eth2-client/api/v1"
require "github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
require "github.com/stretchr/testify/require"
)

func TestHeadEventJSON(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/v1/proposalpreparation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"testing"

api "github.com/attestantio/go-eth2-client/api/v1"
require "github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
require "github.com/stretchr/testify/require"
)

func TestProposalPreparationJSON(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/v1/proposerduty_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"testing"

api "github.com/attestantio/go-eth2-client/api/v1"
require "github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
require "github.com/stretchr/testify/require"
)

func TestProposerDutyJSON(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/v1/signedvalidatorregistration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (

api "github.com/attestantio/go-eth2-client/api/v1"
"github.com/goccy/go-yaml"
require "github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
require "github.com/stretchr/testify/require"
)

func TestSignedValidatorRegistrationJSON(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/v1/synccommittee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"testing"

api "github.com/attestantio/go-eth2-client/api/v1"
require "github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
require "github.com/stretchr/testify/require"
)

func TestSyncCommitteeJSON(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/v1/synccommitteeduty_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"testing"

api "github.com/attestantio/go-eth2-client/api/v1"
require "github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
require "github.com/stretchr/testify/require"
)

func TestSyncCommitteeDutyJSON(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/v1/synccommitteesubscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"testing"

api "github.com/attestantio/go-eth2-client/api/v1"
require "github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
require "github.com/stretchr/testify/require"
)

func TestSyncCommitteeSubscriptionJSON(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/v1/syncstate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"testing"

api "github.com/attestantio/go-eth2-client/api/v1"
require "github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
require "github.com/stretchr/testify/require"
)

func TestSyncStateJSON(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/v1/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"testing"

api "github.com/attestantio/go-eth2-client/api/v1"
require "github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
require "github.com/stretchr/testify/require"
)

func TestValidatorJSON(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/v1/validatorbalance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"testing"

api "github.com/attestantio/go-eth2-client/api/v1"
require "github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
require "github.com/stretchr/testify/require"
)

func TestValidatorBalanceJSON(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/v1/validatorregistration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (

api "github.com/attestantio/go-eth2-client/api/v1"
"github.com/goccy/go-yaml"
require "github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
require "github.com/stretchr/testify/require"
)

func TestValidatorRegistrationJSON(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/v1/validatorstate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ func TestMarshalJSON(t *testing.T) {
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
require.NotPanics(t, func() {
res, err := json.Marshal(&test.state) //test.state.MarshalJSON()
res, err := json.Marshal(&test.state) // test.state.MarshalJSON()
test.errFunc(t, err)
require.Equal(t, test.expected, res)
})
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ require (
github.com/rs/zerolog v1.32.0
github.com/stretchr/testify v1.8.4
go.opentelemetry.io/otel v1.16.0
go.opentelemetry.io/otel/trace v1.16.0
golang.org/x/crypto v0.20.0
golang.org/x/sync v0.2.0
)
Expand All @@ -41,7 +42,6 @@ require (
github.com/prometheus/procfs v0.10.1 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
go.opentelemetry.io/otel/metric v1.16.0 // indirect
go.opentelemetry.io/otel/trace v1.16.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
Expand Down
2 changes: 1 addition & 1 deletion http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ func metadataFromHeaders(headers map[string]string) map[string]any {
}

// urlForCall patches together a URL for a call.
func urlForCall(base *url.URL, endpoint string, query string) *url.URL {
func urlForCall(base *url.URL, endpoint, query string) *url.URL {
callURL := *base
callURL.Path = endpoint
if callURL.RawQuery == "" {
Expand Down
4 changes: 2 additions & 2 deletions http/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ func registerPrometheusMetrics(_ context.Context) error {
return nil
}

func (s *Service) monitorGetComplete(_ context.Context, endpoint string, result string) {
func (s *Service) monitorGetComplete(_ context.Context, endpoint, result string) {
if requestsMetric == nil {
return
}

requestsMetric.WithLabelValues(s.address, "GET", reduceEndpoint(endpoint), result).Inc()
}

func (s *Service) monitorPostComplete(_ context.Context, endpoint string, result string) {
func (s *Service) monitorPostComplete(_ context.Context, endpoint, result string) {
if requestsMetric == nil {
return
}
Expand Down
11 changes: 6 additions & 5 deletions http/submitattesterslashing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ package http_test

import (
"context"
"os"
"testing"

client "github.com/attestantio/go-eth2-client"
"github.com/attestantio/go-eth2-client/http"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/stretchr/testify/require"
"os"
"testing"
)

func TestSubmitAttesterSlashing(t *testing.T) {

service, err := http.New(context.Background(),
http.WithTimeout(timeout),
http.WithAddress(os.Getenv("HTTP_ADDRESS")),
Expand Down Expand Up @@ -73,14 +73,15 @@ func TestSubmitAttesterSlashing(t *testing.T) {
Signature: phase0.BLSSignature{0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf},
},
},
}}
},
}

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
// Create proposal slashing and submit.
err := service.(client.AttesterSlashingSubmitter).SubmitAttesterSlashing(context.Background(), &test.slashing)
// This should error on bad slashing
require.Error(t, err) //we should be getting errors about non-slashable attestations or signatures
require.Error(t, err) // we should be getting errors about non-slashable attestations or signatures
})
}
}
11 changes: 6 additions & 5 deletions http/submitproposalslashing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ package http_test

import (
"context"
"os"
"testing"

client "github.com/attestantio/go-eth2-client"
"github.com/attestantio/go-eth2-client/http"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/stretchr/testify/require"
"os"
"testing"
)

func TestSubmitProposalSlashing(t *testing.T) {

service, err := http.New(context.Background(),
http.WithTimeout(timeout),
http.WithAddress(os.Getenv("HTTP_ADDRESS")),
Expand Down Expand Up @@ -77,14 +77,15 @@ func TestSubmitProposalSlashing(t *testing.T) {
Signature: phase0.BLSSignature([96]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}),
},
},
}}
},
}

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
// Create proposal slashing and submit.
err := service.(client.ProposalSlashingSubmitter).SubmitProposalSlashing(context.Background(), &test.slashing)
// This should error on bad slashing
require.Error(t, err) //we should get error 400 with an invalid signature
require.Error(t, err) // we should get error 400 with an invalid signature
})
}
}
4 changes: 2 additions & 2 deletions multi/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func registerPrometheusMetrics(_ context.Context) error {
return nil
}

func (s *Service) setProviderStateMetric(_ context.Context, server string, state string) {
func (s *Service) setProviderStateMetric(_ context.Context, server, state string) {
if stateMetric == nil {
return
}
Expand All @@ -80,7 +80,7 @@ func (s *Service) setProviderStateMetric(_ context.Context, server string, state
}
}

func (s *Service) setConnectionsMetric(_ context.Context, active int, inactive int) {
func (s *Service) setConnectionsMetric(_ context.Context, active, inactive int) {
if connectionsMetric == nil {
return
}
Expand Down
Loading

0 comments on commit c44a9ea

Please sign in to comment.