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
- test_initialise: Initializes the global counter with a default value of zero
-
test_incr n: increments the global counter by
n -
test_incr_res n: Compares the expected result of incrementing the global counter by a specific value (
n) with the actual result obtained from thegetfunction after the increment. - 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.rstfor the protocol and the environment,CHANGES.rstat the root of the repository for everything else). -
Select suitable reviewers using the Reviewersfield below.
Edited by AC