tezos-checker / checker

An in-development "robocoin" system for the Tezos blockchain
24 stars 16 forks source link

Increase coverage for cfmm.ml #181

Closed gkaracha closed 3 years ago

gkaracha commented 3 years ago

Coverage increases

  1. due to the addition of the following new tests:
    • cfmm_remove_liquidity - too much lqt withdrawn (equal)
    • cfmm_remove_liquidity - too much lqt withdrawn (more than)
    • cfmm_remove_liquidity - error_CfmmTooLate - barely (equal)
    • cfmm_remove_liquidity - error_CfmmTooLate - over (unequal)
    • view_buy_kit_min_kit_expected - fail if no ctez is given
    • view_sell_kit_min_ctez_expected - fail if no kit is given
    • view_remove_liquidity_min_ctez_withdrawn - too much lqt withdrawn (equal)
    • view_remove_liquidity_min_ctez_withdrawn - too much lqt withdrawn (more than)
    • view_remove_liquidity_min_kit_withdrawn - too much lqt withdrawn (equal)
    • view_remove_liquidity_min_kit_withdrawn - too much lqt withdrawn (more than)
    • view_remove_liquidity_min_ctez_withdrawn - fail if no liquidity is given
    • view_remove_liquidity_min_kit_withdrawn - fail if no liquidity is given
    • cfmm_add_liquidity - error_CfmmTooLate - barely (equal)
    • cfmm_add_liquidity - error_CfmmTooLate - over (unequal)
    • view_add_liquidity_max_kit_deposited - fail if no ctez is given
    • view_add_liquidity_min_lqt_minted - fail if no ctez is given
  2. due to the removal of the following inaccessible error paths (inaccessible because of arithmetic-related reasons)
    • error_SellKitTooMuchTezBought
    • error_BuyKitTooMuchKitBought
    • error_AddLiquidityZeroKitDeposited
    • error_RemoveLiquidityTooMuchTezWithdrawn
    • error_RemoveLiquidityTooMuchKitWithdrawn

Note that cfmm.ml has been and still is reported as having 100% test coverage by bisect_ppx, but before this PR it was at 92.31% real. I think that with this PR we get to an actual 100%, but to check that I have to manually switch the if-then-elses to match-withs at the moment. I (painstakingly) checked and we are now at real 100% coverage for cfmm.ml.

gkaracha commented 3 years ago

The removal of error_SellKitTooMuchTezBought and error_BuyKitTooMuchKitBought lead to a slight bytecode size reduction as well:

<                              buy_kit: ~1518 bytes, 1 chunks
>                              buy_kit: ~1472 bytes, 1 chunks

<                             sell_kit: ~1518 bytes, 1 chunks
>                             sell_kit: ~1472 bytes, 1 chunks
gkaracha commented 3 years ago

Total bytecode size reduction:

<                              buy_kit: ~1518 bytes, 1 chunks
>                              buy_kit: ~1472 bytes, 1 chunks

<                             sell_kit: ~1518 bytes, 1 chunks
>                             sell_kit: ~1472 bytes, 1 chunks

<                        add_liquidity: ~2169 bytes, 1 chunks
>                        add_liquidity: ~2131 bytes, 1 chunks

<                     remove_liquidity: ~2311 bytes, 1 chunks
>                     remove_liquidity: ~2223 bytes, 1 chunks