Skip to content

Commit

Permalink
BCF-2749 remove legacy chains job orm (#11140)
Browse files Browse the repository at this point in the history
* Remove legacy chains from job orm

 - This removes evm cfg loading into jobs str8 from db

* Remove legacy chains from tests that used it for job orm

* Remove legacy env var test from TestRunner integration tests

* minor fix for test runner

* minor err handling change in vrf delegate_test.go
  • Loading branch information
ilija42 authored Nov 2, 2023
1 parent a08b705 commit 2c295a7
Show file tree
Hide file tree
Showing 17 changed files with 75 additions and 256 deletions.
2 changes: 1 addition & 1 deletion core/internal/cltest/cltest.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func NewJobPipelineV2(t testing.TB, cfg pipeline.BridgeConfig, jpcfg JobPipeline
lggr := logger.TestLogger(t)
prm := pipeline.NewORM(db, lggr, dbCfg, jpcfg.MaxSuccessfulRuns())
btORM := bridges.NewORM(db, lggr, dbCfg)
jrm := job.NewORM(db, legacyChains, prm, btORM, keyStore, lggr, dbCfg)
jrm := job.NewORM(db, prm, btORM, keyStore, lggr, dbCfg)
pr := pipeline.NewRunner(prm, btORM, jpcfg, cfg, legacyChains, keyStore.Eth(), keyStore.VRF(), lggr, restrictedHTTPClient, unrestrictedHTTPClient)
return JobPipelineV2TestHelper{
prm,
Expand Down
4 changes: 2 additions & 2 deletions core/internal/cltest/factories.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ func MustInsertV2JobSpec(t *testing.T, db *sqlx.DB, transmitterAddress common.Ad
PipelineSpecID: pipelineSpec.ID,
}

jorm := job.NewORM(db, nil, nil, nil, nil, logger.TestLogger(t), configtest.NewTestGeneralConfig(t).Database())
jorm := job.NewORM(db, nil, nil, nil, logger.TestLogger(t), configtest.NewTestGeneralConfig(t).Database())
err = jorm.InsertJob(&jb)
require.NoError(t, err)
return jb
Expand Down Expand Up @@ -619,7 +619,7 @@ func MustInsertKeeperJob(t *testing.T, db *sqlx.DB, korm keeper.ORM, from ethkey
tlg := logger.TestLogger(t)
prm := pipeline.NewORM(db, tlg, cfg.Database(), cfg.JobPipeline().MaxSuccessfulRuns())
btORM := bridges.NewORM(db, tlg, cfg.Database())
jrm := job.NewORM(db, nil, prm, btORM, nil, tlg, cfg.Database())
jrm := job.NewORM(db, prm, btORM, nil, tlg, cfg.Database())
err = jrm.InsertJob(&jb)
require.NoError(t, err)
return jb
Expand Down
6 changes: 1 addition & 5 deletions core/internal/cltest/job_factories.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ import (

"github.com/smartcontractkit/chainlink/v2/core/bridges"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest"
"github.com/smartcontractkit/chainlink/v2/core/logger"
"github.com/smartcontractkit/chainlink/v2/core/services/job"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey"
"github.com/smartcontractkit/chainlink/v2/core/services/pipeline"
evmrelay "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm"
)

const (
Expand Down Expand Up @@ -66,9 +64,7 @@ func getORMs(t *testing.T, db *sqlx.DB) (jobORM job.ORM, pipelineORM pipeline.OR
lggr := logger.TestLogger(t)
pipelineORM = pipeline.NewORM(db, lggr, config.Database(), config.JobPipeline().MaxSuccessfulRuns())
bridgeORM := bridges.NewORM(db, lggr, config.Database())
cc := evmtest.NewChainRelayExtenders(t, evmtest.TestChainOpts{DB: db, GeneralConfig: config, KeyStore: keyStore.Eth()})
legacyChains := evmrelay.NewLegacyChainsFromRelayerExtenders(cc)
jobORM = job.NewORM(db, legacyChains, pipelineORM, bridgeORM, keyStore, lggr, config.Database())
jobORM = job.NewORM(db, pipelineORM, bridgeORM, keyStore, lggr, config.Database())
t.Cleanup(func() { jobORM.Close() })
return
}
3 changes: 1 addition & 2 deletions core/internal/features/features_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@ observationSource = """

pipelineORM := pipeline.NewORM(app.GetSqlxDB(), logger.TestLogger(t), cfg.Database(), cfg.JobPipeline().MaxSuccessfulRuns())
bridgeORM := bridges.NewORM(app.GetSqlxDB(), logger.TestLogger(t), cfg.Database())
legacyChains := app.GetRelayers().LegacyEVMChains()
jobORM := job.NewORM(app.GetSqlxDB(), legacyChains, pipelineORM, bridgeORM, app.KeyStore, logger.TestLogger(t), cfg.Database())
jobORM := job.NewORM(app.GetSqlxDB(), pipelineORM, bridgeORM, app.KeyStore, logger.TestLogger(t), cfg.Database())

runs := cltest.WaitForPipelineComplete(t, 0, jobID, 1, 2, jobORM, 5*time.Second, 300*time.Millisecond)
require.Len(t, runs, 1)
Expand Down
2 changes: 1 addition & 1 deletion core/services/chainlink/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func NewApplication(opts ApplicationOpts) (Application, error) {
sessionORM = sessions.NewORM(db, cfg.WebServer().SessionTimeout().Duration(), globalLogger, cfg.Database(), auditLogger)
mercuryORM = mercury.NewORM(db, globalLogger, cfg.Database())
pipelineRunner = pipeline.NewRunner(pipelineORM, bridgeORM, cfg.JobPipeline(), cfg.WebServer(), legacyEVMChains, keyStore.Eth(), keyStore.VRF(), globalLogger, restrictedHTTPClient, unrestrictedHTTPClient)
jobORM = job.NewORM(db, legacyEVMChains, pipelineORM, bridgeORM, keyStore, globalLogger, cfg.Database())
jobORM = job.NewORM(db, pipelineORM, bridgeORM, keyStore, globalLogger, cfg.Database())
txmORM = txmgr.NewTxStore(db, globalLogger, cfg.Database())
)

Expand Down
6 changes: 1 addition & 5 deletions core/services/cron/cron_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/internal/cltest"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest"
"github.com/smartcontractkit/chainlink/v2/core/logger"
"github.com/smartcontractkit/chainlink/v2/core/services/cron"
"github.com/smartcontractkit/chainlink/v2/core/services/job"
"github.com/smartcontractkit/chainlink/v2/core/services/pipeline"
pipelinemocks "github.com/smartcontractkit/chainlink/v2/core/services/pipeline/mocks"
evmrelay "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm"
)

func TestCronV2Pipeline(t *testing.T) {
Expand All @@ -28,12 +26,10 @@ func TestCronV2Pipeline(t *testing.T) {
db := pgtest.NewSqlxDB(t)

keyStore := cltest.NewKeyStore(t, db, cfg.Database())
relayerExtenders := evmtest.NewChainRelayExtenders(t, evmtest.TestChainOpts{DB: db, GeneralConfig: cfg, Client: evmtest.NewEthClientMockWithDefaultChain(t), KeyStore: keyStore.Eth()})
lggr := logger.TestLogger(t)
orm := pipeline.NewORM(db, lggr, cfg.Database(), cfg.JobPipeline().MaxSuccessfulRuns())
btORM := bridges.NewORM(db, lggr, cfg.Database())
legacyChains := evmrelay.NewLegacyChainsFromRelayerExtenders(relayerExtenders)
jobORM := job.NewORM(db, legacyChains, orm, btORM, keyStore, lggr, cfg.Database())
jobORM := job.NewORM(db, orm, btORM, keyStore, lggr, cfg.Database())

jb := &job.Job{
Type: job.Cron,
Expand Down
2 changes: 1 addition & 1 deletion core/services/directrequest/delegate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ func NewDirectRequestUniverseWithConfig(t *testing.T, cfg chainlink.GeneralConfi
lggr := logger.TestLogger(t)
orm := pipeline.NewORM(db, lggr, cfg.Database(), cfg.JobPipeline().MaxSuccessfulRuns())
btORM := bridges.NewORM(db, lggr, cfg.Database())
jobORM := job.NewORM(db, orm, btORM, keyStore, lggr, cfg.Database())
legacyChains := evmrelay.NewLegacyChainsFromRelayerExtenders(relayExtenders)
jobORM := job.NewORM(db, legacyChains, orm, btORM, keyStore, lggr, cfg.Database())
delegate := directrequest.NewDelegate(lggr, runner, orm, legacyChains, mailMon)

jb := cltest.MakeDirectRequestJobSpec(t)
Expand Down
4 changes: 2 additions & 2 deletions core/services/feeds/orm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1656,8 +1656,7 @@ func createJob(t *testing.T, db *sqlx.DB, externalJobID uuid.UUID) *job.Job {
bridgeORM = bridges.NewORM(db, lggr, config.Database())
relayExtenders = evmtest.NewChainRelayExtenders(t, evmtest.TestChainOpts{DB: db, GeneralConfig: config, KeyStore: keyStore.Eth()})
)
legacyChains := evmrelay.NewLegacyChainsFromRelayerExtenders(relayExtenders)
orm := job.NewORM(db, legacyChains, pipelineORM, bridgeORM, keyStore, lggr, config.Database())
orm := job.NewORM(db, pipelineORM, bridgeORM, keyStore, lggr, config.Database())
require.NoError(t, keyStore.OCR().Add(cltest.DefaultOCRKey))
require.NoError(t, keyStore.P2P().Add(cltest.DefaultP2PKey))

Expand All @@ -1667,6 +1666,7 @@ func createJob(t *testing.T, db *sqlx.DB, externalJobID uuid.UUID) *job.Job {
_, bridge2 := cltest.MustCreateBridge(t, db, cltest.BridgeOpts{}, config.Database())

_, address := cltest.MustInsertRandomKey(t, keyStore.Eth())
legacyChains := evmrelay.NewLegacyChainsFromRelayerExtenders(relayExtenders)
jb, err := ocr.ValidatedOracleSpecToml(legacyChains,
testspecs.GenerateOCRSpec(testspecs.OCRSpecParams{
JobID: externalJobID.String(),
Expand Down
6 changes: 1 addition & 5 deletions core/services/fluxmonitorv2/orm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/internal/cltest"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest"
"github.com/smartcontractkit/chainlink/v2/core/logger"
"github.com/smartcontractkit/chainlink/v2/core/services/fluxmonitorv2"
"github.com/smartcontractkit/chainlink/v2/core/services/job"
"github.com/smartcontractkit/chainlink/v2/core/services/pipeline"
evmrelay "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm"
"github.com/smartcontractkit/chainlink/v2/core/utils"
)

Expand Down Expand Up @@ -96,11 +94,9 @@ func TestORM_UpdateFluxMonitorRoundStats(t *testing.T) {
pipelineORM := pipeline.NewORM(db, lggr, cfg.Database(), cfg.JobPipeline().MaxSuccessfulRuns())
bridgeORM := bridges.NewORM(db, lggr, cfg.Database())

relayExtenders := evmtest.NewChainRelayExtenders(t, evmtest.TestChainOpts{GeneralConfig: cfg, DB: db, KeyStore: keyStore.Eth()})
legacyChains := evmrelay.NewLegacyChainsFromRelayerExtenders(relayExtenders)
// Instantiate a real job ORM because we need to create a job to satisfy
// a check in pipeline.CreateRun
jobORM := job.NewORM(db, legacyChains, pipelineORM, bridgeORM, keyStore, lggr, cfg.Database())
jobORM := job.NewORM(db, pipelineORM, bridgeORM, keyStore, lggr, cfg.Database())
orm := newORM(t, db, cfg.Database(), nil)

address := testutils.NewAddress()
Expand Down
Loading

0 comments on commit 2c295a7

Please sign in to comment.