-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextendedsecretkey_test.go
More file actions
28 lines (20 loc) · 925 Bytes
/
extendedsecretkey_test.go
File metadata and controls
28 lines (20 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package ergo
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestExtendedSecretKey(t *testing.T) {
seedStr := "chef hidden swift slush bar length outdoor pupil hunt country endorse accuse"
seed := MnemonicToSeed(seedStr, "")
root, rootErr := DeriveMaster(seed)
assert.NoError(t, rootErr)
changePath, derivationPathErr := NewDerivationPath(0, []uint32{0})
assert.NoError(t, derivationPathErr)
changeSecret, deriveErr := root.Derive(changePath)
assert.NoError(t, deriveErr)
assert.Equal(t, "9hRTUYF37avZvhC5FG7VoSfrfWQgRMubrA4xLqwFBfes743691r", changeSecret.ExtendedPublicKey().Address().Base58(MainnetPrefix))
nextChangePath, _ := changePath.Next()
nextChangeSecret, nextDeriveErr := root.Derive(nextChangePath)
assert.NoError(t, nextDeriveErr)
assert.Equal(t, "9gYRhhA9TcFv6xWGwTBPLBJzyW1Hv3EiDzXqoivWYjq8TowWJ1h", nextChangeSecret.ExtendedPublicKey().Address().Base58(MainnetPrefix))
}