[go: up one dir, main page]

Draft: Counter onboarding challenge

Context

Solve the "counter" onboarding challenge. Introduced two octez-client commands, one to update the counter with any integer value, and one to obtain the current value of the counter.

  1. octez-client update mock counter with <value> <account> : increases the mock counter with value (can be negative as well), but must be an integer; consumes gas since it updates the context
  2. octez-client get mock counter : similar to octez-client get balance for <account>; obtains the current value of the global, shared, mock counter; it does not consume any gas, as it only reads a value from the context, without altering it.

Added two Michelson instructions - GET_COUNTER and SET_COUNTER, which can interact with the mock counter created and added tests for them.

Manually testing the MR

Added unit testing for initialising and adding a value to the counter. Added integration testing for the two new octez-client commands. Added integration testing for the two new Michelson instructions.

Originated a contract that can interact with the mock_counter, with its Michelson code which can be found in mock_counter_test.tz:

  1. Originate the smart contract with the mockup mode:
$ mockup-client originate contract mock_counter_test \                                    
                transferring 0 from bootstrap1 \
                running "`cat mock_counter_test.tz`" \
                --burn-cap 0.1   
  1. Check that setting the value of the mock_counter overwrites anything that was previously there:
$ mockup-client transfer 0 from bootstrap2 to mock_counter_test --arg "(Left 10)" --burn-cap 0.01

$ mockup-client get mock counter                                                                  
Value of the mock counter: 10
  1. Update the value of the mock_counter:
$ mockup-client transfer 0 from bootstrap2 to mock_counter_test --arg "(Right 101)" --burn-cap 0.01 

$ mockup-client get mock counter                                                                    
Value of the mock counter: 111

This combines both the testing of the Michelson instructions and the testing of the octez-client commands.

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 Gabriel Moise

Merge request reports

Loading