Skip to content

Commit 9fae984

Browse files
authored
tests: refactoring (#198)
* test refactoring evmd as separate package - we can make sure more clean dependency: only evmd -> evmd allows. not vice versa. test re-structuring - tests using network + evmd moved into evm/tests/integration - test file names are changed from *_test.go to test_*.go, so any client chains can leverage cosmos/evm's test suites with their own application refactoring - all integration tests in evm uses EvmApp interface. so it allows other client application can leverage cosmos/evm's test suites. - evmd implements methods of EvmApp - separate Erc20Keeper interface to avoid cyclic import between erc20/keeper and precompiles/erc20 - change backend member variables to public. this is for making testing refactoring easier. if there are some security concern, we should consider introducing getters. removed un-used files * upstream merge and resolve conflicts * fix lints & ci removed already migrated test also * fix ci * fix lint issues * fix ginkgo issues and update testing ci, makefile * gci formatted and re-organize authz test * add missed test case * fix ci issue * erc20 cyclic dependencies resolved * chore: typo * chore: package name * chore: test convention * chore: test convention * chore: align convention * un-do un-necessary change pb files should not be touched * re-organize ibc testing dir and make ibc testsing using EvmApp, not evmd * fix Makefile * change go mod name to github.com/cosmos/evm/evmd * merge main & resolve conflicts * fix lint
1 parent 679305d commit 9fae984

File tree

336 files changed

+25808
-22727
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

336 files changed

+25808
-22727
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ jobs:
3232
**/**.go
3333
go.mod
3434
go.sum
35+
evmd/go.mod
36+
evmd/go.sum
37+
evmd/**/**.go
3538
*.toml
3639
- name: Test and Create Coverage Report
3740
run: |

.golangci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ linters:
8282
- staticcheck
8383
path: migrations
8484
text: 'SA1019:'
85+
- linters:
86+
- staticcheck
87+
path: ^tests/integration/
88+
- linters:
89+
- stylecheck
90+
text: 'ST1001:'
8591
paths:
8692
- x/vm/core
8793
- third_party$

Makefile

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -101,39 +101,52 @@ vulncheck:
101101
### Tests & Simulation ###
102102
###############################################################################
103103

104-
test: test-unit
105-
test-all: test-unit test-race
104+
PACKAGES_UNIT := $(shell go list ./... | grep -v '/tests/e2e$$' | grep -v '/simulation')
105+
PACKAGES_EVMD := $(shell cd evmd && go list ./... | grep -v '/simulation')
106+
COVERPKG_EVM := $(shell go list ./... | grep -v '/tests/e2e$$' | grep -v '/simulation' | paste -sd, -)
107+
COVERPKG_ALL := $(COVERPKG_EVM)
108+
COMMON_COVER_ARGS := -timeout=15m -covermode=atomic
106109

107-
# For unit tests we don't want to execute the upgrade tests in tests/e2e but
108-
# we want to include all unit tests in the subfolders (tests/e2e/*)
109-
PACKAGES_UNIT=$(shell go list ./... | grep -v '/tests/e2e$$')
110-
TEST_PACKAGES=./...
111-
TEST_TARGETS := test-unit test-unit-cover test-race
110+
TEST_PACKAGES := ./...
111+
TEST_TARGETS := test-unit test-evmd test-unit-cover test-race
112112

113-
# Test runs-specific rules. To add a new test target, just add
114-
# a new rule, customise ARGS or TEST_PACKAGES ad libitum, and
115-
# append the new rule to the TEST_TARGETS list.
116113
test-unit: ARGS=-timeout=15m
117114
test-unit: TEST_PACKAGES=$(PACKAGES_UNIT)
115+
test-unit: run-tests
118116

119117
test-race: ARGS=-race
120-
test-race: TEST_PACKAGES=$(PACKAGES_NOSIMULATION)
121-
$(TEST_TARGETS): run-tests
118+
test-race: TEST_PACKAGES=$(PACKAGES_UNIT)
119+
test-race: run-tests
120+
121+
test-evmd: ARGS=-timeout=15m
122+
test-evmd:
123+
@cd evmd && go test -tags=test -mod=readonly $(ARGS) $(EXTRA_ARGS) $(PACKAGES_EVMD)
122124

123125
test-unit-cover: ARGS=-timeout=15m -coverprofile=coverage.txt -covermode=atomic
124126
test-unit-cover: TEST_PACKAGES=$(PACKAGES_UNIT)
125-
test-unit-cover:
126-
@echo "Filtering ignored files from coverage.txt..."
127-
@grep -v -E '/cmd/|/client/|/proto/|/testutil/|/mocks/|/test_.*\.go:|\.pb\.go:|\.pb\.gw\.go:|/x/[^/]+/module\.go:|/scripts/|/ibc/testing/|/version/|\.md:|\.pulsar\.go:' coverage.txt > tmp_coverage.txt && mv tmp_coverage.txt coverage.txt
128-
@echo "Function-level coverage summary:"
127+
test-unit-cover: run-tests
128+
@echo "🔍 Running evm (root) coverage..."
129+
@go test -tags=test $(COMMON_COVER_ARGS) -coverpkg=$(COVERPKG_ALL) -coverprofile=coverage.txt ./...
130+
@echo "🔍 Running evmd coverage..."
131+
@cd evmd && go test -tags=test $(COMMON_COVER_ARGS) -coverpkg=$(COVERPKG_ALL) -coverprofile=coverage_evmd.txt ./...
132+
@echo "🔀 Merging evmd coverage into root coverage..."
133+
@tail -n +2 evmd/coverage_evmd.txt >> coverage.txt && rm evmd/coverage_evmd.txt
134+
@echo "📊 Coverage summary:"
129135
@go tool cover -func=coverage.txt
130136

137+
test: test-unit
138+
139+
test-all:
140+
@echo "🔍 Running evm module tests..."
141+
@go test -tags=test -mod=readonly -timeout=15m $(PACKAGES_NOSIMULATION)
142+
@echo "🔍 Running evmd module tests..."
143+
@cd evmd && go test -tags=test -mod=readonly -timeout=15m $(PACKAGES_EVMD)
131144

132145
run-tests:
133146
ifneq (,$(shell which tparse 2>/dev/null))
134147
go test -tags=test -mod=readonly -json $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES) | tparse
135148
else
136-
go test -tags=test -mod=readonly $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES)
149+
go test -tags=test -mod=readonly $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES)
137150
endif
138151

139152
# Use the old Apple linker to workaround broken xcode - https://github.com/golang/go/issues/65169

0 commit comments

Comments
 (0)