Skip to content
Snippets Groups Projects

Testing framework: fix sorting on decompilation/compilation of maps/sets

Merged E. Rivas requested to merge er433/fix/test-comparison into dev

Motivation and Context

It was reported in #ligo by Chiachi and also by Smartchain that there are issues when interpreting Michelson code related to maps and sets in which elements are not ordered.

Description

This MR keeps sets and maps in order.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Performance improvement (non-breaking change that improves performance)
  • None (change with no changelog)

Changelog

Example file

$ cat test_compare_setmap.mligo 

let test_address_set =
 let s : address set = Set.empty in
 let s = Set.add ("tz1KeYsjjSCLEELMuiq1oXzVZmuJrZ15W4mv" : address) s in
 let s = Set.add ("tz1TDZG4vFoA2xutZMYauUnS4HVucnAGQSpZ" : address) s in
 let s : address set = Test.decompile (Test.eval s) in
 Test.eval s

Before

$ ligo run test test_compare_setmap.mligo 
Error(s) occurred while parsing the Michelson input:
At (unshown) location 0, value
  { "tz1TDZG4vFoA2xutZMYauUnS4HVucnAGQSpZ" ;
    "tz1KeYsjjSCLEELMuiq1oXzVZmuJrZ15W4mv" } is invalid for type set address.
Values in a set literal must be in strictly ascending order, but they were unordered in literal:
  { "tz1TDZG4vFoA2xutZMYauUnS4HVucnAGQSpZ" ;
    "tz1KeYsjjSCLEELMuiq1oXzVZmuJrZ15W4mv" } 

After

$ ligo run test test_compare_setmap.mligo 
Everything at the top-level was executed.   
- test_address_set exited with value { "tz1KeYsjjSCLEELMuiq1oXzVZmuJrZ15W4mv" ;
  "tz1TDZG4vFoA2xutZMYauUnS4HVucnAGQSpZ" }.

Checklist:

  • Changes follow the existing coding style (use dune @fmt to check).
  • Tests for the changes have been added (for bug fixes / feature).
  • Documentation has been updated.
  • Changelog description has been added (if appropriate).
  • Start titles under ## Changelog section with #### (if appropriate).
  • There is no image or uploaded file in changelog
  • Examples in changed behaviour have been added to the changelog (for breaking change / feature).
Edited by E. Rivas

Merge request reports

Merge train pipeline #708419281 passed with warnings

Merge train pipeline passed with warnings for 92ea6bb7

Approved by

Merged by E. RivasE. Rivas 2 years ago (Nov 29, 2022 6:14pm UTC)

Merge details

  • Changes merged into dev with 6e747c67 (commits were squashed).
  • Deleted the source branch.
  • Auto-merge enabled

Pipeline #708444116 passed

Pipeline passed for 6e747c67 on dev

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
Please register or sign in to reply
Loading