Skip to content

Commit

Permalink
linter
Browse files Browse the repository at this point in the history
  • Loading branch information
krehermann committed Sep 6, 2024
1 parent 4859068 commit 0099c5b
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 59 deletions.
41 changes: 0 additions & 41 deletions integration-tests/deployment/clo/don_nodeset.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,50 +57,9 @@ func ProductFilterGenerator(p models.ProductType) FilterFuncT[*models.Node] {
}
}

func categoryNameFilterGenerator(name string) FilterFuncT[*models.Node] {
return func(n *models.Node) bool {
for _, cat := range n.Categories {
if cat.Name == name {
return true
}
}
return false
}
}

func publicKeyFilterGenerator(pubKey ...string) FilterFuncT[*models.Node] {
return func(n *models.Node) bool {
if n.PublicKey == nil {
return false
}
found := false
for _, key := range pubKey {
if *n.PublicKey == key {
found = true
break
}
}
return found
}
}

// this could be generalized to a regex filter
func NodeNameFilterGenerator(contains string) FilterFuncT[*models.Node] {
return func(n *models.Node) bool {
return strings.Contains(n.Name, contains)
}
}

// this is hacky
var chainWriterFilter = NodeNameFilterGenerator("Keystone Cap One")

func keystoneNopFilter(nop *models.NodeOperator) bool {
nodeFilter := categoryNameFilterGenerator("Keystone")
//isKeystoneNop := false
for _, node := range nop.Nodes {
if nodeFilter(node) {
return true
}
}
return false
}
4 changes: 2 additions & 2 deletions integration-tests/deployment/clo/don_nodeset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ func TestDonNodeset(t *testing.T) {
if updateTestData {
b, err := json.MarshalIndent(m["workflow"], "", " ")
require.NoError(t, err)
require.NoError(t, os.WriteFile("testdata/workflow_nodes.json", b, 0644))
require.NoError(t, os.WriteFile("testdata/workflow_nodes.json", b, 0644)) // nolint: gosec

b, err = json.MarshalIndent(m["chainWriter"], "", " ")
require.NoError(t, err)
require.NoError(t, os.WriteFile("testdata/chain_writer_nodes.json", b, 0644))
require.NoError(t, os.WriteFile("testdata/chain_writer_nodes.json", b, 0644)) // nolint: gosec
}
gotWFNops := m["workflow"]
sort.Slice(gotWFNops, func(i, j int) bool {
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/deployment/keystone/contract_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func deployContracts(lggr logger.Logger, req deployContractsRequest) (*deployCon
if err != nil {
return nil, fmt.Errorf("failed to deploy KeystoneForwarder: %w", err)
}
resp.AddressBook.Save(req.chain.Selector, forwarderResp.Address.String(), forwarderResp.Tv)
err = resp.AddressBook.Save(req.chain.Selector, forwarderResp.Address.String(), forwarderResp.Tv)
if err != nil {
return nil, fmt.Errorf("failed to save KeystoneForwarder: %w", err)
}
Expand Down
10 changes: 3 additions & 7 deletions integration-tests/deployment/keystone/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func Deploy(ctx context.Context, lggr logger.Logger, req DeployRequest) (*Deploy

if registry == nil {
var got = []uint64{}
for k, _ := range req.Menv.Chains() {
for k := range req.Menv.Chains() {
got = append(got, k)
}
return nil, fmt.Errorf("registry not found. expected %d in %v", req.RegistryChain, got)
Expand Down Expand Up @@ -255,7 +255,7 @@ func Deploy(ctx context.Context, lggr logger.Logger, req DeployRequest) (*Deploy
}
resp.DonToId[don] = donid
lggr.Debugw("registered DON", "don", don, "p2pids", p2pIds, "cgs", cfgs, "wfSupported", wfSupported, "f", f, "id", donid)
donid += 1
donid++
}

lggr.Infow("registered DONS")
Expand Down Expand Up @@ -296,10 +296,6 @@ func registerCapabilities(lggr logger.Logger, req registerCapabilitiesRequest) (
uniqueOffchainNodeIDs[nodeID] = struct{}{}
}
}
nodeIDs := make([]string, 0)
for nodeID := range uniqueOffchainNodeIDs {
nodeIDs = append(nodeIDs, nodeID)
}

// capability could be hosted on multiple dons. need to deduplicate
uniqueCaps := make(map[kcr.CapabilitiesRegistryCapability][32]byte)
Expand Down Expand Up @@ -509,7 +505,7 @@ func mapDonsToNodes(ctx context.Context, menv deployment.MultiDonEnvironment, ex
if len(donNodeSet.Nodes) == 0 {
return nil, fmt.Errorf("no nodes found")
}
// each node in the nodeset may support mulitple chains
// each node in the nodeset may support multiple chains
nodeCfgs := make(map[string][]*v1.ChainConfig)
for _, node := range donNodeSet.Nodes {
cfgResp, err := env.Offchain.ListNodeChainConfigs(ctx, &v1.ListNodeChainConfigsRequest{
Expand Down
8 changes: 1 addition & 7 deletions integration-tests/deployment/keystone/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ var (
OCR3Capability deployment.ContractType = "OCR3Capability"
)

type deployable interface {
// deploy deploys the contract and returns the address and transaction
// implementors must confirm the transaction and return any error
deploy(deployRequest) (deployResponse, error)
}

type deployResponse struct {
Address common.Address
Tx common.Hash // todo: chain agnostic
Expand All @@ -41,7 +35,7 @@ type DonNode struct {
}

type CapabilityHost struct {
NodeID string // gloablly unique
NodeID string // globally unique
Capabilities []capabilities_registry.CapabilitiesRegistryCapability
}

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/deployment/memory/job_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (j JobClient) ListNodeChainConfigs(ctx context.Context, in *nodev1.ListNode
}
n, ok := j.Nodes[in.Filter.NodeIds[0]]
if !ok {
return nil, fmt.Errorf("node id not found: %d", in.Filter.NodeIds[0])
return nil, fmt.Errorf("node id not found: %s", in.Filter.NodeIds[0])
}
offpk := n.Keys.OCRKeyBundle.OffchainPublicKey()
cpk := n.Keys.OCRKeyBundle.ConfigEncryptionPublicKey()
Expand Down

0 comments on commit 0099c5b

Please sign in to comment.