From a29c80550b26de1d8ff19df307b9b27dd8fdf674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Fri, 22 Nov 2024 15:17:30 +0900 Subject: [PATCH] Fix key decoding in ocr3config test --- deployment/keystone/ocr3config_test.go | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/deployment/keystone/ocr3config_test.go b/deployment/keystone/ocr3config_test.go index a8849615a29..c3146605822 100644 --- a/deployment/keystone/ocr3config_test.go +++ b/deployment/keystone/ocr3config_test.go @@ -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" ) @@ -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 {