[go: up one dir, main page]

Draft: Proto: Counter Challenge

Context

note: this is a MR for an onboarding task and should not be merged

Implements a global counter that can be monotonically incremented through the command line or within contracts using a new Michelson primitive.

command line: octez-client increment counter by <AMOUNT> from <SOURCE>

Michelson: INCR n

Manually testing the MR

Node:

./src/bin_node/octez-sandboxed-node.sh 1 --connections 0

Client:

eval `./src/bin_client/octez-init-sandboxed-client.sh 1`
octez-autocomplete
octez-activate-alpha
octez-client increment counter by 1 from bootstrap1 --fee 0.01
octez-client bake for --minimal-timestamp
octez-client get counter

==> Counter: 1

octez-client increment counter by 20 from bootstrap2 --fee 0.01
octez-client get counter

==> Counter: 1

octez-client increment counter by 300 from bootstrap1 --fee 0.01
octez-client bake for --minimal-timestamp
octez-client get counter

==> Counter: 321

Unit tests

dune exec src/proto_alpha/lib_protocol/test/unit/main.exe -- --file test_counter_storage.ml
  1. test_initialise: Initializes the global counter with a default value of zero
  2. test_incr n: increments the global counter by n
  3. test_incr_res n: Compares the expected result of incrementing the global counter by a specific value (n) with the actual result obtained from the get function after the increment.
  4. test_incrs (n list): Increments the global counter iteratively using a list of values.

Integration tests

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).
    • unit tests
    • integration tests
  • 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.
Edited by AC

Merge request reports

Loading