-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge integration-tests Folder #1159
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ package actions | |
import ( | ||
"context" | ||
"crypto/ecdsa" | ||
"encoding/json" | ||
"fmt" | ||
"math" | ||
"math/big" | ||
|
@@ -13,7 +12,6 @@ import ( | |
"testing" | ||
"time" | ||
|
||
"github.com/ethereum/go-ethereum/accounts/keystore" | ||
"github.com/pelletier/go-toml/v2" | ||
|
||
geth "github.com/ethereum/go-ethereum" | ||
|
@@ -26,7 +24,6 @@ import ( | |
"github.com/smartcontractkit/chainlink-testing-framework/logging" | ||
"github.com/smartcontractkit/chainlink-testing-framework/testreporters" | ||
"github.com/smartcontractkit/chainlink-testing-framework/utils/conversions" | ||
|
||
"github.com/smartcontractkit/chainlink/integration-tests/contracts" | ||
ethContracts "github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum" | ||
|
||
|
@@ -667,45 +664,6 @@ func ConfigureOCRv2AggregatorContracts( | |
return nil | ||
} | ||
|
||
// ReturnFunds attempts to return all the funds from the chainlink nodes to the network's default address | ||
// all from a remote, k8s style environment | ||
// Remove this once ccip-tests are moved to seth client | ||
func ReturnFunds(lggr zerolog.Logger, chainlinkNodes []*client.ChainlinkK8sClient, blockchainClient blockchain.EVMClient) error { | ||
if blockchainClient == nil { | ||
return fmt.Errorf("blockchain client is nil, unable to return funds from chainlink nodes") | ||
} | ||
lggr.Info().Msg("Attempting to return Chainlink node funds to default network wallets") | ||
if blockchainClient.NetworkSimulated() { | ||
lggr.Info().Str("Network Name", blockchainClient.GetNetworkName()). | ||
Msg("Network is a simulated network. Skipping fund return.") | ||
return nil | ||
} | ||
|
||
for _, chainlinkNode := range chainlinkNodes { | ||
fundedKeys, err := chainlinkNode.ExportEVMKeysForChain(blockchainClient.GetChainID().String()) | ||
if err != nil { | ||
return err | ||
} | ||
for _, key := range fundedKeys { | ||
keyToDecrypt, err := json.Marshal(key) | ||
if err != nil { | ||
return err | ||
} | ||
// This can take up a good bit of RAM and time. When running on the remote-test-runner, this can lead to OOM | ||
// issues. So we avoid running in parallel; slower, but safer. | ||
decryptedKey, err := keystore.DecryptKey(keyToDecrypt, client.ChainlinkKeyPassword) | ||
if err != nil { | ||
return err | ||
} | ||
err = blockchainClient.ReturnFunds(decryptedKey.PrivateKey) | ||
if err != nil { | ||
lggr.Error().Err(err).Str("Address", fundedKeys[0].Address).Msg("Error returning funds from Chainlink node") | ||
} | ||
} | ||
} | ||
return blockchainClient.WaitForEvents() | ||
} | ||
|
||
// TeardownSuite tears down networks/clients and environment and creates a logs folder for failed tests in the | ||
// specified path. Can also accept a testreporter (if one was used) to log further results | ||
func TeardownSuite( | ||
|
@@ -716,7 +674,6 @@ func TeardownSuite( | |
optionalTestReporter testreporters.TestReporter, // Optionally pass in a test reporter to log further metrics | ||
failingLogLevel zapcore.Level, // Examines logs after the test, and fails the test if any Chainlink logs are found at or above provided level | ||
grafnaUrlProvider testreporters.GrafanaURLProvider, | ||
evmClients ...blockchain.EVMClient, | ||
) error { | ||
l := logging.GetTestLogger(t) | ||
if err := testreporters.WriteTeardownLogs(t, env, optionalTestReporter, failingLogLevel, grafnaUrlProvider); err != nil { | ||
|
@@ -728,7 +685,7 @@ func TeardownSuite( | |
l.Warn().Msgf("Error deleting jobs %+v", err) | ||
} | ||
|
||
if chainlinkNodes != nil && chainClient != nil { | ||
if chainlinkNodes != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should not change |
||
if err := ReturnFundsFromNodes(l, chainClient, contracts.ChainlinkK8sClientToChainlinkNodeWithKeysAndAddress(chainlinkNodes)); err != nil { | ||
// This printed line is required for tests that use real funds to propagate the failure | ||
// out to the system running the test. Do not remove | ||
|
@@ -740,29 +697,6 @@ func TeardownSuite( | |
} else { | ||
l.Info().Msg("Successfully returned funds from chainlink nodes to default network wallets") | ||
} | ||
// The following is needed for tests using EVMClient, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to bring this back |
||
// Remove this once ccip-tests are moved to seth client | ||
for _, c := range evmClients { | ||
if c != nil && chainlinkNodes != nil && len(chainlinkNodes) > 0 { | ||
if err := ReturnFunds(l, chainlinkNodes, c); err != nil { | ||
// This printed line is required for tests that use real funds to propagate the failure | ||
// out to the system running the test. Do not remove | ||
fmt.Println(environment.FAILED_FUND_RETURN) | ||
l.Error().Err(err).Str("Namespace", env.Cfg.Namespace). | ||
Msg("Error attempting to return funds from chainlink nodes to network's default wallet. " + | ||
"Environment is left running so you can try manually!") | ||
} | ||
} else { | ||
l.Info().Msg("Successfully returned funds from chainlink nodes to default network wallets") | ||
} | ||
// nolint | ||
if c != nil { | ||
err := c.Close() | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
} | ||
|
||
return env.Shutdown() | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import ( | |
"strconv" | ||
"testing" | ||
|
||
"github.com/ethereum/go-ethereum/core/types" | ||
"github.com/google/uuid" | ||
"github.com/pkg/errors" | ||
"github.com/smartcontractkit/seth" | ||
|
@@ -115,7 +116,7 @@ func DeployKeeperContracts( | |
} | ||
|
||
registrar := DeployKeeperRegistrar(t, client, registryVersion, linkToken, registrarSettings, registry) | ||
upkeeps, upkeepIds := DeployConsumers(t, client, registry, registrar, linkToken, numberOfUpkeeps, linkFundsForEachUpkeep, upkeepGasLimit, false, false) | ||
upkeeps, upkeepIds := DeployConsumers(t, client, registry, registrar, linkToken, numberOfUpkeeps, linkFundsForEachUpkeep, upkeepGasLimit, false, false, false, nil) | ||
|
||
return registry, registrar, upkeeps, upkeepIds | ||
} | ||
|
@@ -178,7 +179,7 @@ func DeployPerformanceKeeperContracts( | |
upkeepsAddresses = append(upkeepsAddresses, upkeep.Address()) | ||
} | ||
|
||
upkeepIds := RegisterUpkeepContracts(t, chainClient, linkToken, linkFundsForEachUpkeep, upkeepGasLimit, registry, registrar, numberOfContracts, upkeepsAddresses, false, false) | ||
upkeepIds := RegisterUpkeepContracts(t, chainClient, linkToken, linkFundsForEachUpkeep, upkeepGasLimit, registry, registrar, numberOfContracts, upkeepsAddresses, false, false, false, nil) | ||
|
||
return registry, registrar, upkeeps, upkeepIds | ||
} | ||
|
@@ -236,7 +237,7 @@ func DeployPerformDataCheckerContracts( | |
upkeepsAddresses = append(upkeepsAddresses, upkeep.Address()) | ||
} | ||
|
||
upkeepIds := RegisterUpkeepContracts(t, chainClient, linkToken, linkFundsForEachUpkeep, upkeepGasLimit, registry, registrar, numberOfContracts, upkeepsAddresses, false, false) | ||
upkeepIds := RegisterUpkeepContracts(t, chainClient, linkToken, linkFundsForEachUpkeep, upkeepGasLimit, registry, registrar, numberOfContracts, upkeepsAddresses, false, false, false, nil) | ||
|
||
return registry, registrar, upkeeps, upkeepIds | ||
} | ||
|
@@ -259,14 +260,14 @@ func DeployKeeperRegistrar( | |
return registrar | ||
} | ||
|
||
func RegisterUpkeepContracts(t *testing.T, client *seth.Client, linkToken contracts.LinkToken, linkFunds *big.Int, upkeepGasLimit uint32, registry contracts.KeeperRegistry, registrar contracts.KeeperRegistrar, numberOfContracts int, upkeepAddresses []string, isLogTrigger bool, isMercury bool) []*big.Int { | ||
func RegisterUpkeepContracts(t *testing.T, client *seth.Client, linkToken contracts.LinkToken, fundsForEachUpkeep *big.Int, upkeepGasLimit uint32, registry contracts.KeeperRegistry, registrar contracts.KeeperRegistrar, numberOfContracts int, upkeepAddresses []string, isLogTrigger bool, isMercury bool, isBillingTokenNative bool, wethToken contracts.WETHToken) []*big.Int { | ||
checkData := make([][]byte, 0) | ||
for i := 0; i < numberOfContracts; i++ { | ||
checkData = append(checkData, []byte("0")) | ||
} | ||
return RegisterUpkeepContractsWithCheckData( | ||
t, client, linkToken, linkFunds, upkeepGasLimit, registry, registrar, | ||
numberOfContracts, upkeepAddresses, checkData, isLogTrigger, isMercury) | ||
t, client, linkToken, fundsForEachUpkeep, upkeepGasLimit, registry, registrar, | ||
numberOfContracts, upkeepAddresses, checkData, isLogTrigger, isMercury, isBillingTokenNative, wethToken) | ||
} | ||
|
||
type upkeepRegistrationResult struct { | ||
|
@@ -284,7 +285,7 @@ type upkeepConfig struct { | |
|
||
type UpkeepId = *big.Int | ||
|
||
func RegisterUpkeepContractsWithCheckData(t *testing.T, client *seth.Client, linkToken contracts.LinkToken, linkFunds *big.Int, upkeepGasLimit uint32, registry contracts.KeeperRegistry, registrar contracts.KeeperRegistrar, numberOfContracts int, upkeepAddresses []string, checkData [][]byte, isLogTrigger bool, isMercury bool) []*big.Int { | ||
func RegisterUpkeepContractsWithCheckData(t *testing.T, client *seth.Client, linkToken contracts.LinkToken, fundsForEachUpkeep *big.Int, upkeepGasLimit uint32, registry contracts.KeeperRegistry, registrar contracts.KeeperRegistrar, numberOfContracts int, upkeepAddresses []string, checkData [][]byte, isLogTrigger bool, isMercury bool, isBillingTokenNative bool, wethToken contracts.WETHToken) []*big.Int { | ||
l := logging.GetTestLogger(t) | ||
|
||
concurrency, err := GetAndAssertCorrectConcurrency(client, 1) | ||
|
@@ -300,45 +301,69 @@ func RegisterUpkeepContractsWithCheckData(t *testing.T, client *seth.Client, lin | |
var registerUpkeepFn = func(resultCh chan upkeepRegistrationResult, errorCh chan error, executorNum int, config upkeepConfig) { | ||
id := uuid.New().String() | ||
keyNum := executorNum + 1 // key 0 is the root key | ||
var tx *types.Transaction | ||
|
||
if isBillingTokenNative { | ||
// register upkeep with native token | ||
tx, err = registrar.RegisterUpkeepFromKey( | ||
keyNum, | ||
fmt.Sprintf("upkeep_%s", id), | ||
[]byte("[email protected]"), | ||
config.address, | ||
upkeepGasLimit, | ||
client.MustGetRootKeyAddress().Hex(), // upkeep Admin | ||
config.data, | ||
fundsForEachUpkeep, | ||
wethToken.Address(), | ||
isLogTrigger, | ||
isMercury, | ||
) | ||
if err != nil { | ||
errorCh <- errors.Wrapf(err, "[id: %s] Failed to register upkeep at %s", id, config.address) | ||
return | ||
} | ||
} else { | ||
// register upkeep with LINK | ||
req, err := registrar.EncodeRegisterRequest( | ||
fmt.Sprintf("upkeep_%s", id), | ||
[]byte("[email protected]"), | ||
config.address, | ||
upkeepGasLimit, | ||
client.MustGetRootKeyAddress().Hex(), // upkeep Admin | ||
config.data, | ||
fundsForEachUpkeep, | ||
0, | ||
client.Addresses[keyNum].Hex(), | ||
isLogTrigger, | ||
isMercury, | ||
linkToken.Address(), | ||
) | ||
|
||
if err != nil { | ||
errorCh <- errors.Wrapf(err, "[id: %s] Failed to encode register request for upkeep at %s", id, config.address) | ||
return | ||
} | ||
|
||
req, err := registrar.EncodeRegisterRequest( | ||
fmt.Sprintf("upkeep_%s", id), | ||
[]byte("[email protected]"), | ||
config.address, | ||
upkeepGasLimit, | ||
client.MustGetRootKeyAddress().Hex(), // upkeep Admin | ||
config.data, | ||
linkFunds, | ||
0, | ||
client.Addresses[keyNum].Hex(), | ||
isLogTrigger, | ||
isMercury, | ||
linkToken.Address(), | ||
) | ||
|
||
if err != nil { | ||
errorCh <- errors.Wrapf(err, "[id: %s] Failed to encode register request for upkeep at %s", id, config.address) | ||
return | ||
} | ||
|
||
balance, err := linkToken.BalanceOf(context.Background(), client.Addresses[keyNum].Hex()) | ||
if err != nil { | ||
errorCh <- errors.Wrapf(err, "[id: %s]Failed to get LINK balance of %s", id, client.Addresses[keyNum].Hex()) | ||
return | ||
} | ||
balance, err := linkToken.BalanceOf(context.Background(), client.Addresses[keyNum].Hex()) | ||
if err != nil { | ||
errorCh <- errors.Wrapf(err, "[id: %s]Failed to get LINK balance of %s", id, client.Addresses[keyNum].Hex()) | ||
return | ||
} | ||
|
||
// not stricly necessary, but helps us to avoid an errorless revert if there is not enough LINK | ||
if balance.Cmp(linkFunds) < 0 { | ||
errorCh <- fmt.Errorf("[id: %s] Not enough LINK balance for %s. Has: %s. Needs: %s", id, client.Addresses[keyNum].Hex(), balance.String(), linkFunds.String()) | ||
return | ||
} | ||
// not strictly necessary, but helps us to avoid an errorless revert if there is not enough LINK | ||
if balance.Cmp(fundsForEachUpkeep) < 0 { | ||
errorCh <- fmt.Errorf("[id: %s] Not enough LINK balance for %s. Has: %s. Needs: %s", id, client.Addresses[keyNum].Hex(), balance.String(), fundsForEachUpkeep.String()) | ||
return | ||
} | ||
|
||
tx, err := linkToken.TransferAndCallFromKey(registrar.Address(), linkFunds, req, keyNum) | ||
if err != nil { | ||
errorCh <- errors.Wrapf(err, "[id: %s] Failed to register upkeep at %s", id, config.address) | ||
return | ||
tx, err = linkToken.TransferAndCallFromKey(registrar.Address(), fundsForEachUpkeep, req, keyNum) | ||
if err != nil { | ||
errorCh <- errors.Wrapf(err, "[id: %s] Failed to register upkeep at %s", id, config.address) | ||
return | ||
} | ||
} | ||
|
||
// parse txn to get upkeep ID | ||
receipt, err := client.Client.TransactionReceipt(context.Background(), tx.Hash()) | ||
if err != nil { | ||
errorCh <- errors.Wrapf(err, "[id: %s] Failed to get receipt for upkeep at %s and tx hash %s", id, config.address, tx.Hash()) | ||
|
@@ -405,10 +430,10 @@ func DeployKeeperConsumers(t *testing.T, client *seth.Client, numberOfContracts | |
// v2.1 only: Conditional based contract with Mercury enabled | ||
keeperConsumerInstance, err = contracts.DeployAutomationStreamsLookupUpkeepConsumerFromKey(client, keyNum, big.NewInt(1000), big.NewInt(5), false, true, false) // 1000 block test range | ||
} else if isLogTrigger { | ||
// v2.1 only: Log triggered based contract without Mercury | ||
// v2.1+: Log triggered based contract without Mercury | ||
keeperConsumerInstance, err = contracts.DeployAutomationLogTriggerConsumerFromKey(client, keyNum, big.NewInt(1000)) // 1000 block test range | ||
} else { | ||
// v2.0 and v2.1: Conditional based contract without Mercury | ||
// v2.0+: Conditional based contract without Mercury | ||
keeperConsumerInstance, err = contracts.DeployUpkeepCounterFromKey(client, keyNum, big.NewInt(999999), big.NewInt(5)) | ||
} | ||
|
||
|
@@ -580,7 +605,7 @@ func RegisterNewUpkeeps( | |
err = SendLinkFundsToDeploymentAddresses(chainClient, concurrency, numberOfNewUpkeeps, operationsPerAddress, multicallAddress, linkFundsForEachUpkeep, linkToken) | ||
require.NoError(t, err, "Sending link funds to deployment addresses shouldn't fail") | ||
|
||
newUpkeepIDs := RegisterUpkeepContracts(t, chainClient, linkToken, linkFundsForEachUpkeep, upkeepGasLimit, registry, registrar, numberOfNewUpkeeps, addressesOfNewUpkeeps, false, false) | ||
newUpkeepIDs := RegisterUpkeepContracts(t, chainClient, linkToken, linkFundsForEachUpkeep, upkeepGasLimit, registry, registrar, numberOfNewUpkeeps, addressesOfNewUpkeeps, false, false, false, nil) | ||
|
||
return newlyDeployedUpkeeps, newUpkeepIDs | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to bring this back