add test to NewKeyFromString for empty and zeroed extended key
This commit is contained in:
parent
1b747bcbc7
commit
4fabcca216
|
@ -438,6 +438,7 @@ func TestErrors(t *testing.T) {
|
||||||
err error
|
err error
|
||||||
neuter bool
|
neuter bool
|
||||||
neuterErr error
|
neuterErr error
|
||||||
|
extKey *ExtendedKey
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "invalid key length",
|
name: "invalid key length",
|
||||||
|
@ -461,6 +462,22 @@ func TestErrors(t *testing.T) {
|
||||||
neuter: true,
|
neuter: true,
|
||||||
neuterErr: chaincfg.ErrUnknownHDKeyID,
|
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 {
|
for i, test := range tests {
|
||||||
|
@ -477,6 +494,13 @@ func TestErrors(t *testing.T) {
|
||||||
continue
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue