Skip to content

Commit

Permalink
Fix key decoding in ocr3config test
Browse files Browse the repository at this point in the history
  • Loading branch information
archseer committed Nov 22, 2024
1 parent 73835e1 commit a29c805
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions deployment/keystone/ocr3config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ import (
"encoding/json"
"os"
"sort"
"strings"
"testing"

"github.com/ethereum/go-ethereum/common"
chain_selectors "github.com/smartcontractkit/chain-selectors"
"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/common/view"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey"
types2 "github.com/smartcontractkit/libocr/offchainreporting2/types"
"github.com/smartcontractkit/libocr/offchainreporting2plus/types"
types3 "github.com/smartcontractkit/libocr/offchainreporting2plus/types"
"github.com/test-go/testify/require"
)

Expand Down Expand Up @@ -121,16 +124,33 @@ func loadTestData(t *testing.T, path string) []deployment.Node {
AdminAddr: nv.PayeeAddress,
}
for chain, ocrKey := range nv.OCRKeys {
// TODO: this decoding could be shared with NodeInfo
p, err := p2pkey.MakePeerID(ocrKey.PeerID)
require.NoError(t, err)

b := common.Hex2Bytes(ocrKey.OffchainPublicKey)
var opk types2.OffchainPublicKey
copy(opk[:], b)

b = common.Hex2Bytes(ocrKey.ConfigEncryptionPublicKey)
var cpk types3.ConfigEncryptionPublicKey
copy(cpk[:], b)

var pubkey types3.OnchainPublicKey
if strings.HasPrefix(chain, "ethereum") {
// convert from pubkey to address
pubkey = common.HexToAddress(ocrKey.OnchainPublicKey).Bytes()
} else {
pubkey = common.Hex2Bytes(ocrKey.OnchainPublicKey)
}

ocrCfg := deployment.OCRConfig{
KeyBundleID: ocrKey.KeyBundleID,
OffchainPublicKey: types2.OffchainPublicKey([]byte(ocrKey.OffchainPublicKey)),
OnchainPublicKey: types2.OnchainPublicKey(ocrKey.OnchainPublicKey),
OffchainPublicKey: opk,
OnchainPublicKey: pubkey,
PeerID: p,
TransmitAccount: types.Account(ocrKey.TransmitAccount),
ConfigEncryptionPublicKey: types2.ConfigEncryptionPublicKey([]byte(ocrKey.ConfigEncryptionPublicKey)),
ConfigEncryptionPublicKey: cpk,
}
var k chain_selectors.ChainDetails
switch chain {
Expand Down

0 comments on commit a29c805

Please sign in to comment.