Skip to content

Commit

Permalink
test: binary E2E test for Mist JSON (#2626)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberj0g authored Oct 17, 2022
1 parent 31be623 commit 2298436
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/e2e/binary_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package e2e

import (
"encoding/json"
"github.com/stretchr/testify/assert"
"os/exec"
"testing"
)

func TestMistJson(t *testing.T) {
assert := assert.New(t)
buildLivepeer(assert)
// run
lp := exec.Command("./livepeer", "-j")
stdoutRes, err := lp.Output()
assert.NoError(err)

// parse output
jsonMap := make(map[string](interface{}))
err = json.Unmarshal(stdoutRes, &jsonMap)
assert.NoError(err)
// only check for name element
assert.Contains(jsonMap, "name")
}
10 changes: 10 additions & 0 deletions test/e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ import (
"bytes"
"context"
"fmt"
"github.com/stretchr/testify/assert"
"io/ioutil"
"math/big"
"net/http"
"net/url"
"os/exec"
"path/filepath"
"strings"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -58,6 +61,13 @@ func terminateGeth(t *testing.T, ctx context.Context, geth *gethContainer) {
require.NoError(t, err)
}

func buildLivepeer(assert *assert.Assertions) {
// build app
build := exec.Command("go", strings.Split("build ../../cmd/livepeer/livepeer.go", " ")...)
err := build.Run()
assert.NoError(err)
}

// Start Livepeer helpers
var (
httpPort = 8935
Expand Down

0 comments on commit 2298436

Please sign in to comment.