check / check (push) Successful in 52s
REPO_POLICIES.md sets the Go module root to sneak.berlin/go/<name>. go.mod, every import of the old path and the -X path in the Makefile LDFLAGS now use sneak.berlin/go/keyfunc; make fmt moved those imports to their new place in the sort order. The old path keeps no alias. The README gives the go install line next to the build from a clone and drops this issue from its TODO list, which now names the open 1.0 issues. Model: opus-5-5
62 lines
1.4 KiB
Go
62 lines
1.4 KiB
Go
package derive_test
|
|
|
|
import (
|
|
"bytes"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"sneak.berlin/go/keyfunc/internal/derive"
|
|
)
|
|
|
|
// application is the number the SSH key type uses.
|
|
const application = 838372
|
|
|
|
// example returns the mnemonic every BIP-39 document uses to show its
|
|
// test vectors: eleven abandons and about.
|
|
func example() string {
|
|
return strings.Repeat("abandon ", 11) + "about"
|
|
}
|
|
|
|
func TestPathIsTheOneTheSpecificationGives(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
require.Equal(t, "m/83696968'/838372'/3'", derive.Path(application, 3))
|
|
}
|
|
|
|
func TestEveryIndexGivesItsOwnBytes(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
first, err := derive.Bytes(example(), application, 0)
|
|
require.NoError(t, err)
|
|
require.Len(t, first, derive.Size)
|
|
|
|
second, err := derive.Bytes(example(), application, 1)
|
|
require.NoError(t, err)
|
|
require.Len(t, second, derive.Size)
|
|
|
|
require.False(t, bytes.Equal(first, second))
|
|
}
|
|
|
|
func TestAnIndexWithNoHardenedChildIsRefused(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
_, err := derive.Bytes(example(), application, derive.MaxIndex+1)
|
|
require.ErrorIs(t, err, derive.ErrIndexTooLarge)
|
|
|
|
_, err = derive.Bytes(example(), application, derive.MaxIndex)
|
|
require.NoError(t, err)
|
|
}
|
|
|
|
func TestTheSameInputAlwaysGivesTheSameBytes(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
once, err := derive.Bytes(example(), application, 7)
|
|
require.NoError(t, err)
|
|
|
|
again, err := derive.Bytes(example(), application, 7)
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, once, again)
|
|
}
|