forked from gagliardetto/solana-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added capabilities to read private key generated by `solana-keygen ne…
…w` command line
- Loading branch information
Matthieu Vachon
committed
Dec 11, 2020
1 parent
4e3f16d
commit 98efad3
Showing
4 changed files
with
72 additions
and
20 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
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,38 @@ | ||
package solana | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestPrivateKeyFromSolanaKeygenFile(t *testing.T) { | ||
tests := []struct { | ||
inFile string | ||
expected PrivateKey | ||
expectedPub PublicKey | ||
expectedErr error | ||
}{ | ||
{ | ||
"testdata/standard.solana-keygen.json", | ||
MustPrivateKeyFromBase58("66cDvko73yAf8LYvFMM3r8vF5vJtkk7JKMgEKwkmBC86oHdq41C7i1a2vS3zE1yCcdLLk6VUatUb32ZzVjSBXtRs"), | ||
MustPublicKeyFromBase58("F8UvVsKnzWyp2nF8aDcqvQ2GVcRpqT91WDsAtvBKCMt9"), | ||
nil, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.inFile, func(t *testing.T) { | ||
actual, err := PrivateKeyFromSolanaKeygenFile(test.inFile) | ||
if test.expectedErr == nil { | ||
require.NoError(t, err) | ||
assert.Equal(t, test.expected, actual) | ||
assert.Equal(t, test.expectedPub, actual.PublicKey(), "%s != %s", test.expectedPub, actual.PublicKey()) | ||
|
||
} else { | ||
assert.Equal(t, test.expectedErr, err) | ||
} | ||
}) | ||
} | ||
} |
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 @@ | ||
[254,235,166,85,112,29,132,16,126,87,234,58,144,120,98,141,75,133,85,10,31,71,74,147,81,189,128,180,112,21,110,62,209,238,65,42,248,12,152,28,130,46,170,32,19,8,11,29,255,208,207,18,123,131,230,60,249,157,68,133,246,187,45,62] |