Skip to content

Commit c5e7cb7

Browse files
committed
Update test
1 parent 75e088b commit c5e7cb7

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

hdwallet_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ func TestIssue172(t *testing.T) {
3636

3737
// Derive the old (wrong way)
3838
account, err := getWallet().Derive(path, false)
39+
if err != nil {
40+
t.Error(err)
41+
}
3942

4043
if account.Address.Hex() != "0x3943412CBEEEd4b68d73382b136F36b0CB82F481" {
4144
t.Error("wrong address")
@@ -44,6 +47,10 @@ func TestIssue172(t *testing.T) {
4447
// Set envar to non-zero length to derive correctly
4548
os.Setenv(issue179FixEnvar, "1")
4649
account, err = getWallet().Derive(path, false)
50+
if err != nil {
51+
t.Error(err)
52+
}
53+
4754
if account.Address.Hex() != "0x98e440675eFF3041D20bECb7fE7e81746A431b6d" {
4855
t.Error("wrong address")
4956
}
@@ -53,6 +60,9 @@ func TestIssue172(t *testing.T) {
5360
wallet := getWallet()
5461
wallet.SetFixIssue172(true)
5562
account, err = wallet.Derive(path, false)
63+
if err != nil {
64+
t.Error(err)
65+
}
5666

5767
if account.Address.Hex() != "0x98e440675eFF3041D20bECb7fE7e81746A431b6d" {
5868
t.Error("wrong address")
@@ -325,6 +335,8 @@ func TestWallet(t *testing.T) {
325335
}
326336

327337
mnemonic, err = NewMnemonicFromEntropy(entropy)
338+
_ = mnemonic
339+
328340
if err != nil {
329341
t.Error(err)
330342
}
@@ -333,3 +345,25 @@ func TestWallet(t *testing.T) {
333345
t.Error("expected 12 words")
334346
}
335347
}
348+
349+
func TestWalletWithPassword(t *testing.T) {
350+
mnemonic := "tag volcano eight thank tide danger coast health above argue embrace heavy"
351+
wallet, err := NewFromMnemonic(mnemonic, "mysecret")
352+
if err != nil {
353+
t.Error(err)
354+
}
355+
356+
path, err := ParseDerivationPath("m/44'/60'/0'/0/0")
357+
if err != nil {
358+
t.Error(err)
359+
}
360+
361+
account, err := wallet.Derive(path, false)
362+
if err != nil {
363+
t.Error(err)
364+
}
365+
366+
if account.Address.Hex() != "0x2C0572B541D72F7078A28597fE8b1997437E885a" {
367+
t.Error("wrong address")
368+
}
369+
}

0 commit comments

Comments
 (0)