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):
OS: Windows 10
Browser Google Chrome
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
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;
}
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;
} ;; from the same test-file works well, returns proper result