Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add rapid pbt for trace parser #913

Conversation

p-offtermatt
Copy link
Contributor

@p-offtermatt p-offtermatt commented May 3, 2023

Description

Closes: #881

Adds property based testing for trace parser using rapid https://github.com/flyingmutant/rapid.

Best viewed by file:

  • tests/e2e/.gitignore: ignores testdata, which is a folder created by rapid. it puts files there that allow rerunning failed tests
  • tests/e2e/json_parser.go & tests/e2e/json_writer.go: Minor change to actually return errors, so that the interface as intended matches the implementation. Necessary to reuse logic that checks for errors
  • tests/e2e/action_rapid_test.go Generators for actions / tests/e2e/state_rapid_test.go Generators for state (and a separate test to check that chainState is processed correctly by itself, since that was an issue)
  • tests/e2e/step_rapid_test.go Generator for traces and steps, also containing the actual test
  • tests/e2e/trace_handlers_test.go Restructured existing tests to make the actual test logic reusable for the rapid tests

Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • Included the correct type prefix in the PR title
  • Targeted the correct branch (see PR Targeting)
  • Provided a link to the relevant issue or specification
  • Included the necessary unit and integration tests
  • Included comments for documenting Go code
  • Reviewed "Files changed" and left comments if necessary
  • Confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage

@mpoke mpoke linked an issue May 9, 2023 that may be closed by this pull request
Copy link
Contributor

@MSalopek MSalopek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval!

@p-offtermatt p-offtermatt merged commit 930e7b1 into feat/upgrade-e2e-testing May 12, 2023
5 checks passed
@p-offtermatt p-offtermatt deleted the ph/881-testing-add-rapid-pbt-for-trace-parser branch May 12, 2023 13:50
p-offtermatt added a commit that referenced this pull request Sep 12, 2023
* Add other steps to read/write test

* Improve error logging in trace handler test

* Push ActionType handling into Unmarshal/Marshal and out of own class

* Rename generic trace handler files to be clear they are for json

* Rename to marshalling to be more generic

* Add marshal/unmarshal for proposals

* Export unexported field

* Add test for marshal/unmarshalling chain state

* Fix pointer issues

* Fix typo: action -> proposal

* Log proposal string in test

* Use json.RawMessage instead of map[string]any

* For uniformity, also use RawMessage for step unmarshalling

* Add tests for extra proposal types

* Add more proposal types to test and unify names

* Add handling for ParamsProposal

* Regenerate traces

* Chore: Export forgotten field

* Use string, not int, to help marshal/unmarshal

* Add rapid to go.mod and .sum

* Add rapidpbt for chainState marshalling

* Rename file to make clear it only relates to chainState

* Add error return to TraceWriter and TraceParser

* gst

* Add generators  for actions and steps, utilize in test driver

* Restrict range for time

* Add test for time marshal/unmarshal

* Make time have a lower bound, since negative numbers are not supported by RFC3339

* Improve label string for argument to time.Unix

* Correct lower bound for time: 1900 years negative instead of 2000

* Convert timestamp to utc

* Format file

* Ignore testdata folder

* Add go comment

* Add docstring to GetTraceGen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Testing: Add rapid PBT for trace parser
2 participants