add test to NewKeyFromString for empty and zeroed extended key

This commit is contained in:
Andrea Franz 2018-03-14 13:18:13 +01:00
parent 1b747bcbc7
commit 4fabcca216
No known key found for this signature in database
GPG Key ID: 4F0D2F2D9DE7F29D
1 changed files with 24 additions and 0 deletions

View File

@ -438,6 +438,7 @@ func TestErrors(t *testing.T) {
err error
neuter bool
neuterErr error
extKey *ExtendedKey
}{
{
name: "invalid key length",
@ -461,6 +462,22 @@ func TestErrors(t *testing.T) {
neuter: true,
neuterErr: chaincfg.ErrUnknownHDKeyID,
},
{
name: "zeroed extended key",
key: EmptyExtendedKeyString,
err: nil,
neuter: false,
neuterErr: nil,
extKey: &ExtendedKey{},
},
{
name: "empty string",
key: "",
err: nil,
neuter: false,
neuterErr: nil,
extKey: &ExtendedKey{},
},
}
for i, test := range tests {
@ -477,6 +494,13 @@ func TestErrors(t *testing.T) {
continue
}
}
if test.extKey != nil {
if !reflect.DeepEqual(extKey, test.extKey) {
t.Errorf("ExtKey #%d (%s): mismatched extended key -- got: %+v, want: %+v", i, test.name, extKey, test.extKey)
continue
}
}
}
}