Skip to content

Commit

Permalink
update ctf version, hack a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Tofel committed Dec 20, 2023
1 parent 1e021c5 commit fd57a65
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 62 deletions.
21 changes: 11 additions & 10 deletions integration-tests/docker/test_env/test_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,18 @@ func (te *CLClusterTestEnv) StartPrivateChain() error {
func (te *CLClusterTestEnv) StartEthereumNetwork(cfg *test_env.EthereumNetwork) (blockchain.EVMNetwork, test_env.RpcProvider, error) {
// if environment is being restored from a previous state, use the existing config
// this might fail terribly if temporary folders with chain data on the host machine were removed
if te.Cfg != nil && te.Cfg.EthereumNetwork != nil {
builder := test_env.NewEthereumNetworkBuilder()
c, err := builder.WithExistingConfig(*te.Cfg.EthereumNetwork).
WithTest(te.t).
Build()
if err != nil {
return blockchain.EVMNetwork{}, test_env.RpcProvider{}, err
}
cfg = &c
// if te.Cfg != nil && te.Cfg.EthereumNetwork != nil {
builder := test_env.NewEthereumNetworkBuilder()
c, err := builder.WithExistingConfig(*cfg).
WithTest(te.t).
Build()
if err != nil {
return blockchain.EVMNetwork{}, test_env.RpcProvider{}, err
}
n, rpc, err := cfg.Start()
// cfg = &c
// }
n, rpc, err := c.Start()
*cfg = c

if err != nil {
return blockchain.EVMNetwork{}, test_env.RpcProvider{}, err
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ require (
github.com/slack-go/slack v0.12.2
github.com/smartcontractkit/chainlink-automation v1.0.1
github.com/smartcontractkit/chainlink-common v0.1.7-0.20231206181640-faad3f11cfad
github.com/smartcontractkit/chainlink-testing-framework v1.22.1-0.20231219145206-1ffabc4c07f2
github.com/smartcontractkit/chainlink-testing-framework v1.22.1-0.20231220002630-ba1f74c6e6c4
github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868
github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000
github.com/smartcontractkit/libocr v0.0.0-20231130143053-c5102a9c0fb7
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1532,8 +1532,8 @@ github.com/smartcontractkit/chainlink-solana v1.0.3-0.20231206154215-ec1718b7df3
github.com/smartcontractkit/chainlink-solana v1.0.3-0.20231206154215-ec1718b7df3e/go.mod h1:9YIi413QRRytafTzpWm+Z+5NWBNxSqokhKyeEZ3ynlA=
github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20231205180940-ea2e3e916725 h1:NbhPVwxx+53WN/Uld1V6c4iLgoGvUYFOsVd2kfcexe8=
github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20231205180940-ea2e3e916725/go.mod h1:vHrPBipRL52NdPp77KXNU2k1IoCUa1B33N9otZQPYko=
github.com/smartcontractkit/chainlink-testing-framework v1.22.1-0.20231219145206-1ffabc4c07f2 h1:WF3OADk3pI9GiiWCBaK5pJ/uxWlKkkhV+iHvzPfCIQo=
github.com/smartcontractkit/chainlink-testing-framework v1.22.1-0.20231219145206-1ffabc4c07f2/go.mod h1:yu6qqrppNJfutQV37fiSs4eS0uQP5QT0ebi3tlIgWN0=
github.com/smartcontractkit/chainlink-testing-framework v1.22.1-0.20231220002630-ba1f74c6e6c4 h1:ukOvIRbcoTlQqoIJa2XHaNDdsQxUkVNw7enojQjkxTc=
github.com/smartcontractkit/chainlink-testing-framework v1.22.1-0.20231220002630-ba1f74c6e6c4/go.mod h1:yu6qqrppNJfutQV37fiSs4eS0uQP5QT0ebi3tlIgWN0=
github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868 h1:FFdvEzlYwcuVHkdZ8YnZR/XomeMGbz5E2F2HZI3I3w8=
github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868/go.mod h1:Kn1Hape05UzFZ7bOUnm3GVsHzP0TNrVmpfXYNHdqGGs=
github.com/smartcontractkit/go-plugin v0.0.0-20231003134350-e49dad63b306 h1:ko88+ZznniNJZbZPWAvHQU8SwKAdHngdDZ+pvVgB5ss=
Expand Down
62 changes: 13 additions & 49 deletions integration-tests/smoke/ocr2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"fmt"
"math/big"
"net/http"
"os"
"strconv"
"testing"
"time"

Expand Down Expand Up @@ -51,61 +53,23 @@ func TestOCRv2Basic(t *testing.T) {
env.ParallelTransactions(true)

nodeClients := env.ClCluster.NodeAPIs()
bootstrapNode, workerNodes := nodeClients[0], nodeClients[1:]
_, workerNodes := nodeClients[0], nodeClients[1:]

linkToken, err := env.ContractDeployer.DeployLinkTokenContract()
_, err = env.ContractDeployer.DeployLinkTokenContract()
require.NoError(t, err, "Deploying Link Token Contract shouldn't fail")

for i := 0; i < 100; i++ {
err = actions.FundChainlinkNodesLocal(workerNodes, env.EVMClient, big.NewFloat(.05))
require.NoError(t, err, "Error funding Chainlink nodes")
}
err = actions.FundChainlinkNodesLocal(workerNodes, env.EVMClient, big.NewFloat(.05))
require.NoError(t, err, "Error funding Chainlink nodes")

// Gather transmitters
var transmitters []string
for _, node := range workerNodes {
addr, err := node.PrimaryEthAddress()
if err != nil {
require.NoError(t, fmt.Errorf("error getting node's primary ETH address: %w", err))
}
transmitters = append(transmitters, addr)
}

ocrOffchainOptions := contracts.DefaultOffChainAggregatorOptions()
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.MockAdapter, "ocr2", 5, env.EVMClient.GetChainID().Uint64(), false)
require.NoError(t, err, "Error creating OCRv2 jobs")

ocrv2Config, err := actions.BuildMedianOCR2ConfigLocal(workerNodes, ocrOffchainOptions)
require.NoError(t, err, "Error building OCRv2 config")

err = actions.ConfigureOCRv2AggregatorContracts(env.EVMClient, ocrv2Config, aggregatorContracts)
require.NoError(t, err, "Error configuring OCRv2 aggregator contracts")

err = actions.StartNewOCR2Round(1, aggregatorContracts, env.EVMClient, time.Minute*5, l)
require.NoError(t, err, "Error starting new OCR2 round")
roundData, err := aggregatorContracts[0].GetRound(testcontext.Get(t), big.NewInt(1))
require.NoError(t, err, "Getting latest answer from OCR contract shouldn't fail")
require.Equal(t, int64(5), roundData.Answer.Int64(),
"Expected latest answer from OCR contract to be 5 but got %d",
roundData.Answer.Int64(),
)

err = env.MockAdapter.SetAdapterBasedIntValuePath("ocr2", []string{http.MethodGet, http.MethodPost}, 10)
c := os.Getenv("EXECUTION_COUNT")
require.NoError(t, err)
err = actions.StartNewOCR2Round(2, aggregatorContracts, env.EVMClient, time.Minute*5, l)

count, err := strconv.Atoi(c)
require.NoError(t, err)

roundData, err = aggregatorContracts[0].GetRound(testcontext.Get(t), big.NewInt(2))
require.NoError(t, err, "Error getting latest OCR answer")
require.Equal(t, int64(10), roundData.Answer.Int64(),
"Expected latest answer from OCR contract to be 10 but got %d",
roundData.Answer.Int64(),
)
l.Info().Msgf("Execution count: %d", count)

for i := 0; i < count; i++ {
err = actions.FundChainlinkNodesLocal(workerNodes, env.EVMClient, big.NewFloat(.05))
require.NoError(t, err, "Error funding Chainlink nodes")
}
}

func TestOCRv2JobReplacement(t *testing.T) {
Expand Down

0 comments on commit fd57a65

Please sign in to comment.