Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: change tests log level to info #1644

Merged
merged 11 commits into from
Jun 18, 2021
10 changes: 9 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,17 @@ $ go test <file_you_are_working_on>
Sometimes you may need to create mocks for interfaces, in that case you will just execute:

```
$ make mock
$ make mock path=$(path to the interface) interface=$(interface name)
```

The command above will generate a file with prefix `mock_` inside the interface folder, if you want to generate the same mock but inside the `mocks` folder, you can execute:

```
$ make mock path=$(path to the interface) interface=$(interface name) INMOCKS=1
```

The command above will generate the mock inside the folder `$(path)/mocks`, and the mocks will be in the same package that your interface is.

The above command will generate mocks for all the interfaces inside the project! This command does not affect unchanged interfaces.

**8. Lint your changes.**
Expand Down
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,19 @@ install:
GOBIN=$(GOPATH)/bin go run scripts/ci.go install

MOCKGEN := $(shell command -v $(GOPATH)/bin/mockery 2> /dev/null)
INMOCKS=0
mock:
ifndef MOCKGEN
@echo "> Installing mockery ..."
@go get github.com/vektra/mockery/v2/.../
endif
@echo "> Generating mocks at ./tests/mocks ..."
$(GOPATH)/bin/mockery --all --recursive --inpackage --case underscore
@echo "> Generating mocks at $(path)"

ifeq ($(INMOCKS),1)
cd $(path); $(GOPATH)/bin/mockery --name $(interface) --inpackage --keeptree --case underscore
else
$(GOPATH)/bin/mockery --srcpkg $(path) --name $(interface) --case underscore --inpackage
endif



Expand Down
2 changes: 1 addition & 1 deletion dot/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func TestInitNode_LoadGenesisData(t *testing.T) {
err := InitNode(cfg)
require.NoError(t, err)

stateSrvc := state.NewService(cfg.Global.BasePath, log.LvlTrace)
stateSrvc := state.NewService(cfg.Global.BasePath, log.LvlInfo)

gen, err := genesis.NewGenesisFromJSONRaw(genPath)
require.NoError(t, err)
Expand Down
14 changes: 7 additions & 7 deletions dot/state/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ func newTestGenesisWithTrieAndHeader(t *testing.T) (*genesis.Genesis, *trie.Trie
// helper method to create and start test state service
func newTestService(t *testing.T) (state *Service) {
testDir := utils.NewTestDir(t)
state = NewService(testDir, log.LvlTrace)
state = NewService(testDir, log.LvlInfo)
return state
}

func newTestMemDBService() *Service {
testDatadirPath, _ := ioutil.TempDir("/tmp", "test-datadir-*")
state := NewService(testDatadirPath, log.LvlTrace)
state := NewService(testDatadirPath, log.LvlInfo)
state.UseMemDB()
return state
}
Expand Down Expand Up @@ -116,7 +116,7 @@ func TestService_BlockTree(t *testing.T) {
// removes all data directories created within test directory
defer utils.RemoveTestDir(t)

stateA := NewService(testDir, log.LvlTrace)
stateA := NewService(testDir, log.LvlInfo)

genData, genTrie, genesisHeader := newTestGenesisWithTrieAndHeader(t)
err := stateA.Initialise(genData, genesisHeader, genTrie)
Expand All @@ -131,7 +131,7 @@ func TestService_BlockTree(t *testing.T) {
err = stateA.Stop()
require.NoError(t, err)

stateB := NewService(testDir, log.LvlTrace)
stateB := NewService(testDir, log.LvlInfo)

err = stateB.Start()
require.NoError(t, err)
Expand All @@ -145,7 +145,7 @@ func TestService_PruneStorage(t *testing.T) {
testDir := utils.NewTestDir(t)
defer utils.RemoveTestDir(t)

serv := NewService(testDir, log.LvlTrace)
serv := NewService(testDir, log.LvlInfo)
serv.UseMemDB()

genData, genTrie, genesisHeader := newTestGenesisWithTrieAndHeader(t)
Expand Down Expand Up @@ -220,7 +220,7 @@ func TestService_Rewind(t *testing.T) {
testDir := utils.NewTestDir(t)
defer utils.RemoveTestDir(t)

serv := NewService(testDir, log.LvlTrace)
serv := NewService(testDir, log.LvlInfo)
serv.UseMemDB()

genData, genTrie, genesisHeader := newTestGenesisWithTrieAndHeader(t)
Expand Down Expand Up @@ -268,7 +268,7 @@ func TestService_Import(t *testing.T) {
testDir := utils.NewTestDir(t)
defer utils.RemoveTestDir(t)

serv := NewService(testDir, log.LvlTrace)
serv := NewService(testDir, log.LvlInfo)
serv.UseMemDB()

genData, genTrie, genesisHeader := newTestGenesisWithTrieAndHeader(t)
Expand Down
2 changes: 1 addition & 1 deletion dot/sync/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func NewTestSyncer(t *testing.T, usePolkadotGenesis bool) *Service {
}

if cfg.LogLvl == 0 {
cfg.LogLvl = log.LvlDebug
cfg.LogLvl = log.LvlInfo
}

if cfg.FinalityGadget == nil {
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ require (
github.com/stretchr/testify v1.7.0
github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca // indirect
github.com/urfave/cli v1.20.0
github.com/vektra/mockery/v2 v2.8.0 // indirect
github.com/wasmerio/go-ext-wasm v0.3.2-0.20200326095750-0a32be6068ec
go.opencensus.io v0.22.5 // indirect
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad
Expand Down
Loading