Skip to content
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

chore(*): backport #66

Merged
merged 2 commits into from
Sep 26, 2024
Merged
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
12 changes: 6 additions & 6 deletions config/dbconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,31 @@ const (
type DBConfig struct {
// DBPath is the directory path in which the database file should be
// stored.
DBPath string `long:"dbpath" description:"The directory path in which the database file should be stored."`
DBPath string `mapstructure:"dbpath"`

// DBFileName is the name of the database file.
DBFileName string `long:"dbfilename" description:"The name of the database file."`
DBFileName string `mapstructure:"dbfilename"`

// NoFreelistSync, if true, prevents the database from syncing its
// freelist to disk, resulting in improved performance at the expense of
// increased startup time.
NoFreelistSync bool `long:"nofreelistsync" description:"Prevents the database from syncing its freelist to disk, resulting in improved performance at the expense of increased startup time."`
NoFreelistSync bool `mapstructure:"nofreelistsync"`

// AutoCompact specifies if a Bolt based database backend should be
// automatically compacted on startup (if the minimum age of the
// database file is reached). This will require additional disk space
// for the compacted copy of the database but will result in an overall
// lower database size after the compaction.
AutoCompact bool `long:"autocompact" description:"Specifies if a Bolt based database backend should be automatically compacted on startup (if the minimum age of the database file is reached). This will require additional disk space for the compacted copy of the database but will result in an overall lower database size after the compaction."`
AutoCompact bool `mapstructure:"autocompact"`

// AutoCompactMinAge specifies the minimum time that must have passed
// since a bolt database file was last compacted for the compaction to
// be considered again.
AutoCompactMinAge time.Duration `long:"autocompactminage" description:"Specifies the minimum time that must have passed since a bolt database file was last compacted for the compaction to be considered again."`
AutoCompactMinAge time.Duration `mapstructure:"autocompact"`

// DBTimeout specifies the timeout value to use when opening the wallet
// database.
DBTimeout time.Duration `long:"dbtimeout" description:"Specifies the timeout value to use when opening the wallet database."`
DBTimeout time.Duration `mapstructure:"autocompact"`
}

func DefaultDBConfig() *DBConfig {
Expand Down
4 changes: 2 additions & 2 deletions config/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ type MonitorConfig struct {
BtcConfirmationDepth uint64 `mapstructure:"btc-confirmation-depth"`
// whether to enable liveness checker
EnableLivenessChecker bool `mapstructure:"enable-liveness-checker"`

DatabaseConfig *DBConfig `mapstructure:"database-config"`
// DatabaseConfig stores lates epoch and height used for faster bootstrap
DatabaseConfig *DBConfig `mapstructure:"dbconfig"`
}

func (cfg *MonitorConfig) Validate() error {
Expand Down
5 changes: 3 additions & 2 deletions config/submitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ type SubmitterConfig struct {
PollingIntervalSeconds uint `mapstructure:"polling-interval-seconds"`
// ResendIntervalSeconds defines the time (in seconds) which the submitter awaits
// before resubmitting checkpoints to BTC
ResendIntervalSeconds uint `mapstructure:"resend-interval-seconds"`
DatabaseConfig *DBConfig `mapstructure:"database-config"`
ResendIntervalSeconds uint `mapstructure:"resend-interval-seconds"`
// DatabaseConfig stores last submitted txn
DatabaseConfig *DBConfig `mapstructure:"dbconfig"`
}

func (cfg *SubmitterConfig) Validate() error {
Expand Down
14 changes: 11 additions & 3 deletions e2etest/container/config.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package container

import (
"github.com/babylonlabs-io/vigilante/testutil"
"github.com/stretchr/testify/require"
"testing"
)

// ImageConfig contains all images and their respective tags
// needed for running e2e tests.
type ImageConfig struct {
Expand All @@ -14,15 +20,17 @@ const (
dockerBitcoindRepository = "lncm/bitcoind"
dockerBitcoindVersionTag = "v27.0"
dockerBabylondRepository = "babylonlabs/babylond"
dockerBabylondVersionTag = "v0.10.0"
)

// NewImageConfig returns ImageConfig needed for running e2e test.
func NewImageConfig() ImageConfig {
func NewImageConfig(t *testing.T) ImageConfig {
babylondVersion, err := testutil.GetBabylonVersion()
require.NoError(t, err)

return ImageConfig{
BitcoindRepository: dockerBitcoindRepository,
BitcoindVersion: dockerBitcoindVersionTag,
BabylonRepository: dockerBabylondRepository,
BabylonVersion: dockerBabylondVersionTag,
BabylonVersion: babylondVersion,
}
}
4 changes: 2 additions & 2 deletions e2etest/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ type Manager struct {

// NewManager creates a new Manager instance and initializes
// all Docker specific utilities. Returns an error if initialization fails.
func NewManager() (docker *Manager, err error) {
func NewManager(t *testing.T) (docker *Manager, err error) {
docker = &Manager{
cfg: NewImageConfig(),
cfg: NewImageConfig(t),
resources: make(map[string]*dockertest.Resource),
}
docker.pool, err = dockertest.NewPool("")
Expand Down
2 changes: 1 addition & 1 deletion e2etest/test_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func initBTCClientWithSubscriber(t *testing.T, cfg *config.Config) *btcclient.Cl
// StartManager creates a test manager
// NOTE: uses btc client with zmq
func StartManager(t *testing.T, numMatureOutputsInWallet uint32, epochInterval uint) *TestManager {
manager, err := container.NewManager()
manager, err := container.NewManager(t)
require.NoError(t, err)

btcHandler := NewBitcoindHandler(t, manager)
Expand Down
32 changes: 32 additions & 0 deletions testutil/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package testutil

import (
"fmt"
"golang.org/x/mod/modfile"
"os"
"path/filepath"
)

// GetBabylonVersion returns babylond version from go.mod
func GetBabylonVersion() (string, error) {
goModPath := filepath.Join("..", "go.mod")
data, err := os.ReadFile(goModPath)
if err != nil {
return "", err
}

// Parse the go.mod file
modFile, err := modfile.Parse("go.mod", data, nil)
if err != nil {
return "", err
}

const modName = "github.com/babylonlabs-io/babylon"
for _, require := range modFile.Require {
if require.Mod.Path == modName {
return require.Mod.Version, nil
}
}

return "", fmt.Errorf("module %s not found", modName)
}
Loading