Skip to content

Commit

Permalink
Tooling deployment scaffolding (#1252)
Browse files Browse the repository at this point in the history
- NOTE ~5k is generated protobuf code to unblock. That will be imported
once exposed.
- We put the deployment/configuration logic in integration-tests module
for a few reasons:
- Keeps the chain dependencies out of the core module, in particular
helpful for eventual cross family tests
- It can become the canonical deployment logic to be used for CRIB envs
as well (eventually can replace the actions + contracts dirs)
- To accomplish the lightweight tests (chainlink.Application +
simulated.Backend) we expose some test utilities in util/testutils/
- integration-tests/deployment holds product agnostic deployment
utilities including a general purpose environment structure to write
environment abstracted code against and migration output components
(address books, proposals etc)
- integration-tests/deployment/ccip holds all product specific
deployment code including
- Top level migrations and migration tests where a "migration" is
defined to be a function which operates against an environment and
outputs a MigrationOutput structure with one or more artifacts (MCMS
proposals, job specs). Notably migration tests can apply those outputs
to an ephemeral environment to ensure correctness. These migrations are
intended for export and use against real environments (testnet/mainnet).
- Re-usable product specific components of top level migrations and
associated tests

Next steps / follow up PRs:
- Port testutils export to chainlink repo
- Example solana setup
- Once cross family validated, start deeper testing and real CCIP use
cases

---------

Co-authored-by: Adam Hamrick <[email protected]>
Co-authored-by: AnieeG <[email protected]>
  • Loading branch information
3 people authored and asoliman92 committed Aug 28, 2024
1 parent b866aaf commit 5b61e17
Show file tree
Hide file tree
Showing 28 changed files with 3,191 additions and 510 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"math/big"
"net/http"
"net/http/httptest"
"slices"
"strconv"
"strings"
"testing"
Expand Down Expand Up @@ -37,7 +36,6 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/utils/mailbox"

cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip"
coretypes "github.com/smartcontractkit/chainlink-common/pkg/types/core/mocks"

"github.com/smartcontractkit/chainlink/v2/core/chains/evm/client"
v2 "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml"
Expand All @@ -49,7 +47,6 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/commit_store"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/evm_2_evm_offramp"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/evm_2_evm_onramp"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/price_registry_1_2_0"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils"
"github.com/smartcontractkit/chainlink/v2/core/logger"
"github.com/smartcontractkit/chainlink/v2/core/logger/audit"
Expand Down Expand Up @@ -381,6 +378,7 @@ func setupNodeCCIP(
fmt.Sprintf("127.0.0.1:%d", port),
}
c.Log.Level = &loglevel
c.Feature.CCIP = &trueRef
c.Feature.UICSAKeys = &trueRef
c.Feature.FeedsManager = &trueRef
c.OCR.Enabled = &falseRef
Expand Down Expand Up @@ -460,10 +458,9 @@ func setupNodeCCIP(
}
loopRegistry := plugins.NewLoopRegistry(lggr.Named("LoopRegistry"), config.Tracing())
relayerFactory := chainlink.RelayerFactory{
Logger: lggr,
LoopRegistry: loopRegistry,
GRPCOpts: loop.GRPCOpts{},
CapabilitiesRegistry: coretypes.NewCapabilitiesRegistry(t),
Logger: lggr,
LoopRegistry: loopRegistry,
GRPCOpts: loop.GRPCOpts{},
}
testCtx := testutils.Context(t)
// evm alway enabled for backward compatibility
Expand Down Expand Up @@ -764,47 +761,6 @@ func (c *CCIPIntegrationTestHarness) NoNodesHaveExecutedSeqNum(t *testing.T, seq
return log
}

func (c *CCIPIntegrationTestHarness) EventuallyPriceRegistryUpdated(t *testing.T, block uint64, srcSelector uint64, tokens []common.Address, sourceNative common.Address, priceRegistryOpts ...common.Address) {
var priceRegistry *price_registry_1_2_0.PriceRegistry
var err error
if len(priceRegistryOpts) > 0 {
priceRegistry, err = price_registry_1_2_0.NewPriceRegistry(priceRegistryOpts[0], c.Dest.Chain)
require.NoError(t, err)
} else {
require.NotNil(t, c.Dest.PriceRegistry, "no priceRegistry configured")
priceRegistry = c.Dest.PriceRegistry
}

g := gomega.NewGomegaWithT(t)
g.Eventually(func() bool {
it, err := priceRegistry.FilterUsdPerTokenUpdated(&bind.FilterOpts{Start: block}, tokens)
g.Expect(err).NotTo(gomega.HaveOccurred(), "Error filtering UsdPerTokenUpdated event")

tokensFetched := make([]common.Address, 0, len(tokens))
for it.Next() {
tokenFetched := it.Event.Token
tokensFetched = append(tokensFetched, tokenFetched)
t.Log("Token price updated", tokenFetched.String(), it.Event.Value.String(), it.Event.Timestamp.String())
}

for _, token := range tokens {
if !slices.Contains(tokensFetched, token) {
return false
}
}

return true
}, testutils.WaitTimeout(t), 10*time.Second).Should(gomega.BeTrue(), "Tokens prices has not been updated")

g.Eventually(func() bool {
it, err := priceRegistry.FilterUsdPerUnitGasUpdated(&bind.FilterOpts{Start: block}, []uint64{srcSelector})
g.Expect(err).NotTo(gomega.HaveOccurred(), "Error filtering UsdPerUnitGasUpdated event")
g.Expect(it.Next()).To(gomega.BeTrue(), "No UsdPerUnitGasUpdated event found")

return true
}, testutils.WaitTimeout(t), 10*time.Second).Should(gomega.BeTrue(), "source gas price has not been updated")
}

func (c *CCIPIntegrationTestHarness) EventuallyCommitReportAccepted(t *testing.T, currentBlock uint64, commitStoreOpts ...common.Address) commit_store.CommitStoreCommitReport {
var commitStore *commit_store.CommitStore
var err error
Expand Down
Loading

0 comments on commit 5b61e17

Please sign in to comment.