Group tests in a dedicated testing package (#629)

This commit is contained in:
Sebastian Klier 2018-02-08 20:52:47 +08:00 committed by Igor Mandrigin
parent 766568dc11
commit 70912ab8f6
23 changed files with 53 additions and 52 deletions

View File

@ -19,7 +19,7 @@ XGOIMAGEIOSSIM = statusteam/xgo-ios-simulator:$(XGOVERSION)
DOCKER_IMAGE_NAME ?= status-go DOCKER_IMAGE_NAME ?= status-go
UNIT_TEST_PACKAGES := $(shell go list ./... | grep -v /vendor | grep -v /e2e | grep -v /cmd | grep -v /lib) UNIT_TEST_PACKAGES := $(shell go list ./... | grep -v /vendor | grep -v /t/e2e | grep -v /cmd | grep -v /lib)
# This is a code for automatic help generator. # This is a code for automatic help generator.
# It supports ANSI colors and categories. # It supports ANSI colors and categories.
@ -126,13 +126,13 @@ test-unit-coverage: ##@tests Run unit and integration tests with coverage
test-e2e: ##@tests Run e2e tests test-e2e: ##@tests Run e2e tests
# order: reliability then alphabetical # order: reliability then alphabetical
# TODO(tiabc): make a single command out of them adding `-p 1` flag. # TODO(tiabc): make a single command out of them adding `-p 1` flag.
go test -timeout 5m ./e2e/accounts/... -network=$(networkid) go test -timeout 5m ./t/e2e/accounts/... -network=$(networkid)
go test -timeout 5m ./e2e/api/... -network=$(networkid) go test -timeout 5m ./t/e2e/api/... -network=$(networkid)
go test -timeout 5m ./e2e/node/... -network=$(networkid) go test -timeout 5m ./t/e2e/node/... -network=$(networkid)
go test -timeout 50m ./e2e/jail/... -network=$(networkid) go test -timeout 50m ./t/e2e/jail/... -network=$(networkid)
go test -timeout 20m ./e2e/rpc/... -network=$(networkid) go test -timeout 20m ./t/e2e/rpc/... -network=$(networkid)
go test -timeout 20m ./e2e/whisper/... -network=$(networkid) go test -timeout 20m ./t/e2e/whisper/... -network=$(networkid)
go test -timeout 10m ./e2e/transactions/... -network=$(networkid) go test -timeout 10m ./t/e2e/transactions/... -network=$(networkid)
# e2e_test tag is required to include some files from ./lib without _test suffix # e2e_test tag is required to include some files from ./lib without _test suffix
go test -timeout 40m -tags e2e_test ./lib -network=$(networkid) go test -timeout 40m -tags e2e_test ./lib -network=$(networkid)

View File

@ -52,7 +52,7 @@ To test statusgo using a given network by number ID, use:
make ci networkid=3 make ci networkid=3
``` ```
If you have problems running tests on public network we suggest reading [e2e guide](e2e/README.md). If you have problems running tests on public network we suggest reading [e2e guide](t/e2e/README.md).
If you want to launch specific test, for instance `RPCSendTransactions`, use the following command: If you want to launch specific test, for instance `RPCSendTransactions`, use the following command:
``` ```

View File

@ -15,7 +15,7 @@ import (
whisper "github.com/ethereum/go-ethereum/whisper/whisperv5" whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
"github.com/golang/mock/gomock" "github.com/golang/mock/gomock"
"github.com/status-im/status-go/geth/common" "github.com/status-im/status-go/geth/common"
. "github.com/status-im/status-go/testing" . "github.com/status-im/status-go/t/utils"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )

View File

@ -23,7 +23,7 @@ import (
"github.com/status-im/status-go/geth/rpc" "github.com/status-im/status-go/geth/rpc"
"github.com/status-im/status-go/geth/transactions/fake" "github.com/status-im/status-go/geth/transactions/fake"
"github.com/status-im/status-go/geth/transactions/queue" "github.com/status-im/status-go/geth/transactions/queue"
. "github.com/status-im/status-go/testing" . "github.com/status-im/status-go/t/utils"
) )
func TestTxQueueTestSuite(t *testing.T) { func TestTxQueueTestSuite(t *testing.T) {

View File

@ -37,7 +37,7 @@ import (
"github.com/status-im/status-go/geth/transactions" "github.com/status-im/status-go/geth/transactions"
"github.com/status-im/status-go/geth/transactions/queue" "github.com/status-im/status-go/geth/transactions/queue"
"github.com/status-im/status-go/static" "github.com/status-im/status-go/static"
. "github.com/status-im/status-go/testing" //nolint: golint . "github.com/status-im/status-go/t/utils" //nolint: golint
) )
const zeroHash = "0x0000000000000000000000000000000000000000000000000000000000000000" const zeroHash = "0x0000000000000000000000000000000000000000000000000000000000000000"

View File

@ -5,7 +5,7 @@ This package contains all e2e tests divided into subpackages which represents (o
These tests are run against public testnets: Ropsten and Rinkeby. These tests are run against public testnets: Ropsten and Rinkeby.
e2e package contains a few utilities which are described in a [godoc](https://godoc.org/github.com/status-im/status-go/e2e). e2e package contains a few utilities which are described in a [godoc](https://godoc.org/github.com/status-im/status-go/t/e2e).
### Flags ### Flags
@ -23,13 +23,13 @@ Please see Preparation section for details.
To use the `ropsten` network for testing using network name: To use the `ropsten` network for testing using network name:
```bash ```bash
ACCOUNT_PASSWORD=test go test -v ./e2e/... -p= 1 -network=ropsten ACCOUNT_PASSWORD=test go test -v ./t/e2e/... -p=1 -network=ropsten
``` ```
To use the `rinkeby` network with chain id `4` for testing: To use the `rinkeby` network with chain id `4` for testing:
```bash ```bash
ACCOUNT_PASSWORD=test go test -v ./e2e/... -p=1 -network=4 ACCOUNT_PASSWORD=test go test -v ./t/e2e/... -p=1 -network=4
``` ```
#### Preparation #### Preparation

View File

@ -4,9 +4,9 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/status-im/status-go/e2e"
"github.com/status-im/status-go/geth/params" "github.com/status-im/status-go/geth/params"
. "github.com/status-im/status-go/testing" e2e "github.com/status-im/status-go/t/e2e"
. "github.com/status-im/status-go/t/utils"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )

View File

@ -5,10 +5,10 @@ import (
"fmt" "fmt"
"testing" "testing"
"github.com/status-im/status-go/e2e"
"github.com/status-im/status-go/geth/account" "github.com/status-im/status-go/geth/account"
"github.com/status-im/status-go/geth/common" "github.com/status-im/status-go/geth/common"
. "github.com/status-im/status-go/testing" e2e "github.com/status-im/status-go/t/e2e"
. "github.com/status-im/status-go/t/utils"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )

View File

@ -8,11 +8,11 @@ import (
"testing" "testing"
"time" "time"
"github.com/status-im/status-go/e2e"
"github.com/status-im/status-go/geth/api" "github.com/status-im/status-go/geth/api"
"github.com/status-im/status-go/geth/log" "github.com/status-im/status-go/geth/log"
"github.com/status-im/status-go/geth/params" "github.com/status-im/status-go/geth/params"
. "github.com/status-im/status-go/testing" e2e "github.com/status-im/status-go/t/e2e"
. "github.com/status-im/status-go/t/utils"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )

View File

@ -5,14 +5,14 @@ import (
"testing" "testing"
"time" "time"
"github.com/status-im/status-go/e2e"
"github.com/status-im/status-go/geth/account" "github.com/status-im/status-go/geth/account"
"github.com/status-im/status-go/geth/common" "github.com/status-im/status-go/geth/common"
"github.com/status-im/status-go/geth/jail" "github.com/status-im/status-go/geth/jail"
"github.com/status-im/status-go/geth/log" "github.com/status-im/status-go/geth/log"
"github.com/status-im/status-go/geth/node" "github.com/status-im/status-go/geth/node"
"github.com/status-im/status-go/geth/params" "github.com/status-im/status-go/geth/params"
. "github.com/status-im/status-go/testing" e2e "github.com/status-im/status-go/t/e2e"
. "github.com/status-im/status-go/t/utils"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )

View File

@ -10,12 +10,12 @@ import (
"time" "time"
gethcommon "github.com/ethereum/go-ethereum/common" gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/status-im/status-go/e2e"
"github.com/status-im/status-go/geth/common" "github.com/status-im/status-go/geth/common"
"github.com/status-im/status-go/geth/params" "github.com/status-im/status-go/geth/params"
"github.com/status-im/status-go/geth/signal" "github.com/status-im/status-go/geth/signal"
"github.com/status-im/status-go/geth/transactions" "github.com/status-im/status-go/geth/transactions"
. "github.com/status-im/status-go/testing" e2e "github.com/status-im/status-go/t/e2e"
. "github.com/status-im/status-go/t/utils"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )

View File

@ -10,12 +10,12 @@ import (
"testing" "testing"
"time" "time"
"github.com/status-im/status-go/e2e"
"github.com/status-im/status-go/geth/common" "github.com/status-im/status-go/geth/common"
"github.com/status-im/status-go/geth/jail" "github.com/status-im/status-go/geth/jail"
"github.com/status-im/status-go/geth/node" "github.com/status-im/status-go/geth/node"
"github.com/status-im/status-go/geth/signal" "github.com/status-im/status-go/geth/signal"
"github.com/status-im/status-go/static" "github.com/status-im/status-go/static"
e2e "github.com/status-im/status-go/t/e2e"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )

View File

@ -11,11 +11,11 @@ import (
gethnode "github.com/ethereum/go-ethereum/node" gethnode "github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/rpc"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv5" whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
"github.com/status-im/status-go/e2e"
"github.com/status-im/status-go/geth/node" "github.com/status-im/status-go/geth/node"
"github.com/status-im/status-go/geth/params" "github.com/status-im/status-go/geth/params"
"github.com/status-im/status-go/geth/signal" "github.com/status-im/status-go/geth/signal"
. "github.com/status-im/status-go/testing" e2e "github.com/status-im/status-go/t/e2e"
. "github.com/status-im/status-go/t/utils"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )

View File

@ -3,10 +3,10 @@ package rpc
import ( import (
"testing" "testing"
"github.com/status-im/status-go/e2e"
"github.com/status-im/status-go/geth/node" "github.com/status-im/status-go/geth/node"
"github.com/status-im/status-go/geth/rpc" "github.com/status-im/status-go/geth/rpc"
. "github.com/status-im/status-go/testing" //nolint: golint e2e "github.com/status-im/status-go/t/e2e"
. "github.com/status-im/status-go/t/utils" //nolint: golint
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )

View File

@ -10,10 +10,10 @@ import (
"math/big" "math/big"
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
"github.com/status-im/status-go/e2e"
"github.com/status-im/status-go/geth/node" "github.com/status-im/status-go/geth/node"
"github.com/status-im/status-go/geth/params" "github.com/status-im/status-go/geth/params"
. "github.com/status-im/status-go/testing" e2e "github.com/status-im/status-go/t/e2e"
. "github.com/status-im/status-go/t/utils"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )

View File

@ -1,4 +1,4 @@
package e2e package t
import ( import (
"github.com/ethereum/go-ethereum/les" "github.com/ethereum/go-ethereum/les"
@ -8,7 +8,7 @@ import (
"github.com/status-im/status-go/geth/log" "github.com/status-im/status-go/geth/log"
"github.com/status-im/status-go/geth/signal" "github.com/status-im/status-go/geth/signal"
"github.com/status-im/status-go/geth/transactions" "github.com/status-im/status-go/geth/transactions"
. "github.com/status-im/status-go/testing" //nolint: golint . "github.com/status-im/status-go/t/utils" //nolint: golint
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )

View File

@ -1,4 +1,4 @@
package e2e package t
import ( import (
"context" "context"
@ -10,7 +10,7 @@ import (
gethcommon "github.com/ethereum/go-ethereum/common" gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/status-im/status-go/geth/common" "github.com/status-im/status-go/geth/common"
"github.com/status-im/status-go/geth/params" "github.com/status-im/status-go/geth/params"
. "github.com/status-im/status-go/testing" //nolint: golint . "github.com/status-im/status-go/t/utils" //nolint: golint
) )
// TestNodeOption is a callback passed to StartTestNode which alters its config. // TestNodeOption is a callback passed to StartTestNode which alters its config.

View File

@ -14,14 +14,14 @@ import (
gethcommon "github.com/ethereum/go-ethereum/common" gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/status-im/status-go/e2e"
"github.com/status-im/status-go/geth/account" "github.com/status-im/status-go/geth/account"
"github.com/status-im/status-go/geth/common" "github.com/status-im/status-go/geth/common"
"github.com/status-im/status-go/geth/params" "github.com/status-im/status-go/geth/params"
"github.com/status-im/status-go/geth/signal" "github.com/status-im/status-go/geth/signal"
"github.com/status-im/status-go/geth/transactions" "github.com/status-im/status-go/geth/transactions"
"github.com/status-im/status-go/geth/transactions/queue" "github.com/status-im/status-go/geth/transactions/queue"
. "github.com/status-im/status-go/testing" e2e "github.com/status-im/status-go/t/e2e"
. "github.com/status-im/status-go/t/utils"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )

View File

@ -6,9 +6,9 @@ import (
"net/http" "net/http"
"testing" "testing"
"github.com/status-im/status-go/e2e"
"github.com/status-im/status-go/geth/node" "github.com/status-im/status-go/geth/node"
"github.com/status-im/status-go/geth/params" "github.com/status-im/status-go/geth/params"
e2e "github.com/status-im/status-go/t/e2e"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )

View File

@ -6,10 +6,10 @@ import (
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv5" whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
"github.com/status-im/status-go/e2e"
"github.com/status-im/status-go/geth/common" "github.com/status-im/status-go/geth/common"
"github.com/status-im/status-go/static" "github.com/status-im/status-go/static"
. "github.com/status-im/status-go/testing" e2e "github.com/status-im/status-go/t/e2e"
. "github.com/status-im/status-go/t/utils"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )

View File

@ -2,6 +2,7 @@ package whisper
import ( import (
"encoding/json" "encoding/json"
"path/filepath"
"strconv" "strconv"
"testing" "testing"
"time" "time"
@ -12,10 +13,10 @@ import (
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/p2p/discover" "github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/whisper/whisperv5" "github.com/ethereum/go-ethereum/whisper/whisperv5"
"github.com/status-im/status-go/e2e"
"github.com/status-im/status-go/geth/api" "github.com/status-im/status-go/geth/api"
"github.com/status-im/status-go/geth/rpc" "github.com/status-im/status-go/geth/rpc"
. "github.com/status-im/status-go/testing" e2e "github.com/status-im/status-go/t/e2e"
. "github.com/status-im/status-go/t/utils"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )
@ -305,7 +306,7 @@ func (d *groupChatParams) Encode() (string, error) {
//Start status node //Start status node
func (s *WhisperMailboxSuite) startBackend(name string) (*api.StatusBackend, func()) { func (s *WhisperMailboxSuite) startBackend(name string) (*api.StatusBackend, func()) {
datadir := "../../.ethereumtest/mailbox/" + name datadir := filepath.Join(RootDir, ".ethereumtest/mailbox", name)
backend := api.NewStatusBackend() backend := api.NewStatusBackend()
nodeConfig, err := e2e.MakeTestNodeConfig(GetNetworkID()) nodeConfig, err := e2e.MakeTestNodeConfig(GetNetworkID())
nodeConfig.DataDir = datadir nodeConfig.DataDir = datadir
@ -332,15 +333,15 @@ func (s *WhisperMailboxSuite) startMailboxBackend() (*api.StatusBackend, func())
mailboxBackend := api.NewStatusBackend() mailboxBackend := api.NewStatusBackend()
mailboxConfig, err := e2e.MakeTestNodeConfig(GetNetworkID()) mailboxConfig, err := e2e.MakeTestNodeConfig(GetNetworkID())
s.Require().NoError(err) s.Require().NoError(err)
datadir := "../../.ethereumtest/mailbox/mailserver/" datadir := filepath.Join(RootDir, ".ethereumtest/mailbox/mailserver")
mailboxConfig.LightEthConfig.Enabled = false mailboxConfig.LightEthConfig.Enabled = false
mailboxConfig.WhisperConfig.Enabled = true mailboxConfig.WhisperConfig.Enabled = true
mailboxConfig.KeyStoreDir = "../../.ethereumtest/mailbox/mailserver" mailboxConfig.KeyStoreDir = datadir
mailboxConfig.WhisperConfig.EnableMailServer = true mailboxConfig.WhisperConfig.EnableMailServer = true
mailboxConfig.WhisperConfig.IdentityFile = "../../static/keys/wnodekey" mailboxConfig.WhisperConfig.IdentityFile = filepath.Join(RootDir, "/static/keys/wnodekey")
mailboxConfig.WhisperConfig.PasswordFile = "../../static/keys/wnodepassword" mailboxConfig.WhisperConfig.PasswordFile = filepath.Join(RootDir, "/static/keys/wnodepassword")
mailboxConfig.WhisperConfig.DataDir = "../../.ethereumtest/mailbox/mailserver/data" mailboxConfig.WhisperConfig.DataDir = filepath.Join(datadir, "data")
mailboxConfig.DataDir = datadir mailboxConfig.DataDir = datadir
mailboxNodeStarted, err := mailboxBackend.StartNode(mailboxConfig) mailboxNodeStarted, err := mailboxBackend.StartNode(mailboxConfig)

View File

@ -6,10 +6,10 @@ import (
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv5" whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
"github.com/status-im/status-go/e2e"
"github.com/status-im/status-go/geth/account" "github.com/status-im/status-go/geth/account"
"github.com/status-im/status-go/geth/node" "github.com/status-im/status-go/geth/node"
. "github.com/status-im/status-go/testing" e2e "github.com/status-im/status-go/t/e2e"
. "github.com/status-im/status-go/t/utils"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )

View File

@ -1,4 +1,4 @@
package testing package utils
import ( import (
"bytes" "bytes"