From a21fd963de7202b2c9d7b8ab1bfe47646b8b5d7e Mon Sep 17 00:00:00 2001 From: Adam Babik Date: Fri, 20 Oct 2017 12:10:28 +0200 Subject: [PATCH 1/5] improve travis integration --- .travis.yml | 12 ++++++++++-- Makefile | 10 ++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6a3b32e80..854b66373 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,9 +9,17 @@ dist: trusty install: - go get golang.org/x/tools/cmd/cover + - make mock-install + - make mock -script: - - travis_wait make ci +jobs: + include: + - stage: Lint + script: make lint + - stage: Test unit and integration + script: make test-unit-coverage + - stage: Test e2e + script: travis_wait make test-e2e cache: directories: diff --git a/Makefile b/Makefile index b134700d1..d72ae0225 100644 --- a/Makefile +++ b/Makefile @@ -136,10 +136,12 @@ mock-install: ##@other Install mocking tools mock: ##@other Regenerate mocks 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) -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) test-e2e: ##@tests Run e2e tests @@ -153,7 +155,7 @@ test-e2e: ##@tests Run e2e tests build/env.sh go test -timeout 10m ./e2e/transactions/... build/env.sh go test -timeout 10m ./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 tests in CI clean: ##@other Cleanup rm -fr build/bin/* @@ -161,4 +163,4 @@ clean: ##@other Cleanup LINT_EXCLUDE := --exclude='.*_mock.go' --exclude='geth/jail/doc.go' -LINT_FOLDERS := extkeys cmd/... geth/... e2e/... \ No newline at end of file +LINT_FOLDERS := extkeys cmd/... geth/... e2e/... From a2f6889c14480c3a49ba366a16f05784901e787e Mon Sep 17 00:00:00 2001 From: Adam Babik Date: Fri, 20 Oct 2017 13:35:11 +0200 Subject: [PATCH 2/5] remove email notifications --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 854b66373..85a20a11d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,6 @@ +notifications: + email: false + language: go go: From 39cc60b8a7d9686e7665b12284b5597a1d8316c2 Mon Sep 17 00:00:00 2001 From: Ivan Tomilov Date: Tue, 24 Oct 2017 19:48:31 +0300 Subject: [PATCH 3/5] Fixed make lint --- e2e/accounts/accounts_test.go | 26 +++++++++++++------------- e2e/transactions/transactions_test.go | 8 ++++---- geth/jail/jail.go | 4 ++-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/e2e/accounts/accounts_test.go b/e2e/accounts/accounts_test.go index 59895c002..de7edb907 100644 --- a/e2e/accounts/accounts_test.go +++ b/e2e/accounts/accounts_test.go @@ -137,41 +137,41 @@ func (s *AccountsTestSuite) TestRecoverAccount() { keyStore, err := s.Backend.NodeManager().AccountKeyStore() s.NoError(err) - // create an account + // create an acc address, pubKey, mnemonic, err := s.Backend.AccountManager().CreateAccount(TestConfig.Account1.Password) s.NoError(err) s.T().Logf("Account created: {address: %s, key: %s, mnemonic:%s}", address, pubKey, mnemonic) // try recovering using 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") - // now test recovering, but make sure that account/key file is removed i.e. simulate recovering on a new device - account, err := common.ParseAccountString(address) - s.NoError(err, "can not get account from address") + // now test recovering, but make sure that acc/key file is removed i.e. simulate recovering on a new device + acc, err := common.ParseAccountString(address) + s.NoError(err, "can not get acc from address") - account, key, err := keyStore.AccountDecryptedKey(account, TestConfig.Account1.Password) - s.NoError(err, "can not obtain decrypted account key") + acc, key, err := keyStore.AccountDecryptedKey(acc, TestConfig.Account1.Password) + s.NoError(err, "can not obtain decrypted acc key") 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) - 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, - "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 - _, key, err = keyStore.AccountDecryptedKey(account, TestConfig.Account1.Password) + _, key, err = keyStore.AccountDecryptedKey(acc, TestConfig.Account1.Password) s.NoError(err) 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) 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, - "incorrect account details recovered (for non-cached account)") + "incorrect acc details recovered (for non-cached acc)") // time to login with recovered data whisperService := s.WhisperService() diff --git a/e2e/transactions/transactions_test.go b/e2e/transactions/transactions_test.go index df9f826af..f0dd1a76e 100644 --- a/e2e/transactions/transactions_test.go +++ b/e2e/transactions/transactions_test.go @@ -96,12 +96,12 @@ func (s *TransactionsTestSuite) TestCallRPCSendTransactionUpstream() { var txHash gethcommon.Hash signal.SetDefaultNodeNotificationHandler(func(rawSignal string) { - var signal signal.Envelope - err := json.Unmarshal([]byte(rawSignal), &signal) + var signalEnvelope signal.Envelope + err := json.Unmarshal([]byte(rawSignal), &signalEnvelope) s.NoError(err) - if signal.Type == txqueue.EventTransactionQueued { - event := signal.Event.(map[string]interface{}) + if signalEnvelope.Type == txqueue.EventTransactionQueued { + event := signalEnvelope.Event.(map[string]interface{}) txID := event["id"].(string) // Complete with a wrong passphrase. diff --git a/geth/jail/jail.go b/geth/jail/jail.go index 0dc627274..0caac65db 100644 --- a/geth/jail/jail.go +++ b/geth/jail/jail.go @@ -54,9 +54,9 @@ func (jail *Jail) NewCell(chatID string) (common.JailCell, error) { return nil, ErrInvalidJail } - vm := otto.New() + cellVM := otto.New() - cell, err := newCell(chatID, vm) + cell, err := newCell(chatID, cellVM) if err != nil { return nil, err } From 96212b912cb146e290bc0d614a6bcc3c93298f3e Mon Sep 17 00:00:00 2001 From: Ivan Tomilov Date: Tue, 24 Oct 2017 19:54:13 +0300 Subject: [PATCH 4/5] Fixed make lint (goimports) --- cmd/statusd/utils.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/statusd/utils.go b/cmd/statusd/utils.go index 119ef7ff0..02df5c51e 100644 --- a/cmd/statusd/utils.go +++ b/cmd/statusd/utils.go @@ -2,6 +2,7 @@ package main import "C" import ( + "context" "encoding/json" "fmt" "io/ioutil" @@ -17,6 +18,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core" 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/common" @@ -25,7 +27,6 @@ import ( "github.com/status-im/status-go/geth/txqueue" "github.com/status-im/status-go/static" . "github.com/status-im/status-go/testing" //nolint: golint - "github.com/stretchr/testify/require" ) const zeroHash = "0x0000000000000000000000000000000000000000000000000000000000000000" From 53cea066e7742c5c86dd524867e86aa129673f68 Mon Sep 17 00:00:00 2001 From: Ivan Tomilov Date: Wed, 25 Oct 2017 16:36:03 +0300 Subject: [PATCH 5/5] Fix duplicate lint --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2417594a6..d0fd06864 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,8 +16,6 @@ install: jobs: include: - - stage: lint - script: make lint - stage: Lint script: make lint - stage: Test unit and integration