Skip to content

Commit

Permalink
Merge pull request #362 from smartcontractkit/tx-v3
Browse files Browse the repository at this point in the history
use TransactionV3
  • Loading branch information
archseer authored Feb 27, 2024
2 parents 0e7c67b + 33ef9f0 commit a8374fc
Show file tree
Hide file tree
Showing 8 changed files with 210 additions and 201 deletions.
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ golangci-lint 1.55.0
actionlint 1.6.12
shellcheck 0.8.0
scarb 2.5.4
postgres 13.3

# Kubernetes
k3d 5.4.4
Expand Down
10 changes: 5 additions & 5 deletions integration-tests/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ func debug(cmd *exec.Cmd) error {
panic(err)
}

if err := cmd.Start(); err != nil {
panic(err)
if startErr := cmd.Start(); startErr != nil {
panic(startErr)
}

doneStdOut := make(chan any)
Expand Down Expand Up @@ -362,8 +362,8 @@ func (c *Common) CreateJobsForContract(cc *ChainlinkClient, mockUrl string, obse
// Defining relay config
bootstrapRelayConfig := job.JSONConfig{
"nodeName": fmt.Sprintf("starknet-OCRv2-%s-%s", "node", uuid.New().String()),
"accountAddress": fmt.Sprintf("%s", accountAddresses[0]),
"chainID": fmt.Sprintf("%s", c.ChainId),
"accountAddress": accountAddresses[0],
"chainID": c.ChainId,
}

oracleSpec := job.OCR2OracleSpec{
Expand Down Expand Up @@ -407,7 +407,7 @@ func (c *Common) CreateJobsForContract(cc *ChainlinkClient, mockUrl string, obse
}
relayConfig := job.JSONConfig{
"nodeName": bootstrapRelayConfig["nodeName"],
"accountAddress": fmt.Sprintf("%s", accountAddresses[nIdx]),
"accountAddress": accountAddresses[nIdx],
"chainID": bootstrapRelayConfig["chainID"],
}

Expand Down
182 changes: 91 additions & 91 deletions integration-tests/infra_deployments/deployer_test.go
Original file line number Diff line number Diff line change
@@ -1,100 +1,100 @@
package infra_deployments_test

import (
"fmt"
"net/url"
"testing"
//import (
//"fmt"
//"net/url"
//"testing"

"github.com/stretchr/testify/require"
//"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink-starknet/integration-tests/common"
"github.com/smartcontractkit/chainlink-starknet/ops/gauntlet"
"github.com/smartcontractkit/chainlink-starknet/ops/utils"
"github.com/smartcontractkit/chainlink/integration-tests/client"
)
//"github.com/smartcontractkit/chainlink-starknet/integration-tests/common"
//"github.com/smartcontractkit/chainlink-starknet/ops/gauntlet"
//"github.com/smartcontractkit/chainlink-starknet/ops/utils"
//"github.com/smartcontractkit/chainlink/integration-tests/client"
//)

const (
L2RpcUrl = "https://alpha4-2.starknet.io"
P2pPort = "6691"
)
//const (
//L2RpcUrl = "https://alpha4-2.starknet.io"
//P2pPort = "6691"
//)

var (
observationSource = `
val [type="bridge" name="bridge-coinmetrics" requestData=<{"data": {"from":"LINK","to":"USD"}}>]
parse [type="jsonparse" path="result"]
val -> parse
`
juelsPerFeeCoinSource = `"""
sum [type="sum" values=<[451000]> ]
sum
"""
`
)
//var (
//observationSource = `
//val [type="bridge" name="bridge-coinmetrics" requestData=<{"data": {"from":"LINK","to":"USD"}}>]
//parse [type="jsonparse" path="result"]
//val -> parse
//`
//juelsPerFeeCoinSource = `"""
//sum [type="sum" values=<[451000]> ]
//sum
//"""
//`
//)

func createKeys(testState *testing.T) ([]*client.ChainlinkK8sClient, error) {
urls := [][]string{
// Node access params
{"NODE_URL", "NODE_USER", "NODE_PASS"},
}
var clients []*client.ChainlinkK8sClient
//func createKeys(testState *testing.T) ([]*client.ChainlinkK8sClient, error) {
//urls := [][]string{
//// Node access params
//{"NODE_URL", "NODE_USER", "NODE_PASS"},
//}
//var clients []*client.ChainlinkK8sClient

for _, nodeUrl := range urls {
u, _ := url.Parse(nodeUrl[0])
c, err := client.NewChainlinkK8sClient(&client.ChainlinkConfig{
URL: nodeUrl[0],
Email: nodeUrl[1],
Password: nodeUrl[2],
InternalIP: u.Host,
}, "", "")
if err != nil {
return nil, err
}
key, _ := c.MustReadP2PKeys()
if key == nil {
_, _, err = c.CreateP2PKey()
require.NoError(testState, err)
}
clients = append(clients, c)
}
return clients, nil
}
func TestOCRBasic(testState *testing.T) {
var err error
t := &common.Test{}
t.Common = common.New(testState)
t.Cc = &common.ChainlinkClient{}
t.Common.P2PPort = P2pPort
t.Cc.ChainlinkNodes, err = createKeys(testState)
require.NoError(testState, err)
t.Cc.NKeys, _, err = client.CreateNodeKeysBundle(t.GetChainlinkNodes(), t.Common.ChainName, t.Common.ChainId)
require.NoError(testState, err)
for _, n := range t.Cc.ChainlinkNodes {
_, _, err = n.CreateStarkNetChain(&client.StarkNetChainAttributes{
Type: t.Common.ChainName,
ChainID: t.Common.ChainId,
Config: client.StarkNetChainConfig{},
})
require.NoError(testState, err)
_, _, err = n.CreateStarkNetNode(&client.StarkNetNodeAttributes{
Name: t.Common.ChainName,
ChainID: t.Common.ChainId,
Url: L2RpcUrl,
})
require.NoError(testState, err)
}
t.Common.Testnet = true
t.Common.L2RPCUrl = L2RpcUrl
t.Sg, err = gauntlet.NewStarknetGauntlet(fmt.Sprintf("%s/", utils.ProjectRoot))
require.NoError(testState, err, "Could not get a new gauntlet struct")
err = t.Sg.SetupNetwork(t.Common.L2RPCUrl)
require.NoError(testState, err, "Setting up gauntlet network should not fail")
err = t.DeployGauntlet(0, 100000000000, 9, "auto", 1, 1)
require.NoError(testState, err, "Deploying contracts should not fail")
t.SetBridgeTypeAttrs(&client.BridgeTypeAttributes{
Name: "bridge-coinmetrics",
URL: "ADAPTER_URL", // ADAPTER_URL e.g https://adapters.main.sand.cldev.sh/coinmetrics
})
//for _, nodeUrl := range urls {
//u, _ := url.Parse(nodeUrl[0])
//c, err := client.NewChainlinkK8sClient(&client.ChainlinkConfig{
//URL: nodeUrl[0],
//Email: nodeUrl[1],
//Password: nodeUrl[2],
//InternalIP: u.Host,
//}, "", "")
//if err != nil {
//return nil, err
//}
//key, _ := c.MustReadP2PKeys()
//if key == nil {
//_, _, err = c.CreateP2PKey()
//require.NoError(testState, err)
//}
//clients = append(clients, c)
//}
//return clients, nil
//}
//func TestOCRBasic(testState *testing.T) {
//var err error
//t := &common.Test{}
//t.Common = common.New(testState)
//t.Cc = &common.ChainlinkClient{}
//t.Common.P2PPort = P2pPort
//t.Cc.ChainlinkNodes, err = createKeys(testState)
//require.NoError(testState, err)
//t.Cc.NKeys, _, err = client.CreateNodeKeysBundle(t.GetChainlinkNodes(), t.Common.ChainName, t.Common.ChainId)
//require.NoError(testState, err)
//for _, n := range t.Cc.ChainlinkNodes {
//_, _, err = n.CreateStarkNetChain(&client.StarkNetChainAttributes{
//Type: t.Common.ChainName,
//ChainID: t.Common.ChainId,
//Config: client.StarkNetChainConfig{},
//})
//require.NoError(testState, err)
//_, _, err = n.CreateStarkNetNode(&client.StarkNetNodeAttributes{
//Name: t.Common.ChainName,
//ChainID: t.Common.ChainId,
//Url: L2RpcUrl,
//})
//require.NoError(testState, err)
//}
//t.Common.Testnet = true
//t.Common.L2RPCUrl = L2RpcUrl
//t.Sg, err = gauntlet.NewStarknetGauntlet(fmt.Sprintf("%s/", utils.ProjectRoot))
//require.NoError(testState, err, "Could not get a new gauntlet struct")
//err = t.Sg.SetupNetwork(t.Common.L2RPCUrl)
//require.NoError(testState, err, "Setting up gauntlet network should not fail")
//err = t.DeployGauntlet(0, 100000000000, 9, "auto", 1, 1)
//require.NoError(testState, err, "Deploying contracts should not fail")
//t.SetBridgeTypeAttrs(&client.BridgeTypeAttributes{
//Name: "bridge-coinmetrics",
//URL: "ADAPTER_URL", // ADAPTER_URL e.g https://adapters.main.sand.cldev.sh/coinmetrics
//})

err = t.Common.CreateJobsForContract(t.Cc, observationSource, juelsPerFeeCoinSource, t.OCRAddr, t.AccountAddresses)
require.NoError(testState, err)
}
//err = t.Common.CreateJobsForContract(t.Cc, observationSource, juelsPerFeeCoinSource, t.OCRAddr, t.AccountAddresses)
//require.NoError(testState, err)
//}
94 changes: 47 additions & 47 deletions integration-tests/soak/ocr2_test.go
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
package soak_test

import (
"flag"
"fmt"
"testing"
//import (
//"flag"
//"fmt"
//"testing"

"github.com/stretchr/testify/require"
"go.uber.org/zap/zapcore"
//"github.com/stretchr/testify/require"
//"go.uber.org/zap/zapcore"

"github.com/smartcontractkit/chainlink-starknet/integration-tests/common"
"github.com/smartcontractkit/chainlink-starknet/ops/gauntlet"
"github.com/smartcontractkit/chainlink-starknet/ops/utils"
//"github.com/smartcontractkit/chainlink-starknet/integration-tests/common"
//"github.com/smartcontractkit/chainlink-starknet/ops/gauntlet"
//"github.com/smartcontractkit/chainlink-starknet/ops/utils"

"github.com/smartcontractkit/chainlink/integration-tests/actions"
)
//"github.com/smartcontractkit/chainlink/integration-tests/actions"
//)

var (
keepAlive bool
err error
testState *common.Test
decimals = 9
)
//var (
//keepAlive bool
//err error
//testState *common.Test
//decimals = 9
//)

func init() {
flag.BoolVar(&keepAlive, "keep-alive", false, "enable to keep the cluster alive")
}
func TestOCRSoak(t *testing.T) {
testState = &common.Test{
T: t,
}
testState.Common = common.New(t)
// Setting this to the root of the repo for cmd exec func for Gauntlet
testState.Sg, err = gauntlet.NewStarknetGauntlet(fmt.Sprintf("%s/", utils.ProjectRoot))
require.NoError(t, err, "Could not get a new gauntlet struct")
testState.DeployCluster()
require.NoError(t, err, "Deploying cluster should not fail")
if testState.Common.Env.WillUseRemoteRunner() {
return // short circuit here if using a remote runner
}
err = testState.Sg.SetupNetwork(testState.Common.L2RPCUrl)
require.NoError(t, err, "Setting up network should not fail")
err = testState.DeployGauntlet(0, 100000000000, decimals, "auto", 1, 1)
require.NoError(t, err, "Deploying contracts should not fail")
if !testState.Common.Testnet {
testState.Devnet.AutoLoadState(testState.OCR2Client, testState.OCRAddr)
}
err = testState.ValidateRounds(99999999, true)
require.NoError(t, err, "Validating round should not fail")
t.Cleanup(func() {
err = actions.TeardownSuite(t, testState.Common.Env, testState.Cc.ChainlinkNodes, nil, zapcore.ErrorLevel, nil, nil)
require.NoError(t, err, "Error tearing down environment")
})
}
//func init() {
//flag.BoolVar(&keepAlive, "keep-alive", false, "enable to keep the cluster alive")
//}
//func TestOCRSoak(t *testing.T) {
//testState = &common.Test{
//T: t,
//}
//testState.Common = common.New(t)
//// Setting this to the root of the repo for cmd exec func for Gauntlet
//testState.Sg, err = gauntlet.NewStarknetGauntlet(fmt.Sprintf("%s/", utils.ProjectRoot))
//require.NoError(t, err, "Could not get a new gauntlet struct")
//testState.DeployCluster()
//require.NoError(t, err, "Deploying cluster should not fail")
//if testState.Common.Env.WillUseRemoteRunner() {
//return // short circuit here if using a remote runner
//}
//err = testState.Sg.SetupNetwork(testState.Common.L2RPCUrl)
//require.NoError(t, err, "Setting up network should not fail")
//err = testState.DeployGauntlet(0, 100000000000, decimals, "auto", 1, 1)
//require.NoError(t, err, "Deploying contracts should not fail")
//if !testState.Common.Testnet {
//testState.Devnet.AutoLoadState(testState.OCR2Client, testState.OCRAddr)
//}
//err = testState.ValidateRounds(99999999, true)
//require.NoError(t, err, "Validating round should not fail")
//t.Cleanup(func() {
//err = actions.TeardownSuite(t, testState.Common.Env, testState.Cc.ChainlinkNodes, nil, zapcore.ErrorLevel, nil, nil)
//require.NoError(t, err, "Error tearing down environment")
//})
//}
11 changes: 10 additions & 1 deletion ops/devnet/devnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,16 @@ func (devnet *StarknetDevnetClient) FundAccounts(l2AccList []string) error {
if err != nil {
return err
}
log.Info().Msg(fmt.Sprintf("Funding account: %s", string(res.Body())))
log.Info().Msg(fmt.Sprintf("Funding account (WEI): %s", string(res.Body())))
res, err = devnet.client.R().SetBody(map[string]any{
"address": key,
"amount": 900000000000000000,
"unit": "FRI",
}).Post("/mint")
if err != nil {
return err
}
log.Info().Msg(fmt.Sprintf("Funding account (FRI): %s", string(res.Body())))
}
return nil
}
Expand Down
Loading

0 comments on commit a8374fc

Please sign in to comment.