-
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: "CPGPz5KFeFkNlx7rkKwyfCCof1kghlY15Gf6yUzrMxM=", valid: true}, | ||
{mnemonic: "equip will roof matter pink blind book anxiety banner elbow sun young", num: 2, pubkey: "DHym/Mo3e1nCMclw/eSSlU4OWf+h2ePpkrD3HR8kWzY=", valid: true}, | ||
{mnemonic: "equip will roof matter pink blind book anxiety banner elbow sun young", num: 3, pubkey: "hhaCSH9yzK9HxuiErQpahQKMatAVXALdE215qcgd9DM=", 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) | ||
} | ||
} | ||
} |