[go: up one dir, main page]

Tests/Python: Simplify constants mockup pytest

Context

The mockup client's python tests checks that it's initialization respects any constant overrides passed during initialization. For this purpose, the test contained a hard-coded version of the constants defined in src/proto_alpha/lib_client/mockup.ml, where each field was slightly changed from the default.

The problem with this approach is that whenever a new parametric constant is added to the protocol (happens often), the test would have to be modified by hand. To make things worse, adding constants already induces a large amount of boiler plate code elsewhere.

In this MR, instead of hard coding the values of the parametric protocol constants in the test:

  • expose a new protocol RPC /chains/main/blocks/head/context/constants/parametric returning the value of the parametric constants
  • then the test uses the value of this RPC along with it's schema to produce a different value of the parametric constants
  • some ad hoc code is needed to handle the specifics of the mockup node (namely, handling the very constant consensus_threshold and the mockup-specific constants initial_timestamp and chain_id

Discussion

With this MR, developers will only have to update test_mockup.py :

  • if they add a parametric constant of a type that is not yet present in that file and for which I did not code support for "producing a different value according to a schema".
  • if they add new mockup specific protocol constants
  • if something unforeseen changes

The test will be translate to tezt, in the upcoming "2022Q3 OKR 1.4: All Python tests are rewritten in OCaml and flaky tests are fixed".

Manually testing the MR

Checklist

  • Document the interface of any function added or modified (see the coding guidelines)
  • Document any change to the user interface, including configuration parameters (see node configuration)
  • Provide automatic testing (see the testing guide).
  • For new features and bug fixes, add an item in the appropriate changelog (docs/protocols/alpha.rst for the protocol and the environment, CHANGES.rst at the root of the repository for everything else).
  • Select suitable reviewers using the Reviewers field below.
  • Select as Assignee the next person who should take action on that MR
Edited by Arvid Jakobsson

Merge request reports

Loading