Browse Source

Make vetshadow and zach happy

pull/1782/head
Ethan Frey 7 years ago
parent
commit
086e1f6508
8 changed files with 32 additions and 35 deletions
  1. +1
    -1
      Makefile
  2. +1
    -3
      encode_test.go
  3. +3
    -3
      keys/ecc_test.go
  4. +9
    -9
      keys/keybase_test.go
  5. +6
    -6
      keys/wordcodec_test.go
  6. +5
    -5
      nano/keys_test.go
  7. +5
    -4
      nano/sign_test.go
  8. +2
    -4
      signature_test.go

+ 1
- 1
Makefile View File

@ -58,9 +58,9 @@ metalinter_test: ensure_tools
--enable=unused \ --enable=unused \
--enable=vet \ --enable=vet \
--enable=varcheck \ --enable=varcheck \
--enable=vetshadow \
./... ./...
# --enable=vetshadow \ <= doesn't like assert := assert.New(t)
#--enable=dupl \ #--enable=dupl \
#--enable=errcheck \ #--enable=errcheck \


+ 1
- 3
encode_test.go View File

@ -145,8 +145,6 @@ func (s SigMessage) Bytes() []byte {
} }
func TestEmbededWireEncodings(t *testing.T) { func TestEmbededWireEncodings(t *testing.T) {
assert := assert.New(t)
cases := []struct { cases := []struct {
privKey PrivKey privKey PrivKey
keyType byte keyType byte
@ -171,7 +169,7 @@ func TestEmbededWireEncodings(t *testing.T) {
for i, tc := range cases { for i, tc := range cases {
pubKey := tc.privKey.PubKey() pubKey := tc.privKey.PubKey()
sig := tc.privKey.Sign(payload) sig := tc.privKey.Sign(payload)
assert.True(pubKey.VerifyBytes(payload, sig), "%d", i)
assert.True(t, pubKey.VerifyBytes(payload, sig), "%d", i)
msg := SigMessage{ msg := SigMessage{
Key: pubKey, Key: pubKey,


+ 3
- 3
keys/ecc_test.go View File

@ -3,7 +3,7 @@ package keys
import ( import (
"testing" "testing"
"github.com/stretchr/testify/assert"
asrt "github.com/stretchr/testify/assert"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tmlibs/common"
) )
@ -21,7 +21,7 @@ var codecs = []ECC{
// TestECCPasses makes sure that the AddECC/CheckECC methods are symetric // TestECCPasses makes sure that the AddECC/CheckECC methods are symetric
func TestECCPasses(t *testing.T) { func TestECCPasses(t *testing.T) {
assert := assert.New(t)
assert := asrt.New(t)
checks := append(codecs, NoECC{}) checks := append(codecs, NoECC{})
@ -41,7 +41,7 @@ func TestECCPasses(t *testing.T) {
// TestECCFails makes sure random data will (usually) fail the checksum // TestECCFails makes sure random data will (usually) fail the checksum
func TestECCFails(t *testing.T) { func TestECCFails(t *testing.T) {
assert := assert.New(t)
assert := asrt.New(t)
checks := codecs checks := codecs
attempts := 2000 attempts := 2000


+ 9
- 9
keys/keybase_test.go View File

@ -5,8 +5,8 @@ import (
"os" "os"
"testing" "testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
asrt "github.com/stretchr/testify/assert"
rqr "github.com/stretchr/testify/require"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tmlibs/common"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tmlibs/db"
@ -18,7 +18,7 @@ import (
// TestKeyManagement makes sure we can manipulate these keys well // TestKeyManagement makes sure we can manipulate these keys well
func TestKeyManagement(t *testing.T) { func TestKeyManagement(t *testing.T) {
assert, require := assert.New(t), require.New(t)
assert, require := asrt.New(t), rqr.New(t)
// make the storage with reasonable defaults // make the storage with reasonable defaults
cstore := keys.New( cstore := keys.New(
@ -86,7 +86,7 @@ func TestKeyManagement(t *testing.T) {
// TestSignVerify does some detailed checks on how we sign and validate // TestSignVerify does some detailed checks on how we sign and validate
// signatures // signatures
func TestSignVerify(t *testing.T) { func TestSignVerify(t *testing.T) {
assert, require := assert.New(t), require.New(t)
assert, require := asrt.New(t), rqr.New(t)
// make the storage with reasonable defaults // make the storage with reasonable defaults
cstore := keys.New( cstore := keys.New(
@ -157,7 +157,7 @@ func TestSignVerify(t *testing.T) {
// This test will only succeed with a ledger attached to the computer // This test will only succeed with a ledger attached to the computer
// and the cosmos app open // and the cosmos app open
func TestSignWithLedger(t *testing.T) { func TestSignWithLedger(t *testing.T) {
assert, require := assert.New(t), require.New(t)
assert, require := asrt.New(t), rqr.New(t)
if os.Getenv("WITH_LEDGER") == "" { if os.Getenv("WITH_LEDGER") == "" {
t.Skip("Set WITH_LEDGER to run code on real ledger") t.Skip("Set WITH_LEDGER to run code on real ledger")
} }
@ -205,7 +205,7 @@ func TestSignWithLedger(t *testing.T) {
assert.False(key.VerifyBytes(d1, s2)) assert.False(key.VerifyBytes(d1, s2))
} }
func assertPassword(assert *assert.Assertions, cstore keys.Keybase, name, pass, badpass string) {
func assertPassword(assert *asrt.Assertions, cstore keys.Keybase, name, pass, badpass string) {
err := cstore.Update(name, badpass, pass) err := cstore.Update(name, badpass, pass)
assert.NotNil(err) assert.NotNil(err)
err = cstore.Update(name, pass, pass) err = cstore.Update(name, pass, pass)
@ -214,7 +214,7 @@ func assertPassword(assert *assert.Assertions, cstore keys.Keybase, name, pass,
// TestImportUnencrypted tests accepting raw priv keys bytes as input // TestImportUnencrypted tests accepting raw priv keys bytes as input
func TestImportUnencrypted(t *testing.T) { func TestImportUnencrypted(t *testing.T) {
require := require.New(t)
require := rqr.New(t)
// make the storage with reasonable defaults // make the storage with reasonable defaults
cstore := keys.New( cstore := keys.New(
@ -240,7 +240,7 @@ func TestImportUnencrypted(t *testing.T) {
// TestAdvancedKeyManagement verifies update, import, export functionality // TestAdvancedKeyManagement verifies update, import, export functionality
func TestAdvancedKeyManagement(t *testing.T) { func TestAdvancedKeyManagement(t *testing.T) {
assert, require := assert.New(t), require.New(t)
assert, require := asrt.New(t), rqr.New(t)
// make the storage with reasonable defaults // make the storage with reasonable defaults
cstore := keys.New( cstore := keys.New(
@ -283,7 +283,7 @@ func TestAdvancedKeyManagement(t *testing.T) {
// TestSeedPhrase verifies restoring from a seed phrase // TestSeedPhrase verifies restoring from a seed phrase
func TestSeedPhrase(t *testing.T) { func TestSeedPhrase(t *testing.T) {
assert, require := assert.New(t), require.New(t)
assert, require := asrt.New(t), rqr.New(t)
// make the storage with reasonable defaults // make the storage with reasonable defaults
cstore := keys.New( cstore := keys.New(


+ 6
- 6
keys/wordcodec_test.go View File

@ -3,14 +3,14 @@ package keys
import ( import (
"testing" "testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
asrt "github.com/stretchr/testify/assert"
rqr "github.com/stretchr/testify/require"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tmlibs/common"
) )
func TestLengthCalc(t *testing.T) { func TestLengthCalc(t *testing.T) {
assert := assert.New(t)
assert := asrt.New(t)
cases := []struct { cases := []struct {
bytes, words int bytes, words int
@ -50,7 +50,7 @@ func TestLengthCalc(t *testing.T) {
} }
func TestEncodeDecode(t *testing.T) { func TestEncodeDecode(t *testing.T) {
assert, require := assert.New(t), require.New(t)
assert, require := asrt.New(t), rqr.New(t)
codec, err := LoadCodec("english") codec, err := LoadCodec("english")
require.Nil(err, "%+v", err) require.Nil(err, "%+v", err)
@ -82,7 +82,7 @@ func TestEncodeDecode(t *testing.T) {
} }
func TestCheckInvalidLists(t *testing.T) { func TestCheckInvalidLists(t *testing.T) {
assert := assert.New(t)
assert := asrt.New(t)
trivial := []string{"abc", "def"} trivial := []string{"abc", "def"}
short := make([]string, 1234) short := make([]string, 1234)
@ -144,7 +144,7 @@ func getDiffWord(c *WordCodec, not string) string {
} }
func TestCheckTypoDetection(t *testing.T) { func TestCheckTypoDetection(t *testing.T) {
assert, require := assert.New(t), require.New(t)
assert, require := asrt.New(t), rqr.New(t)
banks := []string{"english", "spanish", "japanese", "chinese_simplified"} banks := []string{"english", "spanish", "japanese", "chinese_simplified"}


+ 5
- 5
nano/keys_test.go View File

@ -5,14 +5,14 @@ import (
"os" "os"
"testing" "testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
asrt "github.com/stretchr/testify/assert"
rqr "github.com/stretchr/testify/require"
crypto "github.com/tendermint/go-crypto" crypto "github.com/tendermint/go-crypto"
) )
func TestLedgerKeys(t *testing.T) { func TestLedgerKeys(t *testing.T) {
assert, require := assert.New(t), require.New(t)
assert, require := asrt.New(t), rqr.New(t)
cases := []struct { cases := []struct {
msg, pubkey, sig string msg, pubkey, sig string
@ -76,7 +76,7 @@ func TestLedgerKeys(t *testing.T) {
} }
func TestRealLedger(t *testing.T) { func TestRealLedger(t *testing.T) {
assert, require := assert.New(t), require.New(t)
assert, require := asrt.New(t), rqr.New(t)
if os.Getenv("WITH_LEDGER") == "" { if os.Getenv("WITH_LEDGER") == "" {
t.Skip("Set WITH_LEDGER to run code on real ledger") t.Skip("Set WITH_LEDGER to run code on real ledger")
@ -115,7 +115,7 @@ func TestRealLedger(t *testing.T) {
// TestRealLedgerErrorHandling calls. These tests assume // TestRealLedgerErrorHandling calls. These tests assume
// the ledger is not plugged in.... // the ledger is not plugged in....
func TestRealLedgerErrorHandling(t *testing.T) { func TestRealLedgerErrorHandling(t *testing.T) {
require := require.New(t)
require := rqr.New(t)
if os.Getenv("WITH_LEDGER") != "" { if os.Getenv("WITH_LEDGER") != "" {
t.Skip("Skipping on WITH_LEDGER as it tests unplugged cases") t.Skip("Skipping on WITH_LEDGER as it tests unplugged cases")


+ 5
- 4
nano/sign_test.go View File

@ -5,8 +5,9 @@ import (
"testing" "testing"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
asrt "github.com/stretchr/testify/assert"
rqr "github.com/stretchr/testify/require"
crypto "github.com/tendermint/go-crypto" crypto "github.com/tendermint/go-crypto"
) )
@ -29,7 +30,7 @@ func parseSig(data []byte) (key crypto.Signature, err error) {
} }
func TestParseDigest(t *testing.T) { func TestParseDigest(t *testing.T) {
assert, require := assert.New(t), require.New(t)
assert, require := asrt.New(t), rqr.New(t)
cases := []struct { cases := []struct {
output string output string
@ -91,7 +92,7 @@ func toBytes(c cryptoCase) (msg, key, sig []byte, err error) {
} }
func TestCryptoConvert(t *testing.T) { func TestCryptoConvert(t *testing.T) {
assert, require := assert.New(t), require.New(t)
assert, require := asrt.New(t), rqr.New(t)
cases := []cryptoCase{ cases := []cryptoCase{
0: { 0: {


+ 2
- 4
signature_test.go View File

@ -109,8 +109,6 @@ func TestSignatureEncodings(t *testing.T) {
} }
func TestWrapping(t *testing.T) { func TestWrapping(t *testing.T) {
assert := assert.New(t)
// construct some basic constructs // construct some basic constructs
msg := CRandBytes(128) msg := CRandBytes(128)
priv := GenPrivKeyEd25519() priv := GenPrivKeyEd25519()
@ -126,7 +124,7 @@ func TestWrapping(t *testing.T) {
} }
for _, p := range pubs { for _, p := range pubs {
_, ok := p.PubKeyInner.(PubKey) _, ok := p.PubKeyInner.(PubKey)
assert.False(ok)
assert.False(t, ok)
} }
sigs := []Signature{ sigs := []Signature{
@ -137,7 +135,7 @@ func TestWrapping(t *testing.T) {
} }
for _, s := range sigs { for _, s := range sigs {
_, ok := s.SignatureInner.(Signature) _, ok := s.SignatureInner.(Signature)
assert.False(ok)
assert.False(t, ok)
} }
} }

Loading…
Cancel
Save