Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
asoliman92 committed Jul 12, 2024
1 parent 43c4622 commit 665cf9b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 81 deletions.
67 changes: 11 additions & 56 deletions core/services/ocr3/plugins/ccip_integration_tests/ocr3_node_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package ccip_integration_tests

import (
"context"
"fmt"
"sync"
"testing"
"time"

Expand All @@ -21,7 +19,6 @@ import (
func TestIntegration_OCR3Nodes(t *testing.T) {
numChains := 3
homeChainUni, universes := createUniverses(t, numChains)
//homeChainUni, universes := createUniverses(t, 3)
numNodes := 4
t.Log("creating ocr3 nodes")
var (
Expand Down Expand Up @@ -74,69 +71,27 @@ func TestIntegration_OCR3Nodes(t *testing.T) {
}
}

t.Log("starting ticker to commit blocks")
tick := time.NewTicker(1 * time.Second)
defer tick.Stop()
tickCtx, tickCancel := context.WithCancel(testutils.Context(t))
defer tickCancel()
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
for {
select {
case <-tick.C:
for _, uni := range universes {
uni.backend.Commit()
}
case <-tickCtx.Done():
return
}
}
}()
t.Cleanup(func() {
tickCancel()
wg.Wait()
})

bootstrapNode := nodes[0]

t.Log("adding bootstrap node job")
err := bootstrapNode.app.Start(testutils.Context(t))
require.NoError(t, err, "failed to start bootstrap node")
t.Cleanup(func() {
require.NoError(t, bootstrapNode.app.Stop())
})

evmChains := bootstrapNode.app.GetRelayers().LegacyEVMChains()
require.NotNil(t, evmChains)
require.Len(t, evmChains.Slice(), numChains)
// Start committing periodically in the background for all the chains
commitBlocksBackground(t, universes, time.NewTicker(1*time.Second))

t.Log("creating ocr3 jobs")
for i := 0; i < numNodes; i++ {
//err := apps[i].Start(testutils.Context(t))
//require.NoError(t, err)
//tApp := apps[i]
//t.Cleanup(func() {
// require.NoError(t, tApp.Stop())
//})
//
//ccipSpecToml := createCCIPSpecToml(nodes[i].peerID, bootstrapP2PID.String(), bootstrapPort, nodes[i].keybundle.ID())
//t.Log("Creating ccip job with spec:\n", ccipSpecToml)

//ccipJob, err2 := ccipcapability(ccipSpecToml)
//require.NoError(t, err2, "failed to validate ccip job")
//err2 = apps[i].AddJobV2(testutils.Context(t), &ccipJob)
//require.NoError(t, err2, "failed to add ccip job")
err := apps[i].Start(testutils.Context(t))
require.NoError(t, err)
tApp := apps[i]
t.Cleanup(func() {
require.NoError(t, tApp.Stop())
})
//TODO: Create Jobs and add them to the app
}

// add the ccip dons to the capability registry.
ccipCapabilityID, err := homeChainUni.capabilityRegistry.GetHashedCapabilityId(nil, CapabilityLabelledName, CapabilityVersion)
require.NoError(t, err, "failed to get hashed capability id for ccip")
require.NotEqual(t, [32]byte{}, ccipCapabilityID, "ccip capability id is empty")

// Need to Add nodes and assign capabilities to them before creating DONS
homeChainUni.AddNodes(t, p2pIDs, [][32]byte{ccipCapabilityID})
// create a DON for each chain
// Create a DON for each chain
for _, uni := range universes {
// Add nodes and give them the capability
t.Log("AddingDON for universe: ", uni.chainID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"math/big"
"net/http"
"sync"
"testing"
"time"

Expand Down Expand Up @@ -250,29 +251,29 @@ func createConfigV2Chain(chainID *big.Int) *v2toml.EVMConfig {
}
}

func createCCIPSpecToml(nodeP2PID, bootstrapP2PID string, bootstrapPort int, ocrKeyBundleID string) string {
return fmt.Sprintf(`
type = "ccip"
capabilityVersion = "%s"
capabilityLabelledName = "%s"
p2pKeyID = "%s"
p2pV2Bootstrappers = ["%s"]
[ocrKeyBundleIDs]
evm = "%s"
[relayConfigs.evm.chainReaderConfig.contracts.Offramp]
contractABI = "the abi"
[relayConfigs.evm.chainReaderConfig.contracts.Offramp.configs.getStuff]
chainSpecificName = "getStuffEVM"
[pluginConfig]
tokenPricesPipeline = "the pipeline"`,
CapabilityVersion,
CcipCapabilityLabelledName,
nodeP2PID,
fmt.Sprintf("%[email protected]:%d", bootstrapP2PID,
bootstrapPort,
),
ocrKeyBundleID,
)
// Commit blocks periodically in the background for all chains
func commitBlocksBackground(t *testing.T, universes map[uint64]onchainUniverse, tick *time.Ticker) {
t.Log("starting ticker to commit blocks")
defer tick.Stop()
tickCtx, tickCancel := context.WithCancel(testutils.Context(t))
defer tickCancel()
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
for {
select {
case <-tick.C:
for _, uni := range universes {
uni.backend.Commit()
}
case <-tickCtx.Done():
return
}
}
}()
t.Cleanup(func() {
tickCancel()
wg.Wait()
})
}

0 comments on commit 665cf9b

Please sign in to comment.