From e513dcfcf73bf4be8b42921305eb130141329689 Mon Sep 17 00:00:00 2001 From: Rob De Feo Date: Mon, 10 Jan 2022 22:29:47 +0000 Subject: [PATCH] test: tidy and add test (#752) * test: remove reflect * test: add additional test without a passphrase --- crypto/ed25519/private_test.go | 3 +-- internal/keystore/kdf/scrypt/scrypt_test.go | 10 +++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/crypto/ed25519/private_test.go b/crypto/ed25519/private_test.go index 0aaf51e28..688f83b12 100644 --- a/crypto/ed25519/private_test.go +++ b/crypto/ed25519/private_test.go @@ -4,7 +4,6 @@ import ( "bytes" "crypto/rand" "io" - "reflect" "testing" "testing/iotest" @@ -97,7 +96,7 @@ func TestPrivateKeyFromBytes(t *testing.T) { t.Errorf("PrivateKeyFromBytes() error = %v, wantErr %v", err, tt.wantErr) return } - if !reflect.DeepEqual(got, tt.want) { + if !assert.Equal(t, tt.want, got) { t.Errorf("PrivateKeyFromBytes() = %v, want %v", got, tt.want) } }) diff --git a/internal/keystore/kdf/scrypt/scrypt_test.go b/internal/keystore/kdf/scrypt/scrypt_test.go index b9126bc93..6439c03a8 100644 --- a/internal/keystore/kdf/scrypt/scrypt_test.go +++ b/internal/keystore/kdf/scrypt/scrypt_test.go @@ -99,13 +99,21 @@ func TestDeriveKey(t *testing.T) { wantErr bool }{ { - "success", + "success-passphrase", args{ []DeriveOptionsBuilder{WithPassphrase("passphrase"), DefaultDeriveOptions()}, }, []byte{0x14, 0x64, 0xbb, 0x68, 0x5d, 0xd1, 0x6a, 0xef, 0xe9, 0x1a, 0xe1, 0x34, 0x6d, 0x3d, 0x9a, 0x60, 0x2, 0x43, 0x1a, 0x5a, 0x1b, 0xc2, 0xde, 0xa6, 0x23, 0x35, 0xef, 0xc8, 0xad, 0x1f, 0x60, 0x1b}, false, }, + { + "success-no-passphrase", + args{ + []DeriveOptionsBuilder{DefaultDeriveOptions()}, + }, + []byte{0xae, 0x51, 0xe1, 0x6a, 0x25, 0x28, 0x52, 0x2f, 0x1c, 0x61, 0x85, 0xcc, 0xed, 0xb4, 0xba, 0xb, 0x96, 0xbc, 0x3, 0x32, 0x86, 0x17, 0x2, 0x65, 0x9d, 0x26, 0xf2, 0x6c, 0x54, 0x83, 0xc2, 0xe6}, + false, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {