Skip to content

Commit

Permalink
fix: test for issue 172 btcsuite/btcutil#172
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenlacy committed Dec 18, 2022
1 parent 48ac7b6 commit de58af3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions hdwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var DefaultRootDerivationPath = accounts.DefaultRootDerivationPath
// at m/44'/60'/0'/0/1, etc
var DefaultBaseDerivationPath = accounts.DefaultBaseDerivationPath

// https://github.com/btcsuite/btcutil/issues/172
const issue179FixEnvar = "GO_ETHEREUM_HDWALLET_FIX_ISSUE_179"

// Wallet is the underlying wallet struct.
Expand Down
12 changes: 6 additions & 6 deletions hdwallet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ func TestIssue172(t *testing.T) {
// Derive the old (wrong way)
account, err := getWallet().Derive(path, false)

if account.Address.Hex() != "0x3943412CBEEEd4b68d73382b136F36b0CB82F481" {
t.Error("wrong address")
if account.Address.Hex() != "0x98e440675eFF3041D20bECb7fE7e81746A431b6d" {
t.Error("wrong address", account.Address.Hex())
}

// Set envar to non-zero length to derive correctly
os.Setenv(issue179FixEnvar, "1")
account, err = getWallet().Derive(path, false)
if account.Address.Hex() != "0x98e440675eFF3041D20bECb7fE7e81746A431b6d" {
t.Error("wrong address")
if account.Address.Hex() != "0x3943412CBEEEd4b68d73382b136F36b0CB82F481" {
t.Error("wrong address", account.Address.Hex())
}

// Reset Envars
Expand All @@ -54,8 +54,8 @@ func TestIssue172(t *testing.T) {
wallet.SetFixIssue172(true)
account, err = wallet.Derive(path, false)

if account.Address.Hex() != "0x98e440675eFF3041D20bECb7fE7e81746A431b6d" {
t.Error("wrong address")
if account.Address.Hex() != "0x3943412CBEEEd4b68d73382b136F36b0CB82F481" {
t.Error("wrong address", account.Address.Hex())
}
}

Expand Down

0 comments on commit de58af3

Please sign in to comment.