-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c1c0d1d
commit 6af33e3
Showing
10 changed files
with
77 additions
and
15 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,37 @@ | ||
package ocr2key | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/smartcontractkit/chainlink/core/services/keystore/chaintype" | ||
"github.com/smartcontractkit/chainlink/core/utils" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestExport(t *testing.T) { | ||
var tt = []struct { | ||
chain chaintype.ChainType | ||
}{ | ||
{chain: chaintype.EVM}, | ||
{chain: chaintype.Terra}, | ||
{chain: chaintype.Solana}, | ||
} | ||
for _, tc := range tt { | ||
tc := tc | ||
t.Run(string(tc.chain), func(t *testing.T) { | ||
kb, err := New(tc.chain) | ||
require.NoError(t, err) | ||
ej, err := ToEncryptedJSON(kb, "blah", utils.FastScryptParams) | ||
require.NoError(t, err) | ||
kbAfter, err := FromEncryptedJSON(ej, "blah") | ||
assert.Equal(t, kbAfter.ID(), kb.ID()) | ||
assert.Equal(t, kbAfter.PublicKey(), kb.PublicKey()) | ||
assert.Equal(t, kbAfter.OffchainPublicKey(), kb.OffchainPublicKey()) | ||
assert.Equal(t, kbAfter.MaxSignatureLength(), kb.MaxSignatureLength()) | ||
assert.Equal(t, kbAfter.Raw(), kb.Raw()) | ||
assert.Equal(t, kbAfter.ConfigEncryptionPublicKey(), kb.ConfigEncryptionPublicKey()) | ||
assert.Equal(t, kbAfter.ChainType(), kb.ChainType()) | ||
}) | ||
} | ||
} |
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
18 changes: 18 additions & 0 deletions
18
core/services/keystore/keys/ocr2key/offchain_keyring_test.go
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,18 @@ | ||
package ocr2key | ||
|
||
import ( | ||
"bytes" | ||
"crypto/ed25519" | ||
cryptorand "crypto/rand" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestOffchainKeyring(t *testing.T) { | ||
kr, err := newOffchainKeyring(cryptorand.Reader, cryptorand.Reader) | ||
require.NoError(t, err) | ||
pubKey := kr.OffchainPublicKey() | ||
assert.True(t, bytes.Equal(kr.signingKey.Public().(ed25519.PublicKey), pubKey[:])) | ||
} |
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
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