-
Notifications
You must be signed in to change notification settings - Fork 8
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
Showing
10 changed files
with
634 additions
and
450 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package common | ||
|
||
import ( | ||
"github.com/smartcontractkit/chainlink-env/environment" | ||
"github.com/smartcontractkit/chainlink/integration-tests/client" | ||
) | ||
|
||
type ChainlinkClient struct { | ||
ChainlinkNodes []*client.Chainlink | ||
NodeKeys []client.NodeKeysBundle | ||
bTypeAttr *client.BridgeTypeAttributes | ||
bootstrapPeers []client.P2PData | ||
} | ||
|
||
// CreateKeys Creates node keys and defines chain and nodes for each node | ||
func NewChainlinkClient(env *environment.Environment, chainName string, chainId string, tendermintURL string) (*ChainlinkClient, error) { | ||
nodes, err := client.ConnectChainlinkNodes(env) | ||
if err != nil { | ||
return nil, err | ||
} | ||
nodeKeys, _, err := client.CreateNodeKeysBundle(nodes, chainName, chainId) | ||
if err != nil { | ||
return nil, err | ||
} | ||
for _, n := range nodes { | ||
_, _, err = n.CreateCosmosChain(&client.CosmosChainAttributes{ | ||
ChainID: chainId, | ||
Config: client.CosmosChainConfig{}, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
_, _, err = n.CreateCosmosNode(&client.CosmosNodeAttributes{ | ||
Name: chainName, | ||
CosmosChainID: chainId, | ||
TendermintURL: tendermintURL, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
return &ChainlinkClient{ | ||
ChainlinkNodes: nodes, | ||
NodeKeys: nodeKeys, | ||
}, nil | ||
} | ||
|
||
func (cc *ChainlinkClient) LoadOCR2Config(accountAddresses []string) (*OCR2Config, error) { | ||
var offChaiNKeys []string | ||
var onChaiNKeys []string | ||
var peerIds []string | ||
var txKeys []string | ||
var cfgKeys []string | ||
for i, key := range cc.NodeKeys { | ||
offChaiNKeys = append(offChaiNKeys, key.OCR2Key.Data.Attributes.OffChainPublicKey) | ||
peerIds = append(peerIds, key.PeerID) | ||
txKeys = append(txKeys, accountAddresses[i]) | ||
onChaiNKeys = append(onChaiNKeys, key.OCR2Key.Data.Attributes.OnChainPublicKey) | ||
cfgKeys = append(cfgKeys, key.OCR2Key.Data.Attributes.ConfigPublicKey) | ||
} | ||
|
||
var payload = TestOCR2Config | ||
payload.Signers = onChaiNKeys | ||
payload.Transmitters = txKeys | ||
payload.OffchainConfig.OffchainPublicKeys = offChaiNKeys | ||
payload.OffchainConfig.PeerIds = peerIds | ||
payload.OffchainConfig.ConfigPublicKeys = cfgKeys | ||
return &payload, nil | ||
} |
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,24 @@ | ||
package common | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/rs/zerolog" | ||
"github.com/stretchr/testify/require" | ||
|
||
envConf "github.com/smartcontractkit/chainlink-env/config" | ||
) | ||
|
||
// GetTestLogger TODO: This is a duplicate of the same function in chainlink-testing-framework. We should replace this with a call to the ctf version when chainlink-starknet is updated to use the latest ctf version. | ||
// GetTestLogger instantiates a logger that takes into account the test context and the log level | ||
func GetTestLogger(t *testing.T) zerolog.Logger { | ||
lvlStr := os.Getenv(envConf.EnvVarLogLevel) | ||
if lvlStr == "" { | ||
lvlStr = "info" | ||
} | ||
lvl, err := zerolog.ParseLevel(lvlStr) | ||
require.NoError(t, err, "error parsing log level") | ||
l := zerolog.New(zerolog.NewTestWriter(t)).Output(zerolog.ConsoleWriter{Out: os.Stderr}).Level(lvl).With().Timestamp().Logger() | ||
return l | ||
} |
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,105 @@ | ||
package common | ||
|
||
import ( | ||
"math/big" | ||
) | ||
|
||
// OCR2Config Default config for OCR2 for starknet | ||
// TODO: validate for cosmos | ||
type OCR2Config struct { | ||
F int `json:"f"` | ||
Signers []string `json:"signers"` | ||
Transmitters []string `json:"transmitters"` | ||
OnchainConfig string `json:"onchainConfig"` | ||
OffchainConfig *OffchainConfig `json:"offchainConfig"` | ||
OffchainConfigVersion int `json:"offchainConfigVersion"` | ||
Secret string `json:"secret"` | ||
} | ||
|
||
type OffchainConfig struct { | ||
DeltaProgressNanoseconds int64 `json:"deltaProgressNanoseconds"` | ||
DeltaResendNanoseconds int64 `json:"deltaResendNanoseconds"` | ||
DeltaRoundNanoseconds int64 `json:"deltaRoundNanoseconds"` | ||
DeltaGraceNanoseconds int `json:"deltaGraceNanoseconds"` | ||
DeltaStageNanoseconds int64 `json:"deltaStageNanoseconds"` | ||
RMax int `json:"rMax"` | ||
S []int `json:"s"` | ||
OffchainPublicKeys []string `json:"offchainPublicKeys"` | ||
PeerIds []string `json:"peerIds"` | ||
ReportingPluginConfig *ReportingPluginConfig `json:"reportingPluginConfig"` | ||
MaxDurationQueryNanoseconds int `json:"maxDurationQueryNanoseconds"` | ||
MaxDurationObservationNanoseconds int `json:"maxDurationObservationNanoseconds"` | ||
MaxDurationReportNanoseconds int `json:"maxDurationReportNanoseconds"` | ||
MaxDurationShouldAcceptFinalizedReportNanoseconds int `json:"maxDurationShouldAcceptFinalizedReportNanoseconds"` | ||
MaxDurationShouldTransmitAcceptedReportNanoseconds int `json:"maxDurationShouldTransmitAcceptedReportNanoseconds"` | ||
ConfigPublicKeys []string `json:"configPublicKeys"` | ||
} | ||
|
||
type ReportingPluginConfig struct { | ||
AlphaReportInfinite bool `json:"alphaReportInfinite"` | ||
AlphaReportPpb int `json:"alphaReportPpb"` | ||
AlphaAcceptInfinite bool `json:"alphaAcceptInfinite"` | ||
AlphaAcceptPpb int `json:"alphaAcceptPpb"` | ||
DeltaCNanoseconds int `json:"deltaCNanoseconds"` | ||
} | ||
|
||
var TestOCR2Config = OCR2Config{ | ||
F: 1, | ||
// Signers: onChainKeys, // user defined | ||
// Transmitters: txKeys, // user defined | ||
OnchainConfig: "", | ||
OffchainConfig: &OffchainConfig{ | ||
DeltaProgressNanoseconds: 8000000000, | ||
DeltaResendNanoseconds: 30000000000, | ||
DeltaRoundNanoseconds: 3000000000, | ||
DeltaGraceNanoseconds: 1000000000, | ||
DeltaStageNanoseconds: 20000000000, | ||
RMax: 5, | ||
S: []int{1, 2}, | ||
// OffchainPublicKeys: offChainKeys, // user defined | ||
// PeerIds: peerIds, // user defined | ||
ReportingPluginConfig: &ReportingPluginConfig{ | ||
AlphaReportInfinite: false, | ||
AlphaReportPpb: 0, | ||
AlphaAcceptInfinite: false, | ||
AlphaAcceptPpb: 0, | ||
DeltaCNanoseconds: 1000000000, | ||
}, | ||
MaxDurationQueryNanoseconds: 2000000000, | ||
MaxDurationObservationNanoseconds: 1000000000, | ||
MaxDurationReportNanoseconds: 2000000000, | ||
MaxDurationShouldAcceptFinalizedReportNanoseconds: 2000000000, | ||
MaxDurationShouldTransmitAcceptedReportNanoseconds: 2000000000, | ||
// ConfigPublicKeys: cfgKeys, // user defined | ||
}, | ||
OffchainConfigVersion: 2, | ||
Secret: "awe accuse polygon tonic depart acuity onyx inform bound gilbert expire", | ||
} | ||
|
||
var TestOnKeys = []string{ | ||
"0x04cc1bfa99e282e434aef2815ca17337a923cd2c61cf0c7de5b326d7a8603730", | ||
"0x04cc1bfa99e282e434aef2815ca17337a923cd2c61cf0c7de5b326d7a8603731", | ||
"0x04cc1bfa99e282e434aef2815ca17337a923cd2c61cf0c7de5b326d7a8603732", | ||
"0x04cc1bfa99e282e434aef2815ca17337a923cd2c61cf0c7de5b326d7a8603733", | ||
} | ||
|
||
var TestTxKeys = []string{ | ||
"0x04cc1bfa99e282e434aef2815ca17337a923cd2c61cf0c7de5b326d7a8603734", | ||
"0x04cc1bfa99e282e434aef2815ca17337a923cd2c61cf0c7de5b326d7a8603735", | ||
"0x04cc1bfa99e282e434aef2815ca17337a923cd2c61cf0c7de5b326d7a8603736", | ||
"0x04cc1bfa99e282e434aef2815ca17337a923cd2c61cf0c7de5b326d7a8603737", | ||
} | ||
|
||
var TestOffKeys = []string{ | ||
"af400004fa5d02cd5170b5261032e71f2847ead36159cf8dee68affc3c852090", | ||
"af400004fa5d02cd5170b5261032e71f2847ead36159cf8dee68affc3c852091", | ||
"af400004fa5d02cd5170b5261032e71f2847ead36159cf8dee68affc3c852092", | ||
"af400004fa5d02cd5170b5261032e71f2847ead36159cf8dee68affc3c852093", | ||
} | ||
|
||
var TestCfgKeys = []string{ | ||
"af400004fa5d02cd5170b5261032e71f2847ead36159cf8dee68affc3c852094", | ||
"af400004fa5d02cd5170b5261032e71f2847ead36159cf8dee68affc3c852095", | ||
"af400004fa5d02cd5170b5261032e71f2847ead36159cf8dee68affc3c852096", | ||
"af400004fa5d02cd5170b5261032e71f2847ead36159cf8dee68affc3c852097", | ||
} |
Oops, something went wrong.