@@ -130,18 +130,44 @@ test-integration:
130130 @echo " --> Running integration tests"
131131 cd integration; go test -v ./...
132132
133+ COV_ROOT ="/tmp/tokenfactory-coverage"
134+ COV_UNIT_E2E ="${COV_ROOT}/unit-e2e"
135+ COV_SIMULATION ="${COV_ROOT}/simulation"
136+ COV_PKG ="github.com/strangelove-ventures/tokenfactory/..."
137+ COV_SIM_CMD =${COV_SIMULATION}/simulation.test
138+ COV_SIM_COMMON=-Enabled =True -NumBlocks=100 -Commit=true -Period=5 -Verbose=false -test.v -test.gocoverdir=${COV_SIMULATION}
139+
133140coverage : # # Run coverage report
134- @echo " --> Running coverage"
135- @go test -race -cpu=$$(nproc ) -covermode=atomic -coverprofile=coverage.out $$(go list ./... ) ./interchaintest/... -coverpkg=github.com/strangelove-ventures/tokenfactory/... > /dev/null 2>&1
136- @echo " --> Running coverage filter"
137- @./scripts/filter-coverage.sh
138- @echo " --> Running coverage report"
139- @go tool cover -func=coverage-filtered.out
140- @echo " --> Running coverage html"
141- @go tool cover -html=coverage-filtered.out -o coverage.html
141+ @echo " --> Creating GOCOVERDIR"
142+ @mkdir -p ${COV_UNIT_E2E} ${COV_SIMULATION}
143+ @echo " --> Cleaning up coverage files, if any"
144+ @rm -rf ${COV_UNIT_E2E} /* ${COV_SIMULATION} /*
145+ @echo " --> Building instrumented simulation test binary"
146+ @go test -c ./app -mod=readonly -covermode=atomic -coverpkg=${COV_PKG} -cover -o ${COV_SIM_CMD}
147+ @echo " --> Running Full App Simulation"
148+ @${COV_SIM_CMD} -test.run TestFullAppSimulation ${COV_SIM_COMMON} > /dev/null 2>&1
149+ # Enable after wiring v2 is implemented
150+ # @echo " --> Running App Import/Export Simulation"
151+ # @${COV_SIM_CMD} -test.run TestAppImportExport ${COV_SIM_COMMON} > /dev/null 2>&1
152+ @echo " --> Running App Simulation After Import"
153+ @${COV_SIM_CMD} -test.run TestAppSimulationAfterImport ${COV_SIM_COMMON} > /dev/null 2>&1
154+ @echo " --> Running App State Determinism Simulation"
155+ @${COV_SIM_CMD} -test.run TestAppStateDeterminism ${COV_SIM_COMMON} > /dev/null 2>&1
156+ @echo "--> Running unit & e2e tests coverage"
157+ @go test -timeout 30m -race -covermode=atomic -v -cpu=$$(nproc) -cover $$(go list ./...) ./interchaintest/... -coverpkg=${COV_PKG} -args -test.gocoverdir="${COV_UNIT_E2E}" > /dev/null 2>&1
158+ @echo "--> Merging coverage reports"
159+ @go tool covdata merge -i=${COV_UNIT_E2E},${COV_SIMULATION} -o ${COV_ROOT}
160+ @echo "--> Converting binary coverage report to text format"
161+ @go tool covdata textfmt -i=${COV_ROOT} -o ${COV_ROOT}/coverage-merged.out
162+ @echo "--> Filtering coverage reports"
163+ @./scripts/filter-coverage.sh ${COV_ROOT}/coverage-merged.out ${COV_ROOT}/coverage-merged-filtered.out
164+ @echo "--> Generating coverage report"
165+ @go tool cover -func=${COV_ROOT}/coverage-merged-filtered.out
166+ @echo "--> Generating HTML coverage report"
167+ @go tool cover -html=${COV_ROOT}/coverage-merged-filtered.out -o coverage.html
142168 @echo "--> Coverage report available at coverage.html"
143169 @echo "--> Cleaning up coverage files"
144- @rm coverage.out
170+ @rm -rf ${COV_UNIT_E2E}/* ${COV_SIMULATION}/*
145171 @echo "--> Running coverage complete"
146172
147173.PHONY : test test-integration coverage
@@ -189,6 +215,49 @@ lint-fix:
189215.PHONY : lint lint-fix
190216
191217# #################
218+ # ## Simulation ###
219+ # #################
220+
221+ SIM_NUM_BLOCKS ?= 100
222+ SIM_PERIOD ?= 5
223+ SIM_COMMIT ?= true
224+ SIM_ENABLED ?= true
225+ SIM_VERBOSE ?= false
226+ SIM_TIMEOUT ?= 24h
227+ SIM_SEED ?= 42
228+ SIM_COMMON_ARGS = -NumBlocks=${SIM_NUM_BLOCKS} -Enabled=${SIM_ENABLED} -Commit=${SIM_COMMIT} -Period=${SIM_PERIOD} -Verbose=${SIM_VERBOSE} -Seed=${SIM_SEED} -v -timeout ${SIM_TIMEOUT}
229+
230+ sim-full-app :
231+ @echo " --> Running full app simulation (blocks: ${SIM_NUM_BLOCKS} , commit: ${SIM_COMMIT} , period: ${SIM_PERIOD} , seed: ${SIM_SEED} "
232+ @go test ./app -run TestFullAppSimulation ${SIM_COMMON_ARGS}
233+
234+ sim-full-app-random :
235+ $(MAKE ) sim-full-app SIM_SEED=$$ RANDOM
236+
237+ # Note: known to fail when using app wiring v1
238+ sim-import-export :
239+ @echo " --> Running app import/export simulation (blocks: ${SIM_NUM_BLOCKS} , commit: ${SIM_COMMIT} , period: ${SIM_PERIOD} , seed: ${SIM_SEED} "
240+ @go test ./app -run TestAppImportExport ${SIM_COMMON_ARGS}
241+
242+ # Note: known to fail when using app wiring v1
243+ sim-import-export-random :
244+ $(MAKE ) sim-import-export SIM_SEED=$$ RANDOM
245+
246+ sim-after-import :
247+ @echo " --> Running app after import simulation (blocks: ${SIM_NUM_BLOCKS} , commit: ${SIM_COMMIT} , period: ${SIM_PERIOD} , seed: ${SIM_SEED} "
248+ @go test ./app -run TestAppSimulationAfterImport ${SIM_COMMON_ARGS}
249+
250+ sim-after-import-random :
251+ $(MAKE ) sim-after-import SIM_SEED=$$ RANDOM
252+
253+ sim-app-determinism :
254+ @echo " --> Running app determinism simulation (blocks: ${SIM_NUM_BLOCKS} , commit: ${SIM_COMMIT} , period: ${SIM_PERIOD} , seed: ${SIM_SEED} "
255+ @go test ./app -run TestAppStateDeterminism ${SIM_COMMON_ARGS}
256+
257+ sim-app-determinism-random :
258+ $(MAKE ) sim-app-determinism SIM_SEED=$$ RANDOM
259+
260+ .PHONY : sim-full-app sim-full-app-random sim-import-export sim-after-import sim-app-determinism sim-import-export-random sim-after-import-random sim-app-determinism-random
192261# ## Security ###
193262# #################
194263govulncheck_version =latest
0 commit comments