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(itest): run babylond in e2e #36

Merged
merged 5 commits into from
Sep 27, 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
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
DOCKER = $(shell which docker)
BUILDDIR ?= $(CURDIR)/build
TOOLS_DIR := tools

BABYLON_PKG := github.com/babylonlabs-io/babylon/cmd/babylond

Expand Down Expand Up @@ -51,8 +50,7 @@ test:
go test ./...

test-e2e:
cd $(TOOLS_DIR); go install -trimpath $(BABYLON_PKG);
go test -mod=readonly -timeout=25m -v $(PACKAGES_E2E) -count=1 --tags=e2e
go test -mod=readonly -timeout=25m -failfast -v $(PACKAGES_E2E) -count=1 --tags=e2e

proto-gen:
@$(call print, "Compiling protos.")
Expand Down
15 changes: 6 additions & 9 deletions cmd/stakerd/main.go
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
package main

import (
"context"
"fmt"
"net/http"
"os"
"os/signal"
"runtime/pprof"
"syscall"

"github.com/babylonlabs-io/btc-staker/metrics"
staker "github.com/babylonlabs-io/btc-staker/staker"
scfg "github.com/babylonlabs-io/btc-staker/stakercfg"
service "github.com/babylonlabs-io/btc-staker/stakerservice"

"github.com/jessevdk/go-flags"
"github.com/lightningnetwork/lnd/signal"
)

func main() {
// Hook interceptor for os signals.
shutdownInterceptor, err := signal.Intercept()
if err != nil {
_, _ = fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer cancel()

cfg, cfgLogger, zapLogger, err := scfg.LoadConfig()

Expand Down Expand Up @@ -89,15 +88,13 @@ func main() {
cfg,
staker,
cfgLogger,
shutdownInterceptor,
dbBackend,
)

addr := fmt.Sprintf("%s:%d", cfg.MetricsConfig.Host, cfg.MetricsConfig.ServerPort)
metrics.Start(cfgLogger, addr, stakerMetrics.Registry)

err = service.RunUntilShutdown()
if err != nil {
if err = service.RunUntilShutdown(ctx); err != nil {
_, _ = fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
Expand Down
276 changes: 0 additions & 276 deletions itest/babylon_node_handler.go

This file was deleted.

10 changes: 5 additions & 5 deletions itest/bitcoind_node_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package e2etest
import (
"encoding/json"
"fmt"
"github.com/ory/dockertest/v3"
"os"
"strconv"
"strings"
Expand Down Expand Up @@ -34,24 +35,22 @@ type BitcoindTestHandler struct {
m *containers.Manager
}

func NewBitcoindHandler(t *testing.T) *BitcoindTestHandler {
m, err := containers.NewManager()
require.NoError(t, err)
func NewBitcoindHandler(t *testing.T, m *containers.Manager) *BitcoindTestHandler {
return &BitcoindTestHandler{
t: t,
m: m,
}
}

func (h *BitcoindTestHandler) Start() {
func (h *BitcoindTestHandler) Start() *dockertest.Resource {
tempPath, err := os.MkdirTemp("", "bitcoind-staker-test-*")
require.NoError(h.t, err)

h.t.Cleanup(func() {
_ = os.RemoveAll(tempPath)
})

_, err = h.m.RunBitcoindResource(tempPath)
bitcoinResource, err := h.m.RunBitcoindResource(h.t, tempPath)
require.NoError(h.t, err)

h.t.Cleanup(func() {
Expand All @@ -64,6 +63,7 @@ func (h *BitcoindTestHandler) Start() {
return err == nil
}, startTimeout, 500*time.Millisecond, "bitcoind did not start")

return bitcoinResource
}

func (h *BitcoindTestHandler) GetBlockCount() (int, error) {
Expand Down
Loading
Loading