Skip to content

Commit

Permalink
chore: change tests log level to info (#1644)
Browse files Browse the repository at this point in the history
* chore: change tests log level to info

* chore: revert previus log levels

* chore: fix the corrects levels

* ajust make mock command

* exec go mod tidy

* fix lint

* chore: update docs
  • Loading branch information
EclesioMeloJunior authored Jun 18, 2021
1 parent 1c27575 commit 204af0e
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 14 deletions.
10 changes: 8 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,16 @@ $ 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 above command will generate mocks for all the interfaces inside the project! This command does not affect unchanged interfaces.
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.

**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/sync/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,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
6 changes: 3 additions & 3 deletions lib/babe/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func createTestBlock(t *testing.T, babeService *Service, parent *types.Header, e
func TestBuildBlock_ok(t *testing.T) {
cfg := &ServiceConfig{
TransactionState: state.NewTransactionState(),
LogLvl: log.LvlDebug,
LogLvl: log.LvlInfo,
}

babeService := createTestService(t, cfg)
Expand Down Expand Up @@ -170,7 +170,7 @@ func TestBuildBlock_ok(t *testing.T) {
func TestApplyExtrinsic(t *testing.T) {
cfg := &ServiceConfig{
TransactionState: state.NewTransactionState(),
LogLvl: log.LvlDebug,
LogLvl: log.LvlInfo,
}

babeService := createTestService(t, cfg)
Expand Down Expand Up @@ -205,7 +205,7 @@ func TestBuildAndApplyExtrinsic(t *testing.T) {
t.Skip()
cfg := &ServiceConfig{
TransactionState: state.NewTransactionState(),
LogLvl: log.LvlDebug,
LogLvl: log.LvlInfo,
}

babeService := createTestService(t, cfg)
Expand Down
6 changes: 3 additions & 3 deletions lib/runtime/wasmer/exports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func TestInstance_GrandpaAuthorities_NodeRuntime(t *testing.T) {

tt.Put(runtime.GrandpaAuthoritiesKey, value)

rt := NewTestInstanceWithTrie(t, runtime.NODE_RUNTIME, tt, log.LvlTrace)
rt := NewTestInstanceWithTrie(t, runtime.NODE_RUNTIME, tt, log.LvlInfo)

auths, err := rt.GrandpaAuthorities()
require.NoError(t, err)
Expand All @@ -252,7 +252,7 @@ func TestInstance_GrandpaAuthorities_PolkadotRuntime(t *testing.T) {

tt.Put(runtime.GrandpaAuthoritiesKey, value)

rt := NewTestInstanceWithTrie(t, runtime.POLKADOT_RUNTIME, tt, log.LvlTrace)
rt := NewTestInstanceWithTrie(t, runtime.POLKADOT_RUNTIME, tt, log.LvlInfo)

auths, err := rt.GrandpaAuthorities()
require.NoError(t, err)
Expand Down Expand Up @@ -319,7 +319,7 @@ func TestInstance_BabeConfiguration_NodeRuntime_WithAuthorities(t *testing.T) {

tt.Put(runtime.BABEAuthoritiesKey(), avalue)

rt := NewTestInstanceWithTrie(t, runtime.NODE_RUNTIME, tt, log.LvlTrace)
rt := NewTestInstanceWithTrie(t, runtime.NODE_RUNTIME, tt, log.LvlInfo)

cfg, err := rt.BabeConfiguration()
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion lib/runtime/wasmer/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
)

// DefaultTestLogLvl is the log level used for test runtime instances
var DefaultTestLogLvl = log.LvlDebug
var DefaultTestLogLvl = log.LvlInfo

// NewTestInstance will create a new runtime instance using the given target runtime
func NewTestInstance(t *testing.T, targetRuntime string) *Instance {
Expand Down
2 changes: 1 addition & 1 deletion lib/runtime/wasmtime/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (

// NewTestInstance will create a new runtime instance using the given target runtime
func NewTestInstance(t *testing.T, targetRuntime string) *Instance {
return NewTestInstanceWithTrie(t, targetRuntime, nil, log.LvlTrace)
return NewTestInstanceWithTrie(t, targetRuntime, nil, log.LvlInfo)
}

// NewTestInstanceWithTrie will create a new runtime (polkadot/test) with the supplied trie as the storage
Expand Down
2 changes: 1 addition & 1 deletion tests/polkadotjs_test/start_polkadotjs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestStartGossamerAndPolkadotAPI(t *testing.T) {
command := "npx mocha ./test"
parts := strings.Fields(command)
data, err := exec.Command(parts[0], parts[1:]...).Output()
require.NoError(t, err, fmt.Sprintf("%s", data))
require.NoError(t, err, data)

//uncomment this to see log results from javascript tests
//fmt.Printf("%s\n", data)
Expand Down

0 comments on commit 204af0e

Please sign in to comment.