mirror of https://github.com/guggero/chantools
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.
68 lines
1.4 KiB
Go
68 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"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{},
|
|
}
|
|
|
|
err := os.Setenv(lnd.MnemonicEnvName, seedAezeedNoPassphrase)
|
|
require.NoError(t, err)
|
|
err = os.Setenv(lnd.PassphraseEnvName, "-")
|
|
require.NoError(t, err)
|
|
|
|
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},
|
|
}
|
|
|
|
err := os.Setenv(btc.BIP39MnemonicEnvName, seedBip39)
|
|
require.NoError(t, err)
|
|
err = os.Setenv(btc.BIP39PassphraseEnvName, "-")
|
|
require.NoError(t, err)
|
|
|
|
err = show.Execute(nil, nil)
|
|
require.NoError(t, err)
|
|
|
|
h.assertLogContains(rootKeyBip39)
|
|
}
|
|
|
|
func TestShowRootKeyBIP39WithPassphre(t *testing.T) {
|
|
h := newHarness(t)
|
|
|
|
// Derive the root key from the BIP39 seed.
|
|
show := &showRootKeyCommand{
|
|
rootKey: &rootKey{BIP39: true},
|
|
}
|
|
|
|
err := os.Setenv(btc.BIP39MnemonicEnvName, seedBip39)
|
|
require.NoError(t, err)
|
|
err = os.Setenv(btc.BIP39PassphraseEnvName, testPassPhrase)
|
|
require.NoError(t, err)
|
|
|
|
err = show.Execute(nil, nil)
|
|
require.NoError(t, err)
|
|
|
|
h.assertLogContains(rootKeyBip39Passphrase)
|
|
}
|