diff --git a/integration-tests/actions/ocr2_helpers_local.go b/integration-tests/actions/ocr2_helpers_local.go index 0b20e4cfee7..b3fe6eb041f 100644 --- a/integration-tests/actions/ocr2_helpers_local.go +++ b/integration-tests/actions/ocr2_helpers_local.go @@ -4,6 +4,7 @@ import ( "crypto/ed25519" "encoding/hex" "fmt" + "net/http" "strings" "time" @@ -11,7 +12,7 @@ import ( "github.com/google/uuid" "github.com/lib/pq" "github.com/rs/zerolog/log" - ctfClient "github.com/smartcontractkit/chainlink-testing-framework/client" + "github.com/smartcontractkit/chainlink-testing-framework/docker/test_env" "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/contracts" "github.com/smartcontractkit/chainlink/v2/core/services/job" @@ -29,9 +30,9 @@ func CreateOCRv2JobsLocal( ocrInstances []contracts.OffchainAggregatorV2, bootstrapNode *client.ChainlinkClient, workerChainlinkNodes []*client.ChainlinkClient, - mockserver *ctfClient.MockserverClient, - mockServerPath string, // Path on the mock server for the Chainlink nodes to query - mockServerValue int, // Value to get from the mock server when querying the path + mockAdapter *test_env.Killgrave, + mockAdapterPath string, // Path on the mock server for the Chainlink nodes to query + mockAdapterValue int, // Value to get from the mock server when querying the path chainId uint64, // EVM chain ID forwardingAllowed bool, ) error { @@ -42,12 +43,12 @@ func CreateOCRv2JobsLocal( } p2pV2Bootstrapper := fmt.Sprintf("%s@%s:%d", bootstrapP2PIds.Data[0].Attributes.PeerID, bootstrapNode.InternalIP(), 6690) // Set the value for the jobs to report on - err = mockserver.SetValuePath(mockServerPath, mockServerValue) + err = mockAdapter.SetAdapterBasedIntValuePath(mockAdapterPath, []string{http.MethodGet, http.MethodPost}, mockAdapterValue) if err != nil { return err } // Set the juelsPerFeeCoinSource config value - err = mockserver.SetValuePath(fmt.Sprintf("%s/juelsPerFeeCoinSource", mockServerPath), mockServerValue) + err = mockAdapter.SetAdapterBasedIntValuePath(fmt.Sprintf("%s/juelsPerFeeCoinSource", mockAdapterPath), []string{http.MethodGet, http.MethodPost}, mockAdapterValue) if err != nil { return err } @@ -62,7 +63,7 @@ func CreateOCRv2JobsLocal( RelayConfig: map[string]interface{}{ "chainID": chainId, }, - MonitoringEndpoint: null.StringFrom(fmt.Sprintf("%s/%s", mockserver.Config.ClusterURL, mockServerPath)), + MonitoringEndpoint: null.StringFrom(fmt.Sprintf("%s/%s", mockAdapter.InternalEndpoint, mockAdapterPath)), ContractConfigTrackerPollInterval: *models.NewInterval(15 * time.Second), }, } @@ -83,12 +84,12 @@ func CreateOCRv2JobsLocal( nodeOCRKeyId := nodeOCRKeys.Data[0].ID bta := &client.BridgeTypeAttributes{ - Name: fmt.Sprintf("%s-%s", mockServerPath, uuid.NewString()), - URL: fmt.Sprintf("%s/%s", mockserver.Config.ClusterURL, mockServerPath), + Name: fmt.Sprintf("%s-%s", mockAdapterPath, uuid.NewString()), + URL: fmt.Sprintf("%s/%s", mockAdapter.InternalEndpoint, mockAdapterPath), } juelsBridge := &client.BridgeTypeAttributes{ Name: fmt.Sprintf("juels-%s", uuid.NewString()), - URL: fmt.Sprintf("%s/%s/juelsPerFeeCoinSource", mockserver.Config.ClusterURL, mockServerPath), + URL: fmt.Sprintf("%s/%s/juelsPerFeeCoinSource", mockAdapter.InternalEndpoint, mockAdapterPath), } err = chainlinkNode.MustCreateBridge(bta) if err != nil { diff --git a/integration-tests/actions/ocr_helpers_local.go b/integration-tests/actions/ocr_helpers_local.go index ae2f3686daf..4d8afc52c49 100644 --- a/integration-tests/actions/ocr_helpers_local.go +++ b/integration-tests/actions/ocr_helpers_local.go @@ -3,6 +3,7 @@ package actions import ( "fmt" "math/big" + "net/http" "strings" "github.com/ethereum/go-ethereum" @@ -11,7 +12,7 @@ import ( "github.com/pkg/errors" "github.com/rs/zerolog" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" - ctfClient "github.com/smartcontractkit/chainlink-testing-framework/client" + "github.com/smartcontractkit/chainlink-testing-framework/docker/test_env" "golang.org/x/sync/errgroup" "github.com/smartcontractkit/chainlink/integration-tests/client" @@ -141,7 +142,7 @@ func CreateOCRJobsLocal( bootstrapNode *client.ChainlinkClient, workerNodes []*client.ChainlinkClient, mockValue int, - mockserver *ctfClient.MockserverClient, + mockAdapter *test_env.Killgrave, evmChainID string, ) error { for _, ocrInstance := range ocrInstances { @@ -184,9 +185,9 @@ func CreateOCRJobsLocal( } bta := &client.BridgeTypeAttributes{ Name: nodeContractPairID, - URL: fmt.Sprintf("%s/%s", mockserver.Config.ClusterURL, strings.TrimPrefix(nodeContractPairID, "/")), + URL: fmt.Sprintf("%s/%s", mockAdapter.InternalEndpoint, strings.TrimPrefix(nodeContractPairID, "/")), } - err = SetAdapterResponseLocal(mockValue, ocrInstance, node, mockserver) + err = SetAdapterResponseLocal(mockValue, ocrInstance, node, mockAdapter) if err != nil { return fmt.Errorf("setting adapter response for OCR node failed: %w", err) } @@ -234,16 +235,16 @@ func SetAdapterResponseLocal( response int, ocrInstance contracts.OffchainAggregator, chainlinkNode *client.ChainlinkClient, - mockserver *ctfClient.MockserverClient, + mockAdapter *test_env.Killgrave, ) error { nodeContractPairID, err := BuildNodeContractPairIDLocal(chainlinkNode, ocrInstance) if err != nil { return err } path := fmt.Sprintf("/%s", nodeContractPairID) - err = mockserver.SetValuePath(path, response) + err = mockAdapter.SetAdapterBasedIntValuePath(path, []string{http.MethodGet, http.MethodPost}, response) if err != nil { - return fmt.Errorf("setting mockserver value path failed: %w", err) + return fmt.Errorf("setting mock adapter value path failed: %w", err) } return nil } @@ -252,7 +253,7 @@ func SetAllAdapterResponsesToTheSameValueLocal( response int, ocrInstances []contracts.OffchainAggregator, chainlinkNodes []*client.ChainlinkClient, - mockserver *ctfClient.MockserverClient, + mockAdapter *test_env.Killgrave, ) error { eg := &errgroup.Group{} for _, o := range ocrInstances { @@ -260,7 +261,7 @@ func SetAllAdapterResponsesToTheSameValueLocal( for _, n := range chainlinkNodes { node := n eg.Go(func() error { - return SetAdapterResponseLocal(response, ocrInstance, node, mockserver) + return SetAdapterResponseLocal(response, ocrInstance, node, mockAdapter) }) } } @@ -358,7 +359,7 @@ func CreateOCRJobsWithForwarderLocal( bootstrapNode *client.ChainlinkClient, workerNodes []*client.ChainlinkClient, mockValue int, - mockserver *ctfClient.MockserverClient, + mockAdapter *test_env.Killgrave, evmChainID string, ) error { for _, ocrInstance := range ocrInstances { @@ -401,9 +402,9 @@ func CreateOCRJobsWithForwarderLocal( } bta := &client.BridgeTypeAttributes{ Name: nodeContractPairID, - URL: fmt.Sprintf("%s/%s", mockserver.Config.ClusterURL, strings.TrimPrefix(nodeContractPairID, "/")), + URL: fmt.Sprintf("%s/%s", mockAdapter.InternalEndpoint, strings.TrimPrefix(nodeContractPairID, "/")), } - err = SetAdapterResponseLocal(mockValue, ocrInstance, node, mockserver) + err = SetAdapterResponseLocal(mockValue, ocrInstance, node, mockAdapter) if err != nil { return err } diff --git a/integration-tests/actions/vrfv2_actions/vrfv2_steps.go b/integration-tests/actions/vrfv2_actions/vrfv2_steps.go index bdf0cf1f927..4beb49a23cb 100644 --- a/integration-tests/actions/vrfv2_actions/vrfv2_steps.go +++ b/integration-tests/actions/vrfv2_actions/vrfv2_steps.go @@ -155,7 +155,7 @@ func SetupLocalLoadTestEnv(nodesFunding *big.Float, subFundingLINK *big.Int) (*t env, err := test_env.NewCLTestEnvBuilder(). WithGeth(). WithLogWatcher(). - WithMockServer(1). + WithMockAdapter(). WithCLNodes(1). WithFunding(nodesFunding). Build() diff --git a/integration-tests/docker/cmd/test_env.go b/integration-tests/docker/cmd/test_env.go index 1acf5947505..31b7de5dcdd 100644 --- a/integration-tests/docker/cmd/test_env.go +++ b/integration-tests/docker/cmd/test_env.go @@ -36,7 +36,7 @@ func main() { _, err := test_env.NewCLTestEnvBuilder(). WithGeth(). - WithMockServer(1). + WithMockAdapter(). WithCLNodes(6). Build() if err != nil { diff --git a/integration-tests/docker/test_env/test_env.go b/integration-tests/docker/test_env/test_env.go index 88b32f85be3..02db1ae788c 100644 --- a/integration-tests/docker/test_env/test_env.go +++ b/integration-tests/docker/test_env/test_env.go @@ -46,7 +46,7 @@ type CLClusterTestEnv struct { CLNodes []*ClNode Geth *test_env.Geth // for tests using --dev networks PrivateChain []test_env.PrivateChain // for tests using non-dev networks - MockServer *test_env.MockServer + MockAdapter *test_env.Killgrave EVMClient blockchain.EVMClient ContractDeployer contracts.ContractDeployer ContractLoader contracts.ContractLoader @@ -62,20 +62,20 @@ func NewTestEnv() (*CLClusterTestEnv, error) { } n := []string{network.Name} return &CLClusterTestEnv{ - Geth: test_env.NewGeth(n), - MockServer: test_env.NewMockServer(n), - Network: network, - l: log.Logger, + Geth: test_env.NewGeth(n), + MockAdapter: test_env.NewKillgrave(n, ""), + Network: network, + l: log.Logger, }, nil } // WithTestEnvConfig sets the test environment cfg. -// Sets up the Geth and MockServer containers with the provided cfg. +// Sets up the Geth and MockAdapter containers with the provided cfg. func (te *CLClusterTestEnv) WithTestEnvConfig(cfg *TestEnvConfig) *CLClusterTestEnv { te.Cfg = cfg n := []string{te.Network.Name} - te.Geth = test_env.NewGeth(n, test_env.WithContainerName(cfg.Geth.ContainerName)) - te.MockServer = test_env.NewMockServer(n, test_env.WithContainerName(cfg.MockServer.ContainerName)) + te.Geth = test_env.NewGeth(n, test_env.WithContainerName(te.Cfg.Geth.ContainerName)) + te.MockAdapter = test_env.NewKillgrave(n, te.Cfg.MockAdapter.ImpostersPath, test_env.WithContainerName(te.Cfg.MockAdapter.ContainerName)) return te } @@ -83,7 +83,7 @@ func (te *CLClusterTestEnv) WithTestLogger(t *testing.T) *CLClusterTestEnv { te.t = t te.l = logging.GetTestLogger(t) te.Geth.WithTestLogger(t) - te.MockServer.WithTestLogger(t) + te.MockAdapter.WithTestLogger(t) return te } @@ -135,8 +135,8 @@ func (te *CLClusterTestEnv) StartGeth() (blockchain.EVMNetwork, test_env.Interna return te.Geth.StartContainer() } -func (te *CLClusterTestEnv) StartMockServer() error { - return te.MockServer.StartContainer() +func (te *CLClusterTestEnv) StartMockAdapter() error { + return te.MockAdapter.StartContainer() } func (te *CLClusterTestEnv) GetAPIs() []*client.ChainlinkClient { diff --git a/integration-tests/docker/test_env/test_env_builder.go b/integration-tests/docker/test_env/test_env_builder.go index 7eeeff2489f..ced617bc060 100644 --- a/integration-tests/docker/test_env/test_env_builder.go +++ b/integration-tests/docker/test_env/test_env_builder.go @@ -22,21 +22,20 @@ import ( ) type CLTestEnvBuilder struct { - hasLogWatch bool - hasGeth bool - hasMockServer bool - hasForwarders bool - clNodeConfig *chainlink.Config - secretsConfig string - nonDevGethNetworks []blockchain.EVMNetwork - clNodesCount int - externalAdapterCount int - customNodeCsaKeys []string - defaultNodeCsaKeys []string - l zerolog.Logger - t *testing.T - te *CLClusterTestEnv - isNonEVM bool + hasLogWatch bool + hasGeth bool + hasKillgrave bool + hasForwarders bool + clNodeConfig *chainlink.Config + secretsConfig string + nonDevGethNetworks []blockchain.EVMNetwork + clNodesCount int + customNodeCsaKeys []string + defaultNodeCsaKeys []string + l zerolog.Logger + t *testing.T + te *CLClusterTestEnv + isNonEVM bool /* funding */ ETHFunds *big.Float @@ -44,8 +43,7 @@ type CLTestEnvBuilder struct { func NewCLTestEnvBuilder() *CLTestEnvBuilder { return &CLTestEnvBuilder{ - externalAdapterCount: 1, - l: log.Logger, + l: log.Logger, } } @@ -127,9 +125,8 @@ func (b *CLTestEnvBuilder) WithSecretsConfig(secrets string) *CLTestEnvBuilder { return b } -func (b *CLTestEnvBuilder) WithMockServer(externalAdapterCount int) *CLTestEnvBuilder { - b.hasMockServer = true - b.externalAdapterCount = externalAdapterCount +func (b *CLTestEnvBuilder) WithMockAdapter() *CLTestEnvBuilder { + b.hasKillgrave = true return b } @@ -149,8 +146,7 @@ func (b *CLTestEnvBuilder) Build() (*CLClusterTestEnv, error) { } b.l.Info(). Bool("hasGeth", b.hasGeth). - Bool("hasMockServer", b.hasMockServer). - Int("externalAdapterCount", b.externalAdapterCount). + Bool("hasKillgrave", b.hasKillgrave). Int("clNodesCount", b.clNodesCount). Strs("customNodeCsaKeys", b.customNodeCsaKeys). Strs("defaultNodeCsaKeys", b.defaultNodeCsaKeys). @@ -168,16 +164,13 @@ func (b *CLTestEnvBuilder) Build() (*CLClusterTestEnv, error) { } } - if b.hasMockServer { - err = b.te.StartMockServer() - if err != nil { - return nil, err - } - err = b.te.MockServer.SetExternalAdapterMocks(b.externalAdapterCount) + if b.hasKillgrave { + err = b.te.StartMockAdapter() if err != nil { return nil, err } } + if b.nonDevGethNetworks != nil { b.te.WithPrivateChain(b.nonDevGethNetworks) err := b.te.StartPrivateChain() diff --git a/integration-tests/docker/test_env/test_env_config.go b/integration-tests/docker/test_env/test_env_config.go index da38575a86a..dfac6f9520a 100644 --- a/integration-tests/docker/test_env/test_env_config.go +++ b/integration-tests/docker/test_env/test_env_config.go @@ -7,15 +7,15 @@ import ( ) type TestEnvConfig struct { - Networks []string `json:"networks"` - Geth GethConfig `json:"geth"` - MockServer MockServerConfig `json:"mockserver"` - Nodes []ClNodeConfig `json:"nodes"` + Networks []string `json:"networks"` + Geth GethConfig `json:"geth"` + MockAdapter MockAdapterConfig `json:"mock_adapter"` + Nodes []ClNodeConfig `json:"nodes"` } -type MockServerConfig struct { - ContainerName string `json:"container_name"` - EAMockUrls []string `json:"external_adapters_mock_urls"` +type MockAdapterConfig struct { + ContainerName string `json:"container_name"` + ImpostersPath string `json:"imposters_path"` } type GethConfig struct { diff --git a/integration-tests/go.mod b/integration-tests/go.mod index 97a1da1665f..b9a4641eaf6 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -20,7 +20,7 @@ require ( github.com/rs/zerolog v1.30.0 github.com/slack-go/slack v0.12.2 github.com/smartcontractkit/chainlink-env v0.38.1 - github.com/smartcontractkit/chainlink-testing-framework v1.17.4 + github.com/smartcontractkit/chainlink-testing-framework v1.17.6 github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000 github.com/smartcontractkit/libocr v0.0.0-20230922131214-122accb19ea6 github.com/smartcontractkit/ocr2keepers v0.7.27 @@ -354,6 +354,7 @@ require ( github.com/opentracing-contrib/go-grpc v0.0.0-20210225150812-73cb765af46e // indirect github.com/opentracing-contrib/go-stdlib v1.0.0 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect + github.com/otiai10/copy v1.14.0 // indirect github.com/patrickmn/go-cache v2.1.0+incompatible // indirect github.com/pelletier/go-toml v1.9.5 // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect diff --git a/integration-tests/go.sum b/integration-tests/go.sum index 17bdc669e72..802011b54ed 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -2181,6 +2181,10 @@ github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+ github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA= github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= +github.com/otiai10/copy v1.14.0 h1:dCI/t1iTdYGtkvCuBG2BgR6KZa83PTclw4U5n2wAllU= +github.com/otiai10/copy v1.14.0/go.mod h1:ECfuL02W+/FkTWZWgQqXPWZgW9oeKCSQ5qVfSc4qc4w= +github.com/otiai10/mint v1.5.1 h1:XaPLeE+9vGbuyEHem1JNk3bYc7KKqyI/na0/mLd/Kks= +github.com/otiai10/mint v1.5.1/go.mod h1:MJm72SBthJjz8qhefc4z1PYEieWmy8Bku7CjcAqyUSM= github.com/ovh/go-ovh v1.3.0 h1:mvZaddk4E4kLcXhzb+cxBsMPYp2pHqiQpWYkInsuZPQ= github.com/ovh/go-ovh v1.3.0/go.mod h1:AxitLZ5HBRPyUd+Zl60Ajaag+rNTdVXWIkzfrVuTXWA= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= @@ -2366,8 +2370,8 @@ github.com/smartcontractkit/chainlink-solana v1.0.3-0.20230831134610-680240b97ac github.com/smartcontractkit/chainlink-solana v1.0.3-0.20230831134610-680240b97aca/go.mod h1:RIUJXn7EVp24TL2p4FW79dYjyno23x5mjt1nKN+5WEk= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20230901115736-bbabe542a918 h1:ByVauKFXphRlSNG47lNuxZ9aicu+r8AoNp933VRPpCw= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20230901115736-bbabe542a918/go.mod h1:/yp/sqD8Iz5GU5fcercjrw0ivJF7HDcupYg+Gjr7EPg= -github.com/smartcontractkit/chainlink-testing-framework v1.17.4 h1:N7YK1VZrSxG3PEwY0S7NXJQgSiEvWHR6uKhytfHMTjA= -github.com/smartcontractkit/chainlink-testing-framework v1.17.4/go.mod h1:izzRx4cNihkVP9XY15isSCMW1QAlRK1w5eE23/MbZHM= +github.com/smartcontractkit/chainlink-testing-framework v1.17.6 h1:hcsP1eyzrqQf3veK4xh0T37PFkq5AasDwlgJfl11atY= +github.com/smartcontractkit/chainlink-testing-framework v1.17.6/go.mod h1:rypNxetVFh6bwaoHn05bsd4vCtgdEsF+1Vdyy/AhAR8= github.com/smartcontractkit/go-plugin v0.0.0-20231003134350-e49dad63b306 h1:ko88+ZznniNJZbZPWAvHQU8SwKAdHngdDZ+pvVgB5ss= github.com/smartcontractkit/go-plugin v0.0.0-20231003134350-e49dad63b306/go.mod h1:w1sAEES3g3PuV/RzUrgow20W2uErMly84hhD3um1WL4= github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f h1:hgJif132UCdjo8u43i7iPN1/MFnu49hv7lFGFftCHKU= diff --git a/integration-tests/smoke/automation_test.go b/integration-tests/smoke/automation_test.go index 0eabac7844b..db34cb28e1e 100644 --- a/integration-tests/smoke/automation_test.go +++ b/integration-tests/smoke/automation_test.go @@ -1017,7 +1017,6 @@ func setupAutomationTestDocker( env, err := test_env.NewCLTestEnvBuilder(). WithTestLogger(t). WithGeth(). - WithMockServer(1). WithCLNodes(5). WithCLNodeConfig(clNodeConfig). WithSecretsConfig(secretsConfig). diff --git a/integration-tests/smoke/cron_test.go b/integration-tests/smoke/cron_test.go index 717ff8db1e9..26e039289cf 100644 --- a/integration-tests/smoke/cron_test.go +++ b/integration-tests/smoke/cron_test.go @@ -2,6 +2,7 @@ package smoke import ( "fmt" + "net/http" "testing" "github.com/google/uuid" @@ -21,7 +22,7 @@ func TestCronBasic(t *testing.T) { env, err := test_env.NewCLTestEnvBuilder(). WithTestLogger(t). WithGeth(). - WithMockServer(1). + WithMockAdapter(). WithCLNodes(1). Build() require.NoError(t, err) @@ -31,12 +32,12 @@ func TestCronBasic(t *testing.T) { } }) - err = env.MockServer.Client.SetValuePath("/variable", 5) - require.NoError(t, err, "Setting value path in mockserver shouldn't fail") + err = env.MockAdapter.SetAdapterBasedIntValuePath("/variable", []string{http.MethodGet, http.MethodPost}, 5) + require.NoError(t, err, "Setting value path in mock adapter shouldn't fail") bta := &client.BridgeTypeAttributes{ Name: fmt.Sprintf("variable-%s", uuid.NewString()), - URL: fmt.Sprintf("%s/variable", env.MockServer.InternalEndpoint), + URL: fmt.Sprintf("%s/variable", env.MockAdapter.InternalEndpoint), RequestData: "{}", } err = env.CLNodes[0].API.MustCreateBridge(bta) @@ -51,6 +52,9 @@ func TestCronBasic(t *testing.T) { gom := gomega.NewGomegaWithT(t) gom.Eventually(func(g gomega.Gomega) { jobRuns, err := env.CLNodes[0].API.MustReadRunsByJob(job.Data.ID) + if err != nil { + l.Info().Err(err).Msg("error while waiting for job runs") + } g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Reading Job run data shouldn't fail") g.Expect(len(jobRuns.Data)).Should(gomega.BeNumerically(">=", 5), "Expected number of job runs to be greater than 5, but got %d", len(jobRuns.Data)) @@ -58,5 +62,5 @@ func TestCronBasic(t *testing.T) { for _, jr := range jobRuns.Data { g.Expect(jr.Attributes.Errors).Should(gomega.Equal([]interface{}{nil}), "Job run %s shouldn't have errors", jr.ID) } - }, "20m", "3s").Should(gomega.Succeed()) + }, "2m", "3s").Should(gomega.Succeed()) } diff --git a/integration-tests/smoke/flux_test.go b/integration-tests/smoke/flux_test.go index ed907e9e460..c2fbf2d435b 100644 --- a/integration-tests/smoke/flux_test.go +++ b/integration-tests/smoke/flux_test.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "math/big" + "net/http" "strings" "testing" "time" @@ -27,7 +28,7 @@ func TestFluxBasic(t *testing.T) { env, err := test_env.NewCLTestEnvBuilder(). WithTestLogger(t). WithGeth(). - WithMockServer(1). + WithMockAdapter(). WithCLNodes(3). Build() require.NoError(t, err) @@ -43,8 +44,8 @@ func TestFluxBasic(t *testing.T) { adapterUUID := uuid.NewString() adapterPath := fmt.Sprintf("/variable-%s", adapterUUID) - err = env.MockServer.Client.SetValuePath(adapterPath, 1e5) - require.NoError(t, err, "Setting mockserver value path shouldn't fail") + err = env.MockAdapter.SetAdapterBasedIntValuePath(adapterPath, []string{http.MethodPost}, 1e5) + require.NoError(t, err, "Setting mock adapter value path shouldn't fail") lt, err := actions.DeployLINKToken(env.ContractDeployer) require.NoError(t, err, "Deploying Link Token Contract shouldn't fail") @@ -81,7 +82,7 @@ func TestFluxBasic(t *testing.T) { require.NoError(t, err, "Getting oracle details from the Flux aggregator contract shouldn't fail") l.Info().Str("Oracles", strings.Join(oracles, ",")).Msg("Oracles set") - adapterFullURL := fmt.Sprintf("%s%s", env.MockServer.Client.Config.ClusterURL, adapterPath) + adapterFullURL := fmt.Sprintf("%s%s", env.MockAdapter.InternalEndpoint, adapterPath) l.Info().Str("AdapterFullURL", adapterFullURL).Send() bta := &client.BridgeTypeAttributes{ Name: fmt.Sprintf("variable-%s", adapterUUID), @@ -126,7 +127,7 @@ func TestFluxBasic(t *testing.T) { fluxRound = contracts.NewFluxAggregatorRoundConfirmer(fluxInstance, big.NewInt(2), fluxRoundTimeout, l) env.EVMClient.AddHeaderEventSubscription(fluxInstance.Address(), fluxRound) - err = env.MockServer.Client.SetValuePath(adapterPath, 1e10) + err = env.MockAdapter.SetAdapterBasedIntValuePath(adapterPath, []string{http.MethodPost}, 1e10) require.NoError(t, err, "Setting value path in mock server shouldn't fail") err = env.EVMClient.WaitForEvents() require.NoError(t, err, "Waiting for event subscriptions in nodes shouldn't fail") diff --git a/integration-tests/smoke/forwarder_ocr_test.go b/integration-tests/smoke/forwarder_ocr_test.go index f0d20e5245c..a6c0cacb96c 100644 --- a/integration-tests/smoke/forwarder_ocr_test.go +++ b/integration-tests/smoke/forwarder_ocr_test.go @@ -21,7 +21,7 @@ func TestForwarderOCRBasic(t *testing.T) { env, err := test_env.NewCLTestEnvBuilder(). WithTestLogger(t). WithGeth(). - WithMockServer(1). + WithMockAdapter(). WithForwarders(). WithCLNodes(6). WithFunding(big.NewFloat(.1)). @@ -69,19 +69,18 @@ func TestForwarderOCRBasic(t *testing.T) { ) require.NoError(t, err, "Error deploying OCR contracts") - err = actions.CreateOCRJobsWithForwarderLocal(ocrInstances, bootstrapNode, workerNodes, 5, env.MockServer.Client, env.EVMClient.GetChainID().String()) + err = actions.CreateOCRJobsWithForwarderLocal(ocrInstances, bootstrapNode, workerNodes, 5, env.MockAdapter, env.EVMClient.GetChainID().String()) require.NoError(t, err, "failed to setup forwarder jobs") err = actions.StartNewRound(1, ocrInstances, env.EVMClient, l) require.NoError(t, err) err = env.EVMClient.WaitForEvents() require.NoError(t, err, "Error waiting for events") - //time.Sleep(999 * time.Second) answer, err := ocrInstances[0].GetLatestAnswer(context.Background()) require.NoError(t, err, "Getting latest answer from OCR contract shouldn't fail") require.Equal(t, int64(5), answer.Int64(), "Expected latest answer from OCR contract to be 5 but got %d", answer.Int64()) - err = actions.SetAllAdapterResponsesToTheSameValueLocal(10, ocrInstances, workerNodes, env.MockServer.Client) + err = actions.SetAllAdapterResponsesToTheSameValueLocal(10, ocrInstances, workerNodes, env.MockAdapter) require.NoError(t, err) err = actions.StartNewRound(2, ocrInstances, env.EVMClient, l) require.NoError(t, err) diff --git a/integration-tests/smoke/forwarders_ocr2_test.go b/integration-tests/smoke/forwarders_ocr2_test.go index 48d1d20b4dc..2840658122e 100644 --- a/integration-tests/smoke/forwarders_ocr2_test.go +++ b/integration-tests/smoke/forwarders_ocr2_test.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "math/big" + "net/http" "testing" "time" @@ -25,7 +26,7 @@ func TestForwarderOCR2Basic(t *testing.T) { env, err := test_env.NewCLTestEnvBuilder(). WithTestLogger(t). WithGeth(). - WithMockServer(1). + WithMockAdapter(). WithCLNodeConfig(node.NewConfig(node.NewBaseConfig(), node.WithOCR2(), node.WithP2Pv2(), @@ -80,7 +81,7 @@ func TestForwarderOCR2Basic(t *testing.T) { err = env.EVMClient.WaitForEvents() require.NoError(t, err, "Error waiting for events") - err = actions.CreateOCRv2JobsLocal(ocrInstances, bootstrapNode, workerNodes, env.MockServer.Client, "ocr2", 5, env.EVMClient.GetChainID().Uint64(), true) + err = actions.CreateOCRv2JobsLocal(ocrInstances, bootstrapNode, workerNodes, env.MockAdapter, "ocr2", 5, env.EVMClient.GetChainID().Uint64(), true) require.NoError(t, err, "Error creating OCRv2 jobs with forwarders") err = env.EVMClient.WaitForEvents() require.NoError(t, err, "Error waiting for events") @@ -101,7 +102,7 @@ func TestForwarderOCR2Basic(t *testing.T) { for i := 2; i <= 3; i++ { ocrRoundVal := (5 + i) % 10 - err = env.MockServer.Client.SetValuePath("ocr2", ocrRoundVal) + err = env.MockAdapter.SetAdapterBasedIntValuePath("ocr2", []string{http.MethodGet, http.MethodPost}, ocrRoundVal) require.NoError(t, err) err = actions.StartNewOCR2Round(int64(i), ocrInstances, env.EVMClient, time.Minute*10, l) require.NoError(t, err) diff --git a/integration-tests/smoke/keeper_test.go b/integration-tests/smoke/keeper_test.go index 0e4cb7ce041..5b002b7b9ba 100644 --- a/integration-tests/smoke/keeper_test.go +++ b/integration-tests/smoke/keeper_test.go @@ -1110,7 +1110,6 @@ func setupKeeperTest(t *testing.T) ( env, err := test_env.NewCLTestEnvBuilder(). WithTestLogger(t). WithGeth(). - WithMockServer(1). WithCLNodes(5). WithCLNodeConfig(clNodeConfig). WithFunding(big.NewFloat(.5)). diff --git a/integration-tests/smoke/ocr2_test.go b/integration-tests/smoke/ocr2_test.go index c6804e48d01..ccc75574f21 100644 --- a/integration-tests/smoke/ocr2_test.go +++ b/integration-tests/smoke/ocr2_test.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "math/big" + "net/http" "strings" "testing" "time" @@ -34,7 +35,7 @@ func TestOCRv2Basic(t *testing.T) { env, err := test_env.NewCLTestEnvBuilder(). WithTestLogger(t). WithGeth(). - WithMockServer(1). + WithMockAdapter(). WithCLNodeConfig(node.NewConfig(node.NewBaseConfig(), node.WithOCR2(), node.WithP2Pv2(), @@ -74,7 +75,7 @@ func TestOCRv2Basic(t *testing.T) { aggregatorContracts, err := actions.DeployOCRv2Contracts(1, linkToken, env.ContractDeployer, transmitters, env.EVMClient, ocrOffchainOptions) require.NoError(t, err, "Error deploying OCRv2 aggregator contracts") - err = actions.CreateOCRv2JobsLocal(aggregatorContracts, bootstrapNode, workerNodes, env.MockServer.Client, "ocr2", 5, env.EVMClient.GetChainID().Uint64(), false) + err = actions.CreateOCRv2JobsLocal(aggregatorContracts, bootstrapNode, workerNodes, env.MockAdapter, "ocr2", 5, env.EVMClient.GetChainID().Uint64(), false) require.NoError(t, err, "Error creating OCRv2 jobs") ocrv2Config, err := actions.BuildMedianOCR2ConfigLocal(workerNodes, ocrOffchainOptions) @@ -92,7 +93,7 @@ func TestOCRv2Basic(t *testing.T) { roundData.Answer.Int64(), ) - err = env.MockServer.Client.SetValuePath("ocr2", 10) + err = env.MockAdapter.SetAdapterBasedIntValuePath("ocr2", []string{http.MethodGet, http.MethodPost}, 10) require.NoError(t, err) err = actions.StartNewOCR2Round(2, aggregatorContracts, env.EVMClient, time.Minute*5, l) require.NoError(t, err) diff --git a/integration-tests/smoke/ocr_test.go b/integration-tests/smoke/ocr_test.go index 56d045fa097..dad3b0272fe 100644 --- a/integration-tests/smoke/ocr_test.go +++ b/integration-tests/smoke/ocr_test.go @@ -20,7 +20,7 @@ func TestOCRBasic(t *testing.T) { env, err := test_env.NewCLTestEnvBuilder(). WithTestLogger(t). WithGeth(). - WithMockServer(1). + WithMockAdapter(). WithCLNodes(6). WithFunding(big.NewFloat(.1)). Build() @@ -44,7 +44,7 @@ func TestOCRBasic(t *testing.T) { err = env.EVMClient.WaitForEvents() require.NoError(t, err, "Error waiting for events") - err = actions.CreateOCRJobsLocal(ocrInstances, bootstrapNode, workerNodes, 5, env.MockServer.Client, env.EVMClient.GetChainID().String()) + err = actions.CreateOCRJobsLocal(ocrInstances, bootstrapNode, workerNodes, 5, env.MockAdapter, env.EVMClient.GetChainID().String()) require.NoError(t, err) err = actions.StartNewRound(1, ocrInstances, env.EVMClient, l) @@ -54,7 +54,7 @@ func TestOCRBasic(t *testing.T) { require.NoError(t, err, "Getting latest answer from OCR contract shouldn't fail") require.Equal(t, int64(5), answer.Int64(), "Expected latest answer from OCR contract to be 5 but got %d", answer.Int64()) - err = actions.SetAllAdapterResponsesToTheSameValueLocal(10, ocrInstances, workerNodes, env.MockServer.Client) + err = actions.SetAllAdapterResponsesToTheSameValueLocal(10, ocrInstances, workerNodes, env.MockAdapter) require.NoError(t, err) err = actions.StartNewRound(2, ocrInstances, env.EVMClient, l) require.NoError(t, err) diff --git a/integration-tests/smoke/runlog_test.go b/integration-tests/smoke/runlog_test.go index 0bfc41eca71..380d0602c06 100644 --- a/integration-tests/smoke/runlog_test.go +++ b/integration-tests/smoke/runlog_test.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "math/big" + "net/http" "strings" "testing" @@ -24,7 +25,7 @@ func TestRunLogBasic(t *testing.T) { env, err := test_env.NewCLTestEnvBuilder(). WithTestLogger(t). WithGeth(). - WithMockServer(1). + WithMockAdapter(). WithCLNodes(1). WithFunding(big.NewFloat(.1)). Build() @@ -46,14 +47,14 @@ func TestRunLogBasic(t *testing.T) { err = lt.Transfer(consumer.Address(), big.NewInt(2e18)) require.NoError(t, err, "Transferring %d to consumer contract shouldn't fail", big.NewInt(2e18)) - err = env.MockServer.Client.SetValuePath("/variable", 5) - require.NoError(t, err, "Setting mockserver value path shouldn't fail") + err = env.MockAdapter.SetAdapterBasedIntValuePath("/variable", []string{http.MethodPost}, 5) + require.NoError(t, err, "Setting mock adapter value path shouldn't fail") jobUUID := uuid.New() bta := client.BridgeTypeAttributes{ Name: fmt.Sprintf("five-%s", jobUUID.String()), - URL: fmt.Sprintf("%s/variable", env.MockServer.Client.Config.ClusterURL), + URL: fmt.Sprintf("%s/variable", env.MockAdapter.InternalEndpoint), } err = env.CLNodes[0].API.MustCreateBridge(&bta) require.NoError(t, err, "Creating bridge shouldn't fail") @@ -82,7 +83,7 @@ func TestRunLogBasic(t *testing.T) { oracle.Address(), jobID, big.NewInt(1e18), - fmt.Sprintf("%s/variable", env.MockServer.Client.Config.ClusterURL), + fmt.Sprintf("%s/variable", env.MockAdapter.InternalEndpoint), "data,result", big.NewInt(100), ) diff --git a/integration-tests/smoke/vrf_test.go b/integration-tests/smoke/vrf_test.go index 47f8cd8e30f..b4a129ad8dc 100644 --- a/integration-tests/smoke/vrf_test.go +++ b/integration-tests/smoke/vrf_test.go @@ -26,7 +26,6 @@ func TestVRFBasic(t *testing.T) { env, err := test_env.NewCLTestEnvBuilder(). WithTestLogger(t). WithGeth(). - WithMockServer(1). WithCLNodes(1). WithFunding(big.NewFloat(.1)). Build()