Skip to content

Commit

Permalink
fixup! Add backbone for E2E Tests + First E2E Scenario: Register Orch…
Browse files Browse the repository at this point in the history
…estrator
  • Loading branch information
leszko committed May 9, 2022
1 parent 9f5988a commit 6064454
Showing 1 changed file with 18 additions and 37 deletions.
55 changes: 18 additions & 37 deletions test/e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/livepeer/go-livepeer/cmd/devtool/devtool"
"github.com/livepeer/go-livepeer/cmd/livepeer/starter"
"github.com/livepeer/go-livepeer/eth"
"github.com/stretchr/testify/require"
"github.com/testcontainers/testcontainers-go"
"io/ioutil"
"net/http"
Expand Down Expand Up @@ -34,28 +35,16 @@ func setupGeth(t *testing.T) *gethContainer {
ContainerRequest: req,
Started: true,
})
if err != nil {
t.Fatal(err)
return nil
}
require.NoError(t, err)

ip, err := container.Host(ctx)
if err != nil {
t.Fatal(err)
return nil
}
require.NoError(t, err)

mappedPort, err := container.MappedPort(ctx, "8545")
if err != nil {
t.Fatal(err)
return nil
}
require.NoError(t, err)

mappedPortWebServer, err := container.MappedPort(ctx, "8546")
if err != nil {
t.Fatal(err)
return nil
}
require.NoError(t, err)

uri := fmt.Sprintf("http://%s:%s", ip, mappedPort.Port())
webServerUri := fmt.Sprintf("http://%s:%s", ip, mappedPortWebServer.Port())
Expand All @@ -64,9 +53,8 @@ func setupGeth(t *testing.T) *gethContainer {
}

func terminateGeth(t *testing.T, geth *gethContainer) {
if err := geth.Terminate(context.TODO()); err != nil {
t.Fatal(err)
}
err := geth.Terminate(context.TODO())
require.NoError(t, err)
}

// Start Livepeer helpers
Expand Down Expand Up @@ -122,18 +110,13 @@ func startLivepeer(t *testing.T, lpCfg starter.LivepeerConfig, geth *gethContain
devCfg.KeystoreDir = keystoreDir

dev, err := devtool.Init(devCfg)
if err != nil {
t.Fatal(err)
return nil
}
if err := dev.RequestTokens(); err != nil {
t.Fatal(err)
return nil
}
if err := dev.InitializeRound(); err != nil {
t.Fatal(err)
return nil
}
require.NoError(t, err)

err = dev.RequestTokens()
require.NoError(t, err)

err = dev.InitializeRound()
require.NoError(t, err)

lpCfg.EthUrl = &geth.URI
lpCfg.Datadir = &datadir
Expand Down Expand Up @@ -168,14 +151,12 @@ func (l *livepeer) stop() {
// Other helpers
func waitForNextRound(t *testing.T, lpEth eth.LivepeerEthClient) {
r, err := lpEth.CurrentRound()
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)

for {
nr, err := lpEth.CurrentRound()
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)

if nr.Cmp(r) > 0 {
return
}
Expand Down

0 comments on commit 6064454

Please sign in to comment.