diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 8953c76fb6..2b5303b1d6 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -65,10 +65,16 @@ $ go test 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.** diff --git a/Makefile b/Makefile index 7e67aeddb2..59577d03c7 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/dot/sync/test_helpers.go b/dot/sync/test_helpers.go index 0059d65b10..4345afcb7f 100644 --- a/dot/sync/test_helpers.go +++ b/dot/sync/test_helpers.go @@ -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 { diff --git a/lib/babe/build_test.go b/lib/babe/build_test.go index e84dc8943c..620d734bad 100644 --- a/lib/babe/build_test.go +++ b/lib/babe/build_test.go @@ -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) @@ -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) @@ -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) diff --git a/lib/runtime/wasmer/exports_test.go b/lib/runtime/wasmer/exports_test.go index 0b5a72362a..9d720d71b0 100644 --- a/lib/runtime/wasmer/exports_test.go +++ b/lib/runtime/wasmer/exports_test.go @@ -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) @@ -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) @@ -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) diff --git a/lib/runtime/wasmer/test_helpers.go b/lib/runtime/wasmer/test_helpers.go index d2ae4491db..a358ce659c 100644 --- a/lib/runtime/wasmer/test_helpers.go +++ b/lib/runtime/wasmer/test_helpers.go @@ -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 { diff --git a/lib/runtime/wasmtime/test_helpers.go b/lib/runtime/wasmtime/test_helpers.go index 75f94239f9..39e04bf915 100644 --- a/lib/runtime/wasmtime/test_helpers.go +++ b/lib/runtime/wasmtime/test_helpers.go @@ -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 diff --git a/tests/polkadotjs_test/start_polkadotjs_test.go b/tests/polkadotjs_test/start_polkadotjs_test.go index 9f02aaf880..eec1dd5835 100644 --- a/tests/polkadotjs_test/start_polkadotjs_test.go +++ b/tests/polkadotjs_test/start_polkadotjs_test.go @@ -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)