Skip to content

Commit

Permalink
adding solchains to newnodes
Browse files Browse the repository at this point in the history
  • Loading branch information
yashnevatia committed Jan 10, 2025
1 parent 32776f1 commit fa9d9f9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
11 changes: 6 additions & 5 deletions deployment/environment/memory/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func generateMemoryChainSol(t *testing.T, inputs map[uint64]SolanaChain) map[uin
return chains
}

func NewNodes(t *testing.T, logLevel zapcore.Level, chains map[uint64]deployment.Chain, numNodes, numBootstraps int, registryConfig deployment.CapabilityRegistryConfig) map[string]Node {
func NewNodes(t *testing.T, logLevel zapcore.Level, chains map[uint64]deployment.Chain, solChains map[uint64]deployment.SolChain, numNodes, numBootstraps int, registryConfig deployment.CapabilityRegistryConfig) map[string]Node {
nodesByPeerID := make(map[string]Node)
if numNodes+numBootstraps == 0 {
return nodesByPeerID
Expand All @@ -173,13 +173,13 @@ func NewNodes(t *testing.T, logLevel zapcore.Level, chains map[uint64]deployment
// since we won't run a bootstrapper and a plugin oracle on the same
// chainlink node in production.
for i := 0; i < numBootstraps; i++ {
node := NewNode(t, ports[i], chains, nil, logLevel, true /* bootstrap */, registryConfig)
node := NewNode(t, ports[i], chains, solChains, logLevel, true /* bootstrap */, registryConfig)
nodesByPeerID[node.Keys.PeerID.String()] = *node
// Note in real env, this ID is allocated by JD.
}
for i := 0; i < numNodes; i++ {
// grab port offset by numBootstraps, since above loop also takes some ports.
node := NewNode(t, ports[numBootstraps+i], chains, nil, logLevel, false /* bootstrap */, registryConfig)
node := NewNode(t, ports[numBootstraps+i], chains, solChains, logLevel, false /* bootstrap */, registryConfig)
nodesByPeerID[node.Keys.PeerID.String()] = *node
// Note in real env, this ID is allocated by JD.
}
Expand All @@ -190,6 +190,7 @@ func NewMemoryEnvironmentFromChainsNodes(
ctx func() context.Context,
lggr logger.Logger,
chains map[uint64]deployment.Chain,
solChains map[uint64]deployment.SolChain,
nodes map[string]Node,
) deployment.Environment {
var nodeIDs []string
Expand All @@ -201,7 +202,7 @@ func NewMemoryEnvironmentFromChainsNodes(
lggr,
deployment.NewMemoryAddressBook(),
chains,
nil,
solChains,
nodeIDs, // Note these have the p2p_ prefix.
NewMemoryJobClient(nodes),
ctx,
Expand All @@ -213,7 +214,7 @@ func NewMemoryEnvironmentFromChainsNodes(
func NewMemoryEnvironment(t *testing.T, lggr logger.Logger, logLevel zapcore.Level, config MemoryEnvironmentConfig) deployment.Environment {
chains, _ := NewMemoryChains(t, config.Chains, config.NumOfUsersPerChain)
solChains := NewMemoryChainsSol(t, config.SolChains)
nodes := NewNodes(t, logLevel, chains, config.Nodes, config.Bootstraps, config.RegistryConfig)
nodes := NewNodes(t, logLevel, chains, solChains, config.Nodes, config.Bootstraps, config.RegistryConfig)
var nodeIDs []string
for id := range nodes {
nodeIDs = append(nodeIDs, id)
Expand Down
8 changes: 4 additions & 4 deletions deployment/keystone/changeset/test/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,17 @@ func SetupTestEnv(t *testing.T, c TestConfig) TestEnv {

wfChains := map[uint64]deployment.Chain{}
wfChains[registryChainSel] = chains[registryChainSel]
wfNodes := memory.NewNodes(t, zapcore.InfoLevel, wfChains, c.WFDonConfig.N, 0, crConfig)
wfNodes := memory.NewNodes(t, zapcore.InfoLevel, wfChains, nil, c.WFDonConfig.N, 0, crConfig)
require.Len(t, wfNodes, c.WFDonConfig.N)

writerChains := map[uint64]deployment.Chain{}
maps.Copy(writerChains, chains)
cwNodes := memory.NewNodes(t, zapcore.InfoLevel, writerChains, c.WriterDonConfig.N, 0, crConfig)
cwNodes := memory.NewNodes(t, zapcore.InfoLevel, writerChains, nil, c.WriterDonConfig.N, 0, crConfig)
require.Len(t, cwNodes, c.WriterDonConfig.N)

assetChains := map[uint64]deployment.Chain{}
assetChains[registryChainSel] = chains[registryChainSel]
assetNodes := memory.NewNodes(t, zapcore.InfoLevel, assetChains, c.AssetDonConfig.N, 0, crConfig)
assetNodes := memory.NewNodes(t, zapcore.InfoLevel, assetChains, nil, c.AssetDonConfig.N, 0, crConfig)
require.Len(t, assetNodes, c.AssetDonConfig.N)

// TODO: partition nodes into multiple nops
Expand Down Expand Up @@ -190,7 +190,7 @@ func SetupTestEnv(t *testing.T, c TestConfig) TestEnv {
maps.Copy(allNodes, wfNodes)
maps.Copy(allNodes, cwNodes)
maps.Copy(allNodes, assetNodes)
env := memory.NewMemoryEnvironmentFromChainsNodes(func() context.Context { return ctx }, lggr, allChains, allNodes)
env := memory.NewMemoryEnvironmentFromChainsNodes(func() context.Context { return ctx }, lggr, allChains, nil, allNodes)
// set the env addresses to the deployed addresses that were created prior to configuring the nodes
err = env.ExistingAddresses.Merge(e.ExistingAddresses)
require.NoError(t, err)
Expand Down

0 comments on commit fa9d9f9

Please sign in to comment.