Skip to content

Commit

Permalink
fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
adambabik committed Jun 12, 2019
1 parent 465251a commit 5c290cf
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 30 deletions.
4 changes: 1 addition & 3 deletions cmd/statusd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ func main() {
)
if err != nil {
printUsage()
if err != nil {
logger.Error(err.Error())
}
logger.Error(err.Error())
os.Exit(1)
}

Expand Down
2 changes: 1 addition & 1 deletion extkeys/hdkey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ func TestChildForPurpose(t *testing.T) {

// Check that the key generated by ChildForPurpose with KeyPurposeChat is different from the BIP44
if walletChild.String() == chatChild.String() {
t.Errorf("wrong chat key. expected to be diferrent from the wallet key")
t.Errorf("wrong chat key. expected to be different from the wallet key")
}
}

Expand Down
4 changes: 2 additions & 2 deletions services/rpcfilters/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ func TestGetFilterLogs(t *testing.T) {
logs, err := api.GetFilterLogs(context.TODO(), id)
require.NoError(t, err)
require.Empty(t, logs)
require.Len(t, tracker.criterias, 1)
rst, err := hexutil.DecodeBig(tracker.criterias[0]["fromBlock"].(string))
require.Len(t, tracker.criteria, 1)
rst, err := hexutil.DecodeBig(tracker.criteria[0]["fromBlock"].(string))
require.NoError(t, err)
require.Equal(t, block, rst)
}
26 changes: 13 additions & 13 deletions services/rpcfilters/latest_logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import (
)

type callTracker struct {
mu sync.Mutex
calls int
reply [][]types.Log
criterias []map[string]interface{}
mu sync.Mutex
calls int
reply [][]types.Log
criteria []map[string]interface{}
}

func (c *callTracker) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error {
Expand All @@ -31,7 +31,7 @@ func (c *callTracker) CallContext(ctx context.Context, result interface{}, metho
return errors.New("unexpected length of args")
}
crit := args[0].(map[string]interface{})
c.criterias = append(c.criterias, crit)
c.criteria = append(c.criteria, crit)
select {
case <-ctx.Done():
return errors.New("context canceled")
Expand Down Expand Up @@ -73,7 +73,7 @@ func runLogsFetcherTest(t *testing.T, f *logsFilter, replies [][]types.Log, quer
}
}()
wg.Wait()
require.Len(t, c.criterias, queries)
require.Len(t, c.criteria, queries)
return &c
}

Expand All @@ -90,8 +90,8 @@ func TestLogsFetcherAdjusted(t *testing.T) {
{BlockNumber: 11}, {BlockNumber: 12},
}
c := runLogsFetcherTest(t, f, [][]types.Log{logs}, 2)
require.Equal(t, hexutil.EncodeBig(big.NewInt(10)), c.criterias[0]["fromBlock"])
require.Equal(t, c.criterias[1]["fromBlock"], "latest")
require.Equal(t, hexutil.EncodeBig(big.NewInt(10)), c.criteria[0]["fromBlock"])
require.Equal(t, c.criteria[1]["fromBlock"], "latest")
}

func TestAdjustedDueToReorg(t *testing.T) {
Expand All @@ -110,9 +110,9 @@ func TestAdjustedDueToReorg(t *testing.T) {
{BlockNumber: 12, BlockHash: common.Hash{2, 2}},
}
c := runLogsFetcherTest(t, f, [][]types.Log{logs, reorg}, 3)
require.Equal(t, hexutil.EncodeBig(big.NewInt(10)), c.criterias[0]["fromBlock"])
require.Equal(t, "latest", c.criterias[1]["fromBlock"])
require.Equal(t, hexutil.EncodeBig(big.NewInt(11)), c.criterias[2]["fromBlock"])
require.Equal(t, hexutil.EncodeBig(big.NewInt(10)), c.criteria[0]["fromBlock"])
require.Equal(t, "latest", c.criteria[1]["fromBlock"])
require.Equal(t, hexutil.EncodeBig(big.NewInt(11)), c.criteria[2]["fromBlock"])
}

func TestLogsFetcherCanceledContext(t *testing.T) {
Expand All @@ -127,6 +127,6 @@ func TestLogsFetcherCanceledContext(t *testing.T) {
}
cancel()
c := runLogsFetcherTest(t, f, [][]types.Log{make([]types.Log, 2)}, 2)
require.Equal(t, hexutil.EncodeBig(big.NewInt(10)), c.criterias[0]["fromBlock"])
require.Equal(t, hexutil.EncodeBig(big.NewInt(10)), c.criterias[1]["fromBlock"])
require.Equal(t, hexutil.EncodeBig(big.NewInt(10)), c.criteria[0]["fromBlock"])
require.Equal(t, hexutil.EncodeBig(big.NewInt(10)), c.criteria[1]["fromBlock"])
}
3 changes: 0 additions & 3 deletions services/shhext/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -650,9 +650,6 @@ func (api *PublicAPI) SendPairingMessage(ctx context.Context, msg chat.SendDirec
}

msg.PubKey = crypto.FromECDSAPub(&privateKey.PublicKey)
if err != nil {
return nil, err
}

protocolMessage, err := api.service.protocol.BuildDHMessage(privateKey, &privateKey.PublicKey, msg.Payload)
if err != nil {
Expand Down
7 changes: 2 additions & 5 deletions services/shhext/chat/crypto/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"encoding/hex"
"errors"
"fmt"

"github.com/ethereum/go-ethereum/crypto"
)

Expand Down Expand Up @@ -103,11 +104,7 @@ func EncryptSymmetric(key, plaintext []byte) ([]byte, error) {
return nil, err
}

encrypted, err := aesgcm.Seal(nil, salt, plaintext, nil), nil
if err != nil {
return nil, err
}

encrypted := aesgcm.Seal(nil, salt, plaintext, nil)
return append(encrypted, salt...), nil
}

Expand Down
2 changes: 1 addition & 1 deletion services/shhext/chat/crypto/crypto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func TestSymmetricEncryption(t *testing.T) {
t,
32,
len(cyphertext1),
"Cyphertext with the correct lenght should be generated")
"Cyphertext with the correct length should be generated")

require.NotEqualf(
t,
Expand Down
2 changes: 1 addition & 1 deletion services/shhext/mailservers/connmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (ps *ConnectionManager) Start() {
continue
}
failuresPerServer[ev.Peer]++
log.Debug("request to a mail server expired, disconncet a peer", "address", ev.Peer)
log.Debug("request to a mail server expired, disconnect a peer", "address", ev.Peer)
if failuresPerServer[ev.Peer] >= ps.maxFailures {
state.nodeDisconnected(ev.Peer)
}
Expand Down
2 changes: 1 addition & 1 deletion services/shhext/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const (
defaultTimeoutWaitAdded = 5 * time.Second
)

var errProtocolNotInitialized = errors.New("procotol is not initialized")
var errProtocolNotInitialized = errors.New("protocol is not initialized")

// EnvelopeEventsHandler used for two different event types.
type EnvelopeEventsHandler interface {
Expand Down

0 comments on commit 5c290cf

Please sign in to comment.