Skip to content

Commit

Permalink
run ineffassign for all code (#12578)
Browse files Browse the repository at this point in the history
* run `ineffassign` for all code

* fix reported ineffassign errors

* remove redundant changes

* fix remaining ineffassign errors

---------

Co-authored-by: Nishant Das <nishdas93@gmail.com>
  • Loading branch information
anukul and nisdas authored Jun 29, 2023
1 parent d0c740f commit 3bc8083
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 16 deletions.
3 changes: 3 additions & 0 deletions api/client/beacon/checkpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ func TestDownloadWeakSubjectivityCheckpoint(t *testing.T) {
wst, err := util.NewBeaconState()
require.NoError(t, err)
fork, err := forkForEpoch(cfg, epoch)
require.NoError(t, err)
require.NoError(t, wst.SetFork(fork))

// set up checkpoint block
Expand Down Expand Up @@ -226,6 +227,7 @@ func TestDownloadBackwardsCompatibleCombined(t *testing.T) {
wst, err := util.NewBeaconState()
require.NoError(t, err)
fork, err := forkForEpoch(cfg, cfg.GenesisEpoch)
require.NoError(t, err)
require.NoError(t, wst.SetFork(fork))

// set up checkpoint block
Expand Down Expand Up @@ -399,6 +401,7 @@ func TestDownloadFinalizedData(t *testing.T) {
st, err := util.NewBeaconState()
require.NoError(t, err)
fork, err := forkForEpoch(cfg, epoch)
require.NoError(t, err)
require.NoError(t, st.SetFork(fork))
require.NoError(t, st.SetSlot(slot))

Expand Down
3 changes: 3 additions & 0 deletions encoding/ssz/detect/configfork_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func TestUnmarshalState(t *testing.T) {
}()
bc := params.BeaconConfig()
altairSlot, err := slots.EpochStart(bc.AltairForkEpoch)
require.NoError(t, err)
bellaSlot, err := slots.EpochStart(bc.BellatrixForkEpoch)
require.NoError(t, err)
cases := []struct {
Expand Down Expand Up @@ -205,6 +206,7 @@ func TestUnmarshalBlock(t *testing.T) {
altairv := bytesutil.ToBytes4(params.BeaconConfig().AltairForkVersion)
bellav := bytesutil.ToBytes4(params.BeaconConfig().BellatrixForkVersion)
altairS, err := slots.EpochStart(params.BeaconConfig().AltairForkEpoch)
require.NoError(t, err)
bellaS, err := slots.EpochStart(params.BeaconConfig().BellatrixForkEpoch)
require.NoError(t, err)
cases := []struct {
Expand Down Expand Up @@ -296,6 +298,7 @@ func TestUnmarshalBlindedBlock(t *testing.T) {
altairv := bytesutil.ToBytes4(params.BeaconConfig().AltairForkVersion)
bellav := bytesutil.ToBytes4(params.BeaconConfig().BellatrixForkVersion)
altairS, err := slots.EpochStart(params.BeaconConfig().AltairForkEpoch)
require.NoError(t, err)
bellaS, err := slots.EpochStart(params.BeaconConfig().BellatrixForkEpoch)
require.NoError(t, err)
cases := []struct {
Expand Down
10 changes: 5 additions & 5 deletions nogo_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@
}
},
"ineffassign": {
"only_files": {
"beacon-chain/.*": "",
"shared/.*": "",
"slasher/.*": "",
"validator/.*": ""
"exclude_files": {
"external/.*": "Third party code",
"rules_go_work-.*": "Third party code",
".*\\.pb.*.go": "Generated code is ok",
".*generated\\.ssz\\.go": "Generated code is ok"
}
},
"properpermissions": {
Expand Down
2 changes: 1 addition & 1 deletion testing/endtoend/component_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func (c *componentHandler) required() []e2etypes.ComponentRunner {
func (c *componentHandler) printPIDs(logger func(string, ...interface{})) {
msg := "\nPID of components. Attach a debugger... if you dare!\n\n"

msg = "This test PID: " + strconv.Itoa(os.Getpid()) + " (parent=" + strconv.Itoa(os.Getppid()) + ")\n"
msg += "This test PID: " + strconv.Itoa(os.Getpid()) + " (parent=" + strconv.Itoa(os.Getppid()) + ")\n"

// Beacon chain nodes
msg += fmt.Sprintf("Beacon chain nodes: %v\n", PIDsFromMultiComponentRunner(c.beaconNodes))
Expand Down
11 changes: 7 additions & 4 deletions testing/endtoend/components/eth1/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func SendTransaction(client *rpc.Client, key *ecdsa.PrivateKey, f *filler.Filler
for i := uint64(0); i < N; i++ {
index := i
g.Go(func() error {
tx, err := txfuzz.RandomValidTx(client, f, sender, nonce+index, expectedPrice, nil, al)
tx, err := txfuzz.RandomValidTx(client, f, sender, nonce+index, gasPrice, nil, al)
if err != nil {
// In the event the transaction constructed is not valid, we continue with the routine
// rather than complete stop it.
Expand All @@ -129,9 +129,12 @@ func SendTransaction(client *rpc.Client, key *ecdsa.PrivateKey, f *filler.Filler
return nil
}
err = backend.SendTransaction(context.Background(), signedTx)
// We continue on if the constructed transaction is invalid
// and can't be submitted on chain.
//nolint:nilerr
if err != nil {
// We continue on if the constructed transaction is invalid
// and can't be submitted on chain.
//nolint:nilerr
return nil
}
return nil
})
}
Expand Down
5 changes: 0 additions & 5 deletions testing/endtoend/components/lighthouse_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,6 @@ func (v *LighthouseValidatorNode) Start(ctx context.Context) error {
}

_, _, index, _ := v.config, v.validatorNum, v.index, v.offset
beaconRPCPort := e2e.TestParams.Ports.PrysmBeaconNodeRPCPort + index
if beaconRPCPort >= e2e.TestParams.Ports.PrysmBeaconNodeRPCPort+e2e.TestParams.BeaconNodeCount {
// Point any extra validator clients to a node we know is running.
beaconRPCPort = e2e.TestParams.Ports.PrysmBeaconNodeRPCPort
}
kPath := e2e.TestParams.TestPath + fmt.Sprintf("/lighthouse-validator-%d", index)
testNetDir := e2e.TestParams.TestPath + fmt.Sprintf("/lighthouse-testnet-%d", index)
httpPort := e2e.TestParams.Ports.LighthouseBeaconNodeHTTPPort
Expand Down
1 change: 0 additions & 1 deletion testing/endtoend/endtoend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,6 @@ func (r *testRunner) defaultEndToEndRun() error {
if err := r.testCheckpointSync(ctx, g, index, conns, httpEndpoints[0], benr, menr); err != nil {
return errors.Wrap(err, "checkpoint sync test failed")
}
index += 1
}

if config.ExtraEpochs > 0 {
Expand Down

0 comments on commit 3bc8083

Please sign in to comment.