You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
chantools/cmd/chantools/showrootkey_test.go

61 lines
1.2 KiB
Go

package main
import (
"testing"
"github.com/guggero/chantools/btc"
"github.com/guggero/chantools/lnd"
"github.com/stretchr/testify/require"
)
func TestShowRootKey(t *testing.T) {
h := newHarness(t)
// Derive the root key from the aezeed.
show := &showRootKeyCommand{
rootKey: &rootKey{},
}
t.Setenv(lnd.MnemonicEnvName, seedAezeedNoPassphrase)
t.Setenv(lnd.PassphraseEnvName, "-")
err := show.Execute(nil, nil)
require.NoError(t, err)
h.assertLogContains(rootKeyAezeed)
}
func TestShowRootKeyBIP39(t *testing.T) {
h := newHarness(t)
// Derive the root key from the BIP39 seed.
show := &showRootKeyCommand{
rootKey: &rootKey{BIP39: true},
}
t.Setenv(btc.BIP39MnemonicEnvName, seedBip39)
t.Setenv(btc.BIP39PassphraseEnvName, "-")
err := show.Execute(nil, nil)
require.NoError(t, err)
h.assertLogContains(rootKeyBip39)
}
func TestShowRootKeyBIP39WithPassphrase(t *testing.T) {
h := newHarness(t)
// Derive the root key from the BIP39 seed.
show := &showRootKeyCommand{
rootKey: &rootKey{BIP39: true},
}
t.Setenv(btc.BIP39MnemonicEnvName, seedBip39)
t.Setenv(btc.BIP39PassphraseEnvName, testPassPhrase)
err := show.Execute(nil, nil)
require.NoError(t, err)
h.assertLogContains(rootKeyBip39Passphrase)
}