disintar / toncli

TON Command Line Interface - easy smart contract manipulation
https://disintar.io/
Apache License 2.0
158 stars 35 forks source link

Toncli run_tests => [__test_equal_slices_contract] status: [FAIL], code: [7] #113

Closed Cosmodude closed 1 year ago

Cosmodude commented 1 year ago

Bug Type

Performance

Reproduction steps

int equal_slices (slice a, slice b) asm "SDEQ"; ;; in the contract

;; function in the contract (slice, cell) load_data() inline { cell ds = get_data(); slice data = ds.begin_parse(); slice manager = data~load_msg_addr(); if (data.slice_refs() == 0) { return (manager, new_dict()); } else { cell dict = data~load_ref(); return (manager, dict); } }

:: in the test function file: () set_default_initial_data() impure { cell dict = new_dict(); slice hash = "kQBtO0gynpAGdXQn0lyYL2QhhGQQ_4PHe2kIM50eSuP9NX7z"; slice manager_address = "kQDmznN8tOKzSQxHTzMTege2QKFcrCwnkTNRtY2cubGB1IKu"a; dict~udict_set(32, 1, hash); set_data(begin_cell() .store_slice(manager_address) ;; store managers address .store_ref(dict) ;; store dict as ref cell .end_cell()); }

;; Testing function:

int __test_equal_slices_contract() { set_default_initial_data(); slice sender_address = "kQDmznN8tOKzSQxHTzMTege2QKFcrCwnkTNRtY2cubGB1IKu"a;

var (_ , stack) = invoke_method(load_data, []);
[slice manager_address, cell dict] = stack;

var (int gas_used, int result) = invoke_method(equal_slices, [sender_address, manager_address]);
throw_if(102, result);
return result;

}

Actual result

INFO: Test [__test_equal_slices_contract] status: [FAIL], code: [7] Total gas used (including testing code): [9229]

Expected result

INFO: Test [__test_equal_slices_contract] status: [SUCCESS] Test result: [[ -1 ]] Total gas used (including testing code): [--]

Suggested Severity

Low

Device

Desktop (please complete the following information):

Additional Context

;; Strange that function:

int __test_equal_slices_here() { slice a = "kQDmznN8tOKzSQxHTzMTege2QKFcrCwnkTNRtY2cubGB1IKu"a; slice b = "kQDmznN8tOKzSQxHTzMTege2QKFcrCwnkTNRtY2cubGB1IKu"a;

int res = equal_slices(a,b);
return res;

} ;; from the same test-file works well, returns proper result

Cosmodude commented 1 year ago

The problem was not with the invoke methods. Remember that invoke_method returns: int + tuple !!!