Skip to content

Commit

Permalink
Remove redundant parentheses around nil values (#8199)
Browse files Browse the repository at this point in the history
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
  • Loading branch information
farazdagi and prylabs-bulldozer[bot] committed Jan 5, 2021
1 parent e5c69bd commit 1abe92f
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
22 changes: 11 additions & 11 deletions beacon-chain/cache/depositcache/deposits_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,8 +611,8 @@ func TestPruneProofs_Ok(t *testing.T) {

require.NoError(t, dc.PruneProofs(context.Background(), 1))

assert.DeepEqual(t, ([][]byte)(nil), dc.deposits[0].Deposit.Proof)
assert.DeepEqual(t, ([][]byte)(nil), dc.deposits[1].Deposit.Proof)
assert.DeepEqual(t, [][]byte(nil), dc.deposits[0].Deposit.Proof)
assert.DeepEqual(t, [][]byte(nil), dc.deposits[1].Deposit.Proof)
assert.NotNil(t, dc.deposits[2].Deposit.Proof)
assert.NotNil(t, dc.deposits[3].Deposit.Proof)
}
Expand Down Expand Up @@ -654,7 +654,7 @@ func TestPruneProofs_SomeAlreadyPruned(t *testing.T) {

require.NoError(t, dc.PruneProofs(context.Background(), 2))

assert.DeepEqual(t, ([][]byte)(nil), dc.deposits[2].Deposit.Proof)
assert.DeepEqual(t, [][]byte(nil), dc.deposits[2].Deposit.Proof)
}

func TestPruneProofs_PruneAllWhenDepositIndexTooBig(t *testing.T) {
Expand Down Expand Up @@ -694,10 +694,10 @@ func TestPruneProofs_PruneAllWhenDepositIndexTooBig(t *testing.T) {

require.NoError(t, dc.PruneProofs(context.Background(), 99))

assert.DeepEqual(t, ([][]byte)(nil), dc.deposits[0].Deposit.Proof)
assert.DeepEqual(t, ([][]byte)(nil), dc.deposits[1].Deposit.Proof)
assert.DeepEqual(t, ([][]byte)(nil), dc.deposits[2].Deposit.Proof)
assert.DeepEqual(t, ([][]byte)(nil), dc.deposits[3].Deposit.Proof)
assert.DeepEqual(t, [][]byte(nil), dc.deposits[0].Deposit.Proof)
assert.DeepEqual(t, [][]byte(nil), dc.deposits[1].Deposit.Proof)
assert.DeepEqual(t, [][]byte(nil), dc.deposits[2].Deposit.Proof)
assert.DeepEqual(t, [][]byte(nil), dc.deposits[3].Deposit.Proof)
}

func TestPruneProofs_CorrectlyHandleLastIndex(t *testing.T) {
Expand Down Expand Up @@ -737,10 +737,10 @@ func TestPruneProofs_CorrectlyHandleLastIndex(t *testing.T) {

require.NoError(t, dc.PruneProofs(context.Background(), 4))

assert.DeepEqual(t, ([][]byte)(nil), dc.deposits[0].Deposit.Proof)
assert.DeepEqual(t, ([][]byte)(nil), dc.deposits[1].Deposit.Proof)
assert.DeepEqual(t, ([][]byte)(nil), dc.deposits[2].Deposit.Proof)
assert.DeepEqual(t, ([][]byte)(nil), dc.deposits[3].Deposit.Proof)
assert.DeepEqual(t, [][]byte(nil), dc.deposits[0].Deposit.Proof)
assert.DeepEqual(t, [][]byte(nil), dc.deposits[1].Deposit.Proof)
assert.DeepEqual(t, [][]byte(nil), dc.deposits[2].Deposit.Proof)
assert.DeepEqual(t, [][]byte(nil), dc.deposits[3].Deposit.Proof)
}

func makeDepositProof() [][]byte {
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/db/kv/deposit_contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestStore_DepositContract(t *testing.T) {
contractAddress := common.Address{1, 2, 3}
retrieved, err := db.DepositContractAddress(ctx)
require.NoError(t, err)
assert.DeepEqual(t, ([]uint8)(nil), retrieved, "Expected nil contract address")
assert.DeepEqual(t, []uint8(nil), retrieved, "Expected nil contract address")
require.NoError(t, db.SaveDepositContractAddress(ctx, contractAddress))
retrieved, err = db.DepositContractAddress(ctx)
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion slasher/db/kv/attester_slashings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func TestStore_UpdateAttesterSlashingStatus(t *testing.T) {
has, st, err = db.HasAttesterSlashing(ctx, tt.as)
require.NoError(t, err, "Failed to get attester slashing")
require.Equal(t, true, has, "Failed to find attester slashing: %v", tt.as)
require.Equal(t, (types.SlashingStatus)(types.Included), st, "Failed to find attester slashing with the correct status: %v", tt.as)
require.Equal(t, types.SlashingStatus(types.Included), st, "Failed to find attester slashing with the correct status: %v", tt.as)
}
}

Expand Down
4 changes: 2 additions & 2 deletions slasher/db/kv/block_header_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestNilDBHistoryBlkHdr(t *testing.T) {

bPrime, err := db.BlockHeaders(ctx, slot, validatorID)
require.NoError(t, err, "Failed to get block")
require.DeepEqual(t, ([]*ethpb.SignedBeaconBlockHeader)(nil), bPrime, "Should return nil for a non existent key")
require.DeepEqual(t, []*ethpb.SignedBeaconBlockHeader(nil), bPrime, "Should return nil for a non existent key")
}

func TestSaveHistoryBlkHdr(t *testing.T) {
Expand Down Expand Up @@ -90,7 +90,7 @@ func TestDeleteHistoryBlkHdr(t *testing.T) {
require.NoError(t, err, "Save block failed")
bh, err := db.BlockHeaders(ctx, tt.bh.Header.Slot, tt.bh.Header.ProposerIndex)
require.NoError(t, err)
assert.DeepEqual(t, ([]*ethpb.SignedBeaconBlockHeader)(nil), bh, "Expected block to have been deleted")
assert.DeepEqual(t, []*ethpb.SignedBeaconBlockHeader(nil), bh, "Expected block to have been deleted")
}
}

Expand Down
2 changes: 1 addition & 1 deletion slasher/db/kv/proposer_slashings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func TestStore_UpdateProposerSlashingStatus(t *testing.T) {
has, st, err = db.HasProposerSlashing(ctx, tt.ps)
require.NoError(t, err, "Failed to get proposer slashing")
require.Equal(t, true, has, "Failed to find proposer slashing")
require.Equal(t, (types.SlashingStatus)(types.Included), st, "Failed to find proposer slashing with the correct status")
require.Equal(t, types.SlashingStatus(types.Included), st, "Failed to find proposer slashing with the correct status")
}
}

Expand Down
2 changes: 1 addition & 1 deletion slasher/db/kv/validator_id_pubkey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestNilDBValidatorPublicKey(t *testing.T) {

pk, err := db.ValidatorPubKey(ctx, validatorID)
require.NoError(t, err, "Nil ValidatorPubKey should not return error")
require.DeepEqual(t, ([]uint8)(nil), pk)
require.DeepEqual(t, []uint8(nil), pk)
}

func TestSavePubKey(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion validator/db/kv/historical_attestations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestSetTargetData(t *testing.T) {
target: 0,
source: 100,
signingRoot: []byte{1, 2, 3},
expected: (EncHistoryData)(nil),
expected: EncHistoryData(nil),
error: "encapsulated data size",
},
{
Expand Down

0 comments on commit 1abe92f

Please sign in to comment.