Merge pull request #419 from status-im/feature/linter-in-travis
Divided Travis integration into stages: lint, unit tests, e2e tests
This commit is contained in:
commit
8275391c09
12
.travis.yml
12
.travis.yml
|
@ -1,3 +1,6 @@
|
||||||
|
notifications:
|
||||||
|
email: false
|
||||||
|
|
||||||
language: go
|
language: go
|
||||||
|
|
||||||
go:
|
go:
|
||||||
|
@ -13,10 +16,13 @@ install:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
include:
|
include:
|
||||||
- stage: lint
|
- stage: Lint
|
||||||
script: make lint
|
script: make lint
|
||||||
- stage: ci
|
- stage: Test unit and integration
|
||||||
script: make ci
|
script: make test-unit-coverage
|
||||||
|
- stage: Test e2e
|
||||||
|
script: make test-e2e
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
- .ethereumtest
|
- .ethereumtest
|
||||||
|
|
8
Makefile
8
Makefile
|
@ -88,10 +88,12 @@ mock-install: ##@other Install mocking tools
|
||||||
mock: ##@other Regenerate mocks
|
mock: ##@other Regenerate mocks
|
||||||
mockgen -source=geth/common/types.go -destination=geth/common/types_mock.go -package=common
|
mockgen -source=geth/common/types.go -destination=geth/common/types_mock.go -package=common
|
||||||
|
|
||||||
test: ##@tests Run unit and integration tests
|
test: test-unit-coverage ##@tests Run basic, short tests during development
|
||||||
|
|
||||||
|
test-unit: ##@tests Run unit and integration tests
|
||||||
build/env.sh go test $(UNIT_TEST_PACKAGES)
|
build/env.sh go test $(UNIT_TEST_PACKAGES)
|
||||||
|
|
||||||
test-coverage: ##@tests Run unit and integration tests with covevare
|
test-unit-coverage: ##@tests Run unit and integration tests with coverage
|
||||||
build/env.sh go test -coverpkg= $(UNIT_TEST_PACKAGES)
|
build/env.sh go test -coverpkg= $(UNIT_TEST_PACKAGES)
|
||||||
|
|
||||||
test-e2e: ##@tests Run e2e tests
|
test-e2e: ##@tests Run e2e tests
|
||||||
|
@ -106,7 +108,7 @@ test-e2e: ##@tests Run e2e tests
|
||||||
build/env.sh go test -timeout 10m ./e2e/transactions/...
|
build/env.sh go test -timeout 10m ./e2e/transactions/...
|
||||||
build/env.sh go test -timeout 40m ./cmd/statusd
|
build/env.sh go test -timeout 40m ./cmd/statusd
|
||||||
|
|
||||||
ci: mock-install mock test-coverage test-e2e ##@tests Run all tests in CI
|
ci: lint mock-install mock test-unit test-e2e ##@tests Run all linters and tests at once
|
||||||
|
|
||||||
clean: ##@other Cleanup
|
clean: ##@other Cleanup
|
||||||
rm -fr build/bin/*
|
rm -fr build/bin/*
|
||||||
|
|
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import "C"
|
import "C"
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
@ -17,6 +18,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
"github.com/ethereum/go-ethereum/core"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
gethparams "github.com/ethereum/go-ethereum/params"
|
gethparams "github.com/ethereum/go-ethereum/params"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"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"
|
||||||
|
@ -25,7 +27,6 @@ import (
|
||||||
"github.com/status-im/status-go/geth/txqueue"
|
"github.com/status-im/status-go/geth/txqueue"
|
||||||
"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/testing" //nolint: golint
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const zeroHash = "0x0000000000000000000000000000000000000000000000000000000000000000"
|
const zeroHash = "0x0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
|
|
|
@ -137,41 +137,41 @@ func (s *AccountsTestSuite) TestRecoverAccount() {
|
||||||
keyStore, err := s.Backend.NodeManager().AccountKeyStore()
|
keyStore, err := s.Backend.NodeManager().AccountKeyStore()
|
||||||
s.NoError(err)
|
s.NoError(err)
|
||||||
|
|
||||||
// create an account
|
// create an acc
|
||||||
address, pubKey, mnemonic, err := s.Backend.AccountManager().CreateAccount(TestConfig.Account1.Password)
|
address, pubKey, mnemonic, err := s.Backend.AccountManager().CreateAccount(TestConfig.Account1.Password)
|
||||||
s.NoError(err)
|
s.NoError(err)
|
||||||
s.T().Logf("Account created: {address: %s, key: %s, mnemonic:%s}", address, pubKey, mnemonic)
|
s.T().Logf("Account created: {address: %s, key: %s, mnemonic:%s}", address, pubKey, mnemonic)
|
||||||
|
|
||||||
// try recovering using password + mnemonic
|
// try recovering using password + mnemonic
|
||||||
addressCheck, pubKeyCheck, err := s.Backend.AccountManager().RecoverAccount(TestConfig.Account1.Password, mnemonic)
|
addressCheck, pubKeyCheck, err := s.Backend.AccountManager().RecoverAccount(TestConfig.Account1.Password, mnemonic)
|
||||||
s.NoError(err, "recover account failed")
|
s.NoError(err, "recover acc failed")
|
||||||
s.False(address != addressCheck || pubKey != pubKeyCheck, "incorrect accound details recovered")
|
s.False(address != addressCheck || pubKey != pubKeyCheck, "incorrect accound details recovered")
|
||||||
|
|
||||||
// now test recovering, but make sure that account/key file is removed i.e. simulate recovering on a new device
|
// now test recovering, but make sure that acc/key file is removed i.e. simulate recovering on a new device
|
||||||
account, err := common.ParseAccountString(address)
|
acc, err := common.ParseAccountString(address)
|
||||||
s.NoError(err, "can not get account from address")
|
s.NoError(err, "can not get acc from address")
|
||||||
|
|
||||||
account, key, err := keyStore.AccountDecryptedKey(account, TestConfig.Account1.Password)
|
acc, key, err := keyStore.AccountDecryptedKey(acc, TestConfig.Account1.Password)
|
||||||
s.NoError(err, "can not obtain decrypted account key")
|
s.NoError(err, "can not obtain decrypted acc key")
|
||||||
extChild2String := key.ExtendedKey.String()
|
extChild2String := key.ExtendedKey.String()
|
||||||
|
|
||||||
s.NoError(keyStore.Delete(account, TestConfig.Account1.Password), "cannot remove account")
|
s.NoError(keyStore.Delete(acc, TestConfig.Account1.Password), "cannot remove acc")
|
||||||
|
|
||||||
addressCheck, pubKeyCheck, err = s.Backend.AccountManager().RecoverAccount(TestConfig.Account1.Password, mnemonic)
|
addressCheck, pubKeyCheck, err = s.Backend.AccountManager().RecoverAccount(TestConfig.Account1.Password, mnemonic)
|
||||||
s.NoError(err, "recover account failed (for non-cached account)")
|
s.NoError(err, "recover acc failed (for non-cached acc)")
|
||||||
s.False(address != addressCheck || pubKey != pubKeyCheck,
|
s.False(address != addressCheck || pubKey != pubKeyCheck,
|
||||||
"incorrect account details recovered (for non-cached account)")
|
"incorrect acc details recovered (for non-cached acc)")
|
||||||
|
|
||||||
// make sure that extended key exists and is imported ok too
|
// make sure that extended key exists and is imported ok too
|
||||||
_, key, err = keyStore.AccountDecryptedKey(account, TestConfig.Account1.Password)
|
_, key, err = keyStore.AccountDecryptedKey(acc, TestConfig.Account1.Password)
|
||||||
s.NoError(err)
|
s.NoError(err)
|
||||||
s.Equal(extChild2String, key.ExtendedKey.String(), "CKD#2 key mismatch")
|
s.Equal(extChild2String, key.ExtendedKey.String(), "CKD#2 key mismatch")
|
||||||
|
|
||||||
// make sure that calling import several times, just returns from cache (no error is expected)
|
// make sure that calling import several times, just returns from cache (no error is expected)
|
||||||
addressCheck, pubKeyCheck, err = s.Backend.AccountManager().RecoverAccount(TestConfig.Account1.Password, mnemonic)
|
addressCheck, pubKeyCheck, err = s.Backend.AccountManager().RecoverAccount(TestConfig.Account1.Password, mnemonic)
|
||||||
s.NoError(err, "recover account failed (for non-cached account)")
|
s.NoError(err, "recover acc failed (for non-cached acc)")
|
||||||
s.False(address != addressCheck || pubKey != pubKeyCheck,
|
s.False(address != addressCheck || pubKey != pubKeyCheck,
|
||||||
"incorrect account details recovered (for non-cached account)")
|
"incorrect acc details recovered (for non-cached acc)")
|
||||||
|
|
||||||
// time to login with recovered data
|
// time to login with recovered data
|
||||||
whisperService := s.WhisperService()
|
whisperService := s.WhisperService()
|
||||||
|
|
|
@ -96,12 +96,12 @@ func (s *TransactionsTestSuite) TestCallRPCSendTransactionUpstream() {
|
||||||
|
|
||||||
var txHash gethcommon.Hash
|
var txHash gethcommon.Hash
|
||||||
signal.SetDefaultNodeNotificationHandler(func(rawSignal string) {
|
signal.SetDefaultNodeNotificationHandler(func(rawSignal string) {
|
||||||
var signal signal.Envelope
|
var signalEnvelope signal.Envelope
|
||||||
err := json.Unmarshal([]byte(rawSignal), &signal)
|
err := json.Unmarshal([]byte(rawSignal), &signalEnvelope)
|
||||||
s.NoError(err)
|
s.NoError(err)
|
||||||
|
|
||||||
if signal.Type == txqueue.EventTransactionQueued {
|
if signalEnvelope.Type == txqueue.EventTransactionQueued {
|
||||||
event := signal.Event.(map[string]interface{})
|
event := signalEnvelope.Event.(map[string]interface{})
|
||||||
txID := event["id"].(string)
|
txID := event["id"].(string)
|
||||||
|
|
||||||
// Complete with a wrong passphrase.
|
// Complete with a wrong passphrase.
|
||||||
|
|
|
@ -54,9 +54,9 @@ func (jail *Jail) NewCell(chatID string) (common.JailCell, error) {
|
||||||
return nil, ErrInvalidJail
|
return nil, ErrInvalidJail
|
||||||
}
|
}
|
||||||
|
|
||||||
vm := otto.New()
|
cellVM := otto.New()
|
||||||
|
|
||||||
cell, err := newCell(chatID, vm)
|
cell, err := newCell(chatID, cellVM)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue