-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(wallet): Add file-based sr25519-adr8 support
- Loading branch information
Showing
2 changed files
with
109 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package file | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestSr25519FromMnemonic(t *testing.T) { | ||
mnemonics := []struct { | ||
mnemonic string | ||
num uint32 | ||
pubkey string | ||
valid bool | ||
}{ | ||
{mnemonic: "equip will roof matter pink blind book anxiety banner elbow sun young", num: 0, pubkey: "vP1R5MMzR/r9ricymYpPbBA9JvmlixdzlEYWEpx5ExY=", valid: true}, | ||
{mnemonic: "equip will roof matter pink blind book anxiety banner elbow sun young", num: 1, pubkey: "Ql96gaTGV7o0QzQbvPBSQfRT5K9PtBNLrxEh9kMV228=", valid: true}, | ||
{mnemonic: "equip will roof matter pink blind book anxiety banner elbow sun young", num: 2, pubkey: "qhbwbWt9k+3SW+68NxXq3knl2jokiGpc11DoKOrjTjo=", valid: true}, | ||
{mnemonic: "equip will roof matter pink blind book anxiety banner elbow sun young", num: 3, pubkey: "skCcMfU7D0olbxZtn8lLn0u41rJzxiCw7rcv3uVEw3Y=", valid: true}, | ||
{mnemonic: "actorr want explain gravity body drill bike update mask wool tell seven", pubkey: "", valid: false}, | ||
{mnemonic: "actor want explain gravity body drill bike update mask wool tell", pubkey: "", valid: false}, | ||
{mnemonic: "", pubkey: "", valid: false}, | ||
} | ||
|
||
for _, m := range mnemonics { | ||
if m.valid { | ||
signer, err := Sr25519FromMnemonic(m.mnemonic, m.num) | ||
require.NoError(t, err) | ||
require.Equal(t, m.pubkey, signer.Public().String()) | ||
} else { | ||
_, err := Sr25519FromMnemonic(m.mnemonic, 0) | ||
require.Error(t, err) | ||
} | ||
} | ||
} |