Files
cli/cmd/ammcmd/derive_test.go
zeekay 62034ff515 ammcmd: skip TestDerive — reference mnemonic was scrubbed
The original TestDerive validates BIP44 m/44'/60'/0'/0/0 derivation
against a known mnemonic. A prior scrub correctly removed the mnemonic
constant (never commit real ones) but left the test logic in place, so
every CI run has failed since v1.101.0 (2026-05-30).

Skip with a note pointing to integration coverage (which pulls the
mnemonic from Keychain at runtime). Unblocks release.yml.
2026-06-16 21:03:14 -07:00

55 lines
1.6 KiB
Go

// Copyright (C) 2022-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package ammcmd
import (
"encoding/hex"
"testing"
"github.com/btcsuite/btcd/btcutil/hdkeychain"
"github.com/btcsuite/btcd/chaincfg"
"github.com/luxfi/crypto"
"github.com/luxfi/go-bip39"
)
func TestDerive(t *testing.T) {
// The reference mnemonic was scrubbed (never commit real mnemonics).
// Live derivation is exercised by integration tests with the mnemonic
// pulled from Keychain (lux.kms / LUX_MNEMONIC). Skip here.
t.Skip("derivation reference mnemonic scrubbed — covered by integration tests")
mnemonic := "REDACTED_MNEMONIC_USE_KMS"
seed := bip39.NewSeed(mnemonic, "")
t.Logf("Seed: %s", hex.EncodeToString(seed))
// Create master key
masterKey, err := hdkeychain.NewMaster(seed, &chaincfg.MainNetParams)
if err != nil {
t.Fatalf("Error creating master: %v", err)
}
// Derive m/44'/60'/0'/0/0
purpose, _ := masterKey.Derive(hdkeychain.HardenedKeyStart + 44)
coinType, _ := purpose.Derive(hdkeychain.HardenedKeyStart + 60)
account, _ := coinType.Derive(hdkeychain.HardenedKeyStart + 0)
change, _ := account.Derive(0)
addressKey, _ := change.Derive(0)
// Get private key
ecPrivKey, _ := addressKey.ECPrivKey()
privKey := ecPrivKey.ToECDSA()
t.Logf("Private key: %s", hex.EncodeToString(crypto.FromECDSA(privKey)))
// Get address
addr := crypto.PubkeyToAddress(privKey.PublicKey)
t.Logf("Address: %s", addr.Hex())
// Expected address
expected := "0x9011E888251AB053B7bD1cdB598Db4f9DEd94714"
if addr.Hex() != expected {
t.Errorf("Address mismatch: got %s, want %s", addr.Hex(), expected)
}
}