Skip to content

Commit 3d4627b

Browse files
authored
test: Add json marshal/unmarshal for test traces (#1314)
* Add json marshal/unmarshal for test traces * Remove auto-generated trace files * Add an example trace to see the input format * Add comment in rapid test * Remove duplicated test case * Remove TODO in favor of comment * Reduce code duplication * Run go mod tidy and make format * Correct testdata directory in gitignore * Remove testdata directory * Remove testdata from gitignore * Add tracehandler_testdata * Remove example trace, since there are examples in the test data * Revert unintentional change to .gitignore * Remove propType field from generator * Add docstrings to action_rapid test and state_rapid_test to better explain what the files are doing * bite -> byte * Refactor: slashThrottleDequeue to slashThrottleDequeueAction * action name -> action type * use method name as first word in docstring * Simply remove simply * Clarify that WriteTrace overrides * Remove outdated comments * Add RegisteredConsumerRewardDenoms to rapid test * Add gen for submitChangeRewardDenomsProposalAction * Remove startChain steps * Marshal step files with indent * Add README that contains info about updates to trace format * Pull out the copied ChainState and Proposal types from methods * Use shadowing to avoid relisting chainstate fields * Make format * Remove log
1 parent cb6f856 commit 3d4627b

20 files changed

+10925
-9
lines changed

go.mod

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ require (
6868
github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect
6969
github.com/creachadair/taskgroup v0.4.2 // indirect
7070
github.com/danieljoos/wincred v1.1.2 // indirect
71-
github.com/davecgh/go-spew v1.1.1 // indirect
71+
github.com/davecgh/go-spew v1.1.1
7272
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
7373
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
7474
github.com/dgraph-io/badger/v2 v2.2007.4 // indirect
@@ -88,7 +88,7 @@ require (
8888
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
8989
github.com/golang/snappy v0.0.4 // indirect
9090
github.com/google/btree v1.1.2 // indirect
91-
github.com/google/go-cmp v0.5.9 // indirect
91+
github.com/google/go-cmp v0.5.9
9292
github.com/google/orderedcode v0.0.1 // indirect
9393
github.com/google/uuid v1.3.0 // indirect
9494
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
@@ -161,7 +161,7 @@ require (
161161
gopkg.in/ini.v1 v1.67.0 // indirect
162162
gopkg.in/yaml.v3 v3.0.1 // indirect
163163
nhooyr.io/websocket v1.8.6 // indirect
164-
pgregory.net/rapid v0.5.5 // indirect
164+
pgregory.net/rapid v0.5.5
165165
sigs.k8s.io/yaml v1.3.0 // indirect
166166
)
167167

tests/e2e/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## Updating the trace format and tests when adjusting the framework
2+
3+
Some things in the test framework should stay consistent, in particular with respect to the trace format.
4+
When adding or modifying actions, please follow these guidelines:
5+
* Add a case for your action to `main.go`
6+
* Add a case for your action to `json_utils.go/UnmarshalMapToActionType`
7+
* Add a generator for your action to `action_rapid_test.go` and add the generator to `GetActionGen`
8+
9+
If the chain state from `state.go` is modified, the `ChainStateWithProposalTypes` in `json_utils.go/MarshalJSON` should be updated.
10+
11+
When adding a new proposal type:
12+
* add a case for your proposal type to `json_utils.go/UnmarshalProposalWithType`
13+
* add a generator for your proposal type in `state_rapid_test.go` and add it to the `GetProposalGen` function

0 commit comments

Comments
 (0)