diff --git a/lntest/harness_miner.go b/lntest/harness_miner.go index 189df54b1..bdbabe35b 100644 --- a/lntest/harness_miner.go +++ b/lntest/harness_miner.go @@ -42,7 +42,8 @@ type HarnessMiner struct { // runCtx is a context with cancel method. It's used to signal when the // node needs to quit, and used as the parent context when spawning - runCtx context.Context + // children contexts for RPC requests. + runCtx context.Context //nolint:containedctx cancel context.CancelFunc // logPath is the directory path of the miner's logs. diff --git a/lntest/harness_setup.go b/lntest/harness_setup.go index 666f59b2b..20442f9c2 100644 --- a/lntest/harness_setup.go +++ b/lntest/harness_setup.go @@ -27,7 +27,7 @@ func SetupHarness(t *testing.T, binaryPath, dbBackendName string, require.NoError(t, os.MkdirAll(logDir, 0700), "create log dir failed") // Parse database backend - dbBackend := prepareDbBackend(t, dbBackendName) + dbBackend := prepareDBBackend(t, dbBackendName) // Create a new HarnessTest. ht := NewHarnessTest(t, binaryPath, feeService, dbBackend) @@ -94,8 +94,8 @@ func prepareChainBackend(t *testing.T, } } -// prepareDbBackend parses a DatabaseBackend based on the name given. -func prepareDbBackend(t *testing.T, +// prepareDBBackend parses a DatabaseBackend based on the name given. +func prepareDBBackend(t *testing.T, dbBackendName string) node.DatabaseBackend { var dbBackend node.DatabaseBackend diff --git a/lntest/node/config.go b/lntest/node/config.go index 9a3b17a51..3e876c320 100644 --- a/lntest/node/config.go +++ b/lntest/node/config.go @@ -126,12 +126,12 @@ type BaseNodeConfig struct { // compiled with all required itest flags. LndBinary string - // backupDbDir is the path where a database backup is stored, if any. - backupDbDir string + // backupDBDir is the path where a database backup is stored, if any. + backupDBDir string - // postgresDbName is the name of the postgres database where lnd data + // postgresDBName is the name of the postgres database where lnd data // is stored in. - postgresDbName string + postgresDBName string } func (cfg BaseNodeConfig) P2PAddr() string { diff --git a/lntest/node/harness_node.go b/lntest/node/harness_node.go index 359a328e4..0d8d97a14 100644 --- a/lntest/node/harness_node.go +++ b/lntest/node/harness_node.go @@ -80,7 +80,7 @@ type HarnessNode struct { // runCtx is a context with cancel method. It's used to signal when the // node needs to quit, and used as the parent context when spawning // children contexts for RPC requests. - runCtx context.Context + runCtx context.Context //nolint:containedctx cancel context.CancelFunc // filename is the log file's name. @@ -118,7 +118,7 @@ func NewHarnessNode(t *testing.T, cfg *BaseNodeConfig) (*HarnessNode, error) { var dbName string if cfg.DBBackend == BackendPostgres { var err error - dbName, err = createTempPgDb() + dbName, err = createTempPgDB() if err != nil { return nil, err } @@ -126,7 +126,7 @@ func NewHarnessNode(t *testing.T, cfg *BaseNodeConfig) (*HarnessNode, error) { } cfg.OriginalExtraArgs = cfg.ExtraArgs - cfg.postgresDbName = dbName + cfg.postgresDBName = dbName return &HarnessNode{ T: t, @@ -614,8 +614,8 @@ func (hn *HarnessNode) attachPubKey() error { // cleanup cleans up all the temporary files created by the node's process. func (hn *HarnessNode) cleanup() error { - if hn.Cfg.backupDbDir != "" { - err := os.RemoveAll(hn.Cfg.backupDbDir) + if hn.Cfg.backupDBDir != "" { + err := os.RemoveAll(hn.Cfg.backupDBDir) if err != nil { return fmt.Errorf("unable to remove backup dir: %v", err) @@ -791,16 +791,16 @@ func (hn *HarnessNode) printErrf(format string, a ...interface{}) { // BackupDB creates a backup of the current database. func (hn *HarnessNode) BackupDB() error { - if hn.Cfg.backupDbDir != "" { + if hn.Cfg.backupDBDir != "" { return fmt.Errorf("backup already created") } - if hn.Cfg.postgresDbName != "" { + if hn.Cfg.postgresDBName != "" { // Backup database. - backupDBName := hn.Cfg.postgresDbName + "_backup" + backupDBName := hn.Cfg.postgresDBName + "_backup" err := executePgQuery( "CREATE DATABASE " + backupDBName + " WITH TEMPLATE " + - hn.Cfg.postgresDbName, + hn.Cfg.postgresDBName, ) if err != nil { return err @@ -818,7 +818,7 @@ func (hn *HarnessNode) BackupDB() error { err) } - hn.Cfg.backupDbDir = tempDir + hn.Cfg.backupDBDir = tempDir } return nil @@ -826,39 +826,39 @@ func (hn *HarnessNode) BackupDB() error { // RestoreDB restores a database backup. func (hn *HarnessNode) RestoreDB() error { - if hn.Cfg.postgresDbName != "" { + if hn.Cfg.postgresDBName != "" { // Restore database. - backupDBName := hn.Cfg.postgresDbName + "_backup" + backupDBName := hn.Cfg.postgresDBName + "_backup" err := executePgQuery( - "DROP DATABASE " + hn.Cfg.postgresDbName, + "DROP DATABASE " + hn.Cfg.postgresDBName, ) if err != nil { return err } err = executePgQuery( "ALTER DATABASE " + backupDBName + " RENAME TO " + - hn.Cfg.postgresDbName, + hn.Cfg.postgresDBName, ) if err != nil { return err } } else { // Restore files. - if hn.Cfg.backupDbDir == "" { + if hn.Cfg.backupDBDir == "" { return fmt.Errorf("no database backup created") } - err := copyAll(hn.Cfg.DBDir(), hn.Cfg.backupDbDir) + err := copyAll(hn.Cfg.DBDir(), hn.Cfg.backupDBDir) if err != nil { return fmt.Errorf("unable to copy database files: %w", err) } - if err := os.RemoveAll(hn.Cfg.backupDbDir); err != nil { + if err := os.RemoveAll(hn.Cfg.backupDBDir); err != nil { return fmt.Errorf("unable to remove backup dir: %w", err) } - hn.Cfg.backupDbDir = "" + hn.Cfg.backupDBDir = "" } return nil @@ -868,8 +868,8 @@ func postgresDatabaseDsn(dbName string) string { return fmt.Sprintf(postgresDsn, dbName) } -// createTempPgDb creates a temp postgres database. -func createTempPgDb() (string, error) { +// createTempPgDB creates a temp postgres database. +func createTempPgDB() (string, error) { // Create random database name. randBytes := make([]byte, 8) _, err := rand.Read(randBytes) diff --git a/lntest/rpc/harness_rpc.go b/lntest/rpc/harness_rpc.go index 9de698536..0e8256ce1 100644 --- a/lntest/rpc/harness_rpc.go +++ b/lntest/rpc/harness_rpc.go @@ -49,7 +49,7 @@ type HarnessRPC struct { // runCtx is a context with cancel method. It's used to signal when the // node needs to quit, and used as the parent context when spawning // children contexts for RPC requests. - runCtx context.Context + runCtx context.Context //nolint:containedctx cancel context.CancelFunc }