Skip to content

Commit

Permalink
test: Add json marshal/unmarshal for test traces (#1314)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
p-offtermatt authored Sep 25, 2023
1 parent cb6f856 commit 3d4627b
Show file tree
Hide file tree
Showing 20 changed files with 10,925 additions and 9 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ require (
github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect
github.com/creachadair/taskgroup v0.4.2 // indirect
github.com/danieljoos/wincred v1.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davecgh/go-spew v1.1.1
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
github.com/dgraph-io/badger/v2 v2.2007.4 // indirect
Expand All @@ -88,7 +88,7 @@ require (
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-cmp v0.5.9
github.com/google/orderedcode v0.0.1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
Expand Down Expand Up @@ -161,7 +161,7 @@ require (
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
nhooyr.io/websocket v1.8.6 // indirect
pgregory.net/rapid v0.5.5 // indirect
pgregory.net/rapid v0.5.5
sigs.k8s.io/yaml v1.3.0 // indirect
)

Expand Down
13 changes: 13 additions & 0 deletions tests/e2e/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Updating the trace format and tests when adjusting the framework

Some things in the test framework should stay consistent, in particular with respect to the trace format.
When adding or modifying actions, please follow these guidelines:
* Add a case for your action to `main.go`
* Add a case for your action to `json_utils.go/UnmarshalMapToActionType`
* Add a generator for your action to `action_rapid_test.go` and add the generator to `GetActionGen`

If the chain state from `state.go` is modified, the `ChainStateWithProposalTypes` in `json_utils.go/MarshalJSON` should be updated.

When adding a new proposal type:
* add a case for your proposal type to `json_utils.go/UnmarshalProposalWithType`
* add a generator for your proposal type in `state_rapid_test.go` and add it to the `GetProposalGen` function
Loading

0 comments on commit 3d4627b

Please sign in to comment.