Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions core/cmd/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@ func removeHidden(cmds ...cli.Command) []cli.Command {

// NewApp returns the command-line parser/function-router for the given client
func NewApp(s *Shell) *cli.App {
var opts chainlink.GeneralConfigOpts
return newAppWithOpts(s, opts)
}

// newAppWithOpts returns the command-line parser/function-router for the given client
// with custom configuration options for testing purposes.
func newAppWithOpts(s *Shell, opts chainlink.GeneralConfigOpts) *cli.App {
app := cli.NewApp()
app.Usage = "CLI for Chainlink"
app.Version = fmt.Sprintf("%v@%v", static.Version, static.Sha)
// TOML
var opts chainlink.GeneralConfigOpts

app.Flags = []cli.Flag{
cli.BoolFlag{
Expand Down
11 changes: 11 additions & 0 deletions core/cmd/export_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package cmd

import (
"github.com/urfave/cli"

"github.com/smartcontractkit/chainlink/v2/core/services/chainlink"
)

func NewAppWithOptsForTest(s *Shell, opts chainlink.GeneralConfigOpts) *cli.App {
return newAppWithOpts(s, opts)
}
22 changes: 20 additions & 2 deletions core/cmd/shell_local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ func TestShell_DiskMaxSizeBeforeRotateOptionDisablesAsExpected(t *testing.T) {
}

func TestShell_RebroadcastTransactions_Txm(t *testing.T) {
t.Parallel()
// Use a non-transactional db for this test because we need to
// test multiple connections to the database, and changes made within
// the transaction cannot be seen from another connection.
Expand Down Expand Up @@ -269,6 +270,7 @@ func TestShell_RebroadcastTransactions_Txm(t *testing.T) {
}

func TestShell_RebroadcastTransactions_OutsideRange_Txm(t *testing.T) {
t.Parallel()
beginningNonce := uint(7)
endingNonce := uint(10)
gasPrice := big.NewInt(100000000000)
Expand All @@ -284,6 +286,7 @@ func TestShell_RebroadcastTransactions_OutsideRange_Txm(t *testing.T) {

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
t.Parallel()
// Use the non-transactional db for this test because we need to
// test multiple connections to the database, and changes made within
// the transaction cannot be seen from another connection.
Expand Down Expand Up @@ -357,6 +360,7 @@ func TestShell_RebroadcastTransactions_OutsideRange_Txm(t *testing.T) {
}

func TestShell_RebroadcastTransactions_AddressCheck(t *testing.T) {
t.Parallel()
tests := []struct {
name string
enableAddress bool
Expand All @@ -369,6 +373,7 @@ func TestShell_RebroadcastTransactions_AddressCheck(t *testing.T) {

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
t.Parallel()
config, sqlxDB := heavyweight.FullTestDBV2(t, func(c *chainlink.Config, s *chainlink.Secrets) {
c.Database.DriverName = pgcommon.DriverPostgres

Expand Down Expand Up @@ -544,7 +549,14 @@ func TestShell_BeforeNode(t *testing.T) {
c := cli.NewContext(nil, set, nil)

// Create full CLI app and run the Before hook first
app := cmd.NewApp(&shell)
var opts = chainlink.GeneralConfigOpts{
OverrideFn: func(c *chainlink.Config, s *chainlink.Secrets) {
s.Password.Keystore = models.NewSecret("dummy")
c.Database.DriverName = pgcommon.DriverTxWrappedPostgres
},
}

app := cmd.NewAppWithOptsForTest(&shell, opts)
err := app.Before(c)
if err != nil && test.wantUnlocked {
t.Fatalf("CLI Before hook failed: %v", err)
Expand Down Expand Up @@ -641,8 +653,14 @@ func TestShell_RunNode_WithBeforeNode(t *testing.T) {

c := cli.NewContext(nil, set, nil)

var opts = chainlink.GeneralConfigOpts{
OverrideFn: func(c *chainlink.Config, s *chainlink.Secrets) {
c.Database.DriverName = pgcommon.DriverTxWrappedPostgres
},
}

// First initialize components (this includes authentication)
cliApp := cmd.NewApp(&shell)
cliApp := cmd.NewAppWithOptsForTest(&shell, opts)
err := cliApp.Before(c)
require.NoError(t, err)

Expand Down
5 changes: 5 additions & 0 deletions core/services/keystore/csa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ func Test_CSAKeyStore_E2E(t *testing.T) {
t.Run("initializes with an empty state", func(t *testing.T) {
defer reset()
keys, err := ks.GetAll()

for _, key := range keys {
t.Log("unexpected key found in keystore", "id", key.ID())
}

require.NoError(t, err)
require.Empty(t, keys)
})
Expand Down
Loading