mirror of
https://github.com/ton-blockchain/ton
synced 2025-02-12 19:22:37 +00:00
[FunC] Apply camelCase to some tests to ensure code_hash remains unchanged
In auto-tests, @code_hash controls bytecode stability. In legacy tests, expected hashes are specified in a separate file.
This commit is contained in:
parent
c74e49d467
commit
a174f858be
8 changed files with 85 additions and 38 deletions
|
@ -12,8 +12,16 @@ cell load_data() inline_ref {
|
|||
set_data(st);
|
||||
}
|
||||
|
||||
cell loadData() {
|
||||
return load_data();
|
||||
}
|
||||
|
||||
() saveData(cell c) impure {
|
||||
return save_data(c);
|
||||
}
|
||||
|
||||
() vote_on_external_chain(slice s_addr, int query_id, int voting_id, slice signature) impure {
|
||||
cell external_votings = load_data();
|
||||
cell external_votings = loadData();
|
||||
(_, int oracles_address, cell oracles) = get_bridge_config();
|
||||
(int wc, int addr) = parse_std_addr(s_addr);
|
||||
throw_if(301, wc + 1);
|
||||
|
@ -39,12 +47,12 @@ cell load_data() inline_ref {
|
|||
.store_dict(signatures);
|
||||
external_votings~udict_set_builder(256, voting_id, new_voting_data);
|
||||
|
||||
save_data(external_votings);
|
||||
saveData(external_votings);
|
||||
return send_receipt_message(s_addr, 0x10000 + 5, query_id, voting_id, 0, 64);
|
||||
}
|
||||
|
||||
() remove_outdated_votings(slice s_addr, int query_id, slice external_ids) impure {
|
||||
cell external_votings = load_data();
|
||||
cell external_votings = loadData();
|
||||
|
||||
int bound = now() - 60 * 60 * 24 * 7;
|
||||
while (~ external_ids.slice_empty?()) {
|
||||
|
@ -62,7 +70,7 @@ cell load_data() inline_ref {
|
|||
}
|
||||
}
|
||||
|
||||
save_data(external_votings);
|
||||
saveData(external_votings);
|
||||
return send_receipt_message(s_addr, 0x10000 + 6, query_id, 0, 0, 64); ;; thanks
|
||||
}
|
||||
|
||||
|
@ -96,7 +104,7 @@ cell load_data() inline_ref {
|
|||
}
|
||||
|
||||
(tuple) get_external_voting_data(int voting_id) method_id {
|
||||
cell external_votings = load_data();
|
||||
cell external_votings = loadData();
|
||||
(slice voting_data, int found?) = external_votings.udict_get?(256, voting_id);
|
||||
throw_unless(309, found?);
|
||||
(int time, int old_oracles_address, cell signatures) = (voting_data~load_uint(32),
|
||||
|
|
|
@ -2,23 +2,35 @@
|
|||
|
||||
#include "stdlib.fc";
|
||||
|
||||
(slice, cell) loadDict(slice s) { return load_dict(s); }
|
||||
(slice, int) loadGrams(slice s) { return load_grams(s); }
|
||||
(slice, int) loadUint(slice s, int len) { return load_uint(s, len); }
|
||||
() endParse(slice s) impure { return end_parse(s); }
|
||||
builder storeDict(builder b, cell c) { return store_dict(b, c); }
|
||||
builder storeUint(builder b, int x, int len) { return store_uint(b, x, len); }
|
||||
() throwUnless(int excno, int cond) impure { return throw_unless(excno, cond); }
|
||||
cell configParam(int paramNo) { return config_param(paramNo); }
|
||||
forall X -> int isNull(X x) { return null?(x); }
|
||||
(slice, int) tryUDictGet(cell dict, int keyLen, int index) { return udict_get?(dict, keyLen, index); }
|
||||
|
||||
|
||||
;; cur_elect credits past_elections grams active_id active_hash
|
||||
(cell, cell, cell, int, int, int) load_data() inline_ref {
|
||||
var cs = get_data().begin_parse();
|
||||
var res = (cs~load_dict(), cs~load_dict(), cs~load_dict(), cs~load_grams(), cs~load_uint(32), cs~load_uint(256));
|
||||
cs.end_parse();
|
||||
var res = (cs~loadDict(), cs~loadDict(), cs~load_dict(), cs~loadGrams(), cs~loadUint(32), cs~load_uint(256));
|
||||
cs.endParse();
|
||||
return res;
|
||||
}
|
||||
|
||||
;; cur_elect credits past_elections grams active_id active_hash
|
||||
() store_data(elect, credits, past_elections, grams, active_id, active_hash) impure inline_ref {
|
||||
set_data(begin_cell()
|
||||
.store_dict(elect)
|
||||
.storeDict(elect)
|
||||
.store_dict(credits)
|
||||
.store_dict(past_elections)
|
||||
.storeDict(past_elections)
|
||||
.store_grams(grams)
|
||||
.store_uint(active_id, 32)
|
||||
.store_uint(active_hash, 256)
|
||||
.storeUint(active_hash, 256)
|
||||
.end_cell());
|
||||
}
|
||||
|
||||
|
@ -63,7 +75,7 @@ builder pack_past_election(int unfreeze_at, int stake_held, int vset_hash, cell
|
|||
;; complaint_status#2d complaint:^ValidatorComplaint voters:(HashmapE 16 True)
|
||||
;; vset_id:uint256 weight_remaining:int64 = ValidatorComplaintStatus;
|
||||
_ unpack_complaint_status(slice cs) inline_ref {
|
||||
throw_unless(9, cs~load_uint(8) == 0x2d);
|
||||
throwUnless(9, cs~load_uint(8) == 0x2d);
|
||||
var res = (cs~load_ref(), cs~load_dict(), cs~load_uint(256), cs~load_int(64));
|
||||
cs.end_parse();
|
||||
return res;
|
||||
|
@ -71,7 +83,7 @@ _ unpack_complaint_status(slice cs) inline_ref {
|
|||
|
||||
builder pack_complaint_status(cell complaint, cell voters, int vset_id, int weight_remaining) inline_ref {
|
||||
return begin_cell()
|
||||
.store_uint(0x2d, 8)
|
||||
.storeUint(0x2d, 8)
|
||||
.store_ref(complaint)
|
||||
.store_dict(voters)
|
||||
.store_uint(vset_id, 256)
|
||||
|
@ -112,8 +124,8 @@ builder pack_complaint(int validator_pubkey, cell description, int created_at, i
|
|||
|
||||
;; deposit bit_price cell_price
|
||||
(int, int, int) get_complaint_prices() inline_ref {
|
||||
var info = config_param(13);
|
||||
return info.null?() ? (1 << 36, 1, 512) : info.parse_complaint_prices();
|
||||
var info = configParam(13);
|
||||
return info.isNull() ? (1 << 36, 1, 512) : info.parse_complaint_prices();
|
||||
}
|
||||
|
||||
;; elected_for elections_begin_before elections_end_before stake_held_for
|
||||
|
@ -189,7 +201,7 @@ builder pack_complaint(int validator_pubkey, cell description, int created_at, i
|
|||
|
||||
;; credits 'amount' to 'addr' inside credit dictionary 'credits'
|
||||
_ ~credit_to(credits, addr, amount) inline_ref {
|
||||
var (val, f) = credits.udict_get?(256, addr);
|
||||
var (val, f) = credits.tryUDictGet(256, addr);
|
||||
if (f) {
|
||||
amount += val~load_grams();
|
||||
}
|
||||
|
@ -352,7 +364,7 @@ _ unfreeze_all(credits, past_elections, elect_id) inline_ref {
|
|||
var config_addr = config_param(0).begin_parse().preload_uint(256);
|
||||
var ds = get_data().begin_parse();
|
||||
var elect = ds~load_dict();
|
||||
if ((src_wc + 1) | (src_addr != config_addr) | elect.null?()) {
|
||||
if ((src_wc + 1) | (src_addr != config_addr) | elect.isNull()) {
|
||||
;; not from config smc, somebody's joke?
|
||||
;; or no elections active (or just completed)
|
||||
return ();
|
||||
|
|
|
@ -2,10 +2,14 @@
|
|||
|
||||
#include "stdlib.fc";
|
||||
|
||||
_ skipBits(slice s, int len) { return skip_bits(s, len); }
|
||||
|
||||
(slice, int) dict_get?(cell dict, int key_len, slice index) asm(index dict key_len) "DICTGET" "NULLSWAPIFNOT";
|
||||
(cell, int) dict_add_builder?(cell dict, int key_len, slice index, builder value) asm(value index dict key_len) "DICTADDB";
|
||||
(cell, int) dict_delete?(cell dict, int key_len, slice index) asm(index dict key_len) "DICTDEL";
|
||||
|
||||
(cell, int) tryDictDelete(cell dict, int keyLen, slice index) { return dict_delete?(dict, keyLen, index); }
|
||||
|
||||
() recv_internal(int msg_value, cell in_msg_cell, slice in_msg) impure {
|
||||
var cs = in_msg_cell.begin_parse();
|
||||
var flags = cs~load_uint(4); ;; int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool
|
||||
|
@ -25,7 +29,7 @@
|
|||
slice s_addr = cs~load_msg_addr();
|
||||
(int wc, int addr_hash) = parse_std_addr(s_addr);
|
||||
slice wc_n_address = begin_cell().store_int(wc, 8).store_uint(addr_hash, 256).end_cell().begin_parse();
|
||||
var ds = get_data().begin_parse().skip_bits(32 + 32 + 256);
|
||||
var ds = get_data().begin_parse().skipBits(32 + 32 + 256);
|
||||
var plugins = ds~load_dict();
|
||||
var (_, success?) = plugins.dict_get?(8 + 256, wc_n_address);
|
||||
if ~(success?) {
|
||||
|
@ -54,7 +58,7 @@
|
|||
|
||||
if (op == 0x64737472) { ;; remove plugin by its request
|
||||
|
||||
plugins~dict_delete?(8 + 256, wc_n_address);
|
||||
plugins~tryDictDelete(8 + 256, wc_n_address);
|
||||
var ds = get_data().begin_parse().first_bits(32 + 32 + 256);
|
||||
set_data(begin_cell().store_slice(ds).store_dict(plugins).end_cell());
|
||||
;; return coins only if bounce expected
|
||||
|
@ -178,7 +182,7 @@ int get_public_key() method_id {
|
|||
}
|
||||
|
||||
int is_plugin_installed(int wc, int addr_hash) method_id {
|
||||
var ds = get_data().begin_parse().skip_bits(32 + 32 + 256);
|
||||
var ds = get_data().begin_parse().skipBits(32 + 32 + 256);
|
||||
var plugins = ds~load_dict();
|
||||
var (_, success?) = plugins.dict_get?(8 + 256, begin_cell().store_int(wc, 8).store_uint(addr_hash, 256).end_cell().begin_parse());
|
||||
return success?;
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
return (Dx / D, Dy / D);
|
||||
}
|
||||
|
||||
int mulDivR(int x, int y, int z) { return muldivr(x, y, z); }
|
||||
|
||||
int calc_phi() {
|
||||
var n = 1;
|
||||
repeat (70) { n *= 10; }
|
||||
|
@ -13,7 +15,7 @@ int calc_phi() {
|
|||
do {
|
||||
(p, q) = (q, p + q);
|
||||
} until (q > n);
|
||||
return muldivr(p, n, q);
|
||||
return mulDivR(p, n, q);
|
||||
}
|
||||
|
||||
int calc_sqrt2() {
|
||||
|
@ -24,7 +26,7 @@ int calc_sqrt2() {
|
|||
var t = p + q;
|
||||
(p, q) = (q, t + q);
|
||||
} until (q > n);
|
||||
return muldivr(p, n, q);
|
||||
return mulDivR(p, n, q);
|
||||
}
|
||||
|
||||
var calc_root(m) {
|
||||
|
@ -73,14 +75,18 @@ int ataninv(int base, int q) { ;; computes base*atan(1/q)
|
|||
return sum;
|
||||
}
|
||||
|
||||
int arctanInv(int base, int q) { return ataninv(base, q); }
|
||||
|
||||
int calc_pi() {
|
||||
int base = 64;
|
||||
repeat (70) { base *= 10; }
|
||||
return (ataninv(base << 2, 5) - ataninv(base, 239)) ~>> 4;
|
||||
return (arctanInv(base << 2, 5) - arctanInv(base, 239)) ~>> 4;
|
||||
}
|
||||
|
||||
int calcPi() { return calc_pi(); }
|
||||
|
||||
int main() {
|
||||
return calc_pi();
|
||||
return calcPi();
|
||||
}
|
||||
|
||||
{-
|
||||
|
|
|
@ -6,8 +6,12 @@ forall X -> tuple unsafe_tuple(X x) asm "NOP";
|
|||
return (x + y, y * 10);
|
||||
}
|
||||
|
||||
(int, int) incWrap(int x, int y) {
|
||||
return inc(x, y);
|
||||
}
|
||||
|
||||
(int, int, int, int, int, int, int) test_return(int x) method_id(11) {
|
||||
return (x, x~inc(x / 20), x, x = x * 2, x, x += 1, x);
|
||||
return (x, x~incWrap(x / 20), x, x = x * 2, x, x += 1, x);
|
||||
}
|
||||
|
||||
(int, int, int, int, int, int, int) test_assign(int x) method_id(12) {
|
||||
|
@ -16,7 +20,7 @@ forall X -> tuple unsafe_tuple(X x) asm "NOP";
|
|||
}
|
||||
|
||||
tuple test_tuple(int x) method_id(13) {
|
||||
tuple t = unsafe_tuple([x, x~inc(x / 20), x, x = x * 2, x, x += 1, x]);
|
||||
tuple t = unsafe_tuple([x, x~incWrap(x / 20), x, x = x * 2, x, x += 1, x]);
|
||||
return t;
|
||||
}
|
||||
|
||||
|
@ -39,7 +43,7 @@ tuple test_tuple(int x) method_id(13) {
|
|||
}
|
||||
|
||||
(int, int, int, int, int, int, int) test_call_2(int x) method_id(16) {
|
||||
return foo2(x, x~inc(x / 20), (x, x = x * 2, x, x += 1), x);
|
||||
return foo2(x, x~incWrap(x / 20), (x, x = x * 2, x, x += 1), x);
|
||||
}
|
||||
|
||||
(int, int, int, int, int, int, int) asm_func(int x1, int x2, int x3, int x4, int x5, int x6, int x7) asm
|
||||
|
@ -52,13 +56,13 @@ tuple test_tuple(int x) method_id(13) {
|
|||
#pragma compute-asm-ltr;
|
||||
|
||||
(int, int, int, int, int, int, int) test_call_asm_new(int x) method_id(18) {
|
||||
return asm_func(x, x~inc(x / 20), x, x = x * 2, x, x += 1, x);
|
||||
return asm_func(x, x~incWrap(x / 20), x, x = x * 2, x, x += 1, x);
|
||||
}
|
||||
|
||||
global int xx;
|
||||
(int, int, int, int, int, int, int) test_global(int x) method_id(19) {
|
||||
xx = x;
|
||||
return (xx, xx~inc(xx / 20), xx, xx = xx * 2, xx, xx += 1, xx);
|
||||
return (xx, xx~incWrap(xx / 20), xx, xx = xx * 2, xx, xx += 1, xx);
|
||||
}
|
||||
|
||||
(int, int, int, int, int) test_if_else(int x) method_id(20) {
|
||||
|
|
|
@ -1,28 +1,34 @@
|
|||
tuple empty_tuple() asm "NIL";
|
||||
forall X -> (tuple, ()) tpush(tuple t, X x) asm "TPUSH";
|
||||
tuple emptyTuple() { return empty_tuple(); }
|
||||
forall X -> (tuple, ()) tuplePush(tuple t, X value) { return tpush(t, value); }
|
||||
|
||||
tuple asm_func_1(int x, int y, int z) asm "3 TUPLE";
|
||||
tuple asm_func_2(int x, int y, int z) asm (z y x -> 0) "3 TUPLE";
|
||||
tuple asm_func_3(int x, int y, int z) asm (y z x -> 0) "3 TUPLE";
|
||||
tuple asm_func_4(int a, (int, (int, int)) b, int c) asm (b a c -> 0) "5 TUPLE";
|
||||
|
||||
_ asmFunc1(int x, int y, int z) { return asm_func_1(x, y, z); }
|
||||
_ asmFunc3(int x, int y, int z) { return asm_func_3(x, y, z); }
|
||||
|
||||
(tuple, ()) asm_func_modify(tuple a, int b, int c) asm (c b a -> 0) "SWAP TPUSH SWAP TPUSH";
|
||||
(tuple, ()) asmFuncModify(tuple a, int b, int c) { return asm_func_modify(a, b, c); }
|
||||
|
||||
global tuple t;
|
||||
|
||||
int foo(int x) {
|
||||
t~tpush(x);
|
||||
t~tuplePush(x);
|
||||
return x * 10;
|
||||
}
|
||||
|
||||
(tuple, tuple) test_old_1() method_id(11) {
|
||||
t = empty_tuple();
|
||||
tuple t2 = asm_func_1(foo(11), foo(22), foo(33));
|
||||
tuple t2 = asmFunc1(foo(11), foo(22), foo(33));
|
||||
return (t, t2);
|
||||
}
|
||||
|
||||
(tuple, tuple) test_old_2() method_id(12) {
|
||||
t = empty_tuple();
|
||||
t = emptyTuple();
|
||||
tuple t2 = asm_func_2(foo(11), foo(22), foo(33));
|
||||
return (t, t2);
|
||||
}
|
||||
|
@ -34,7 +40,7 @@ int foo(int x) {
|
|||
}
|
||||
|
||||
(tuple, tuple) test_old_4() method_id(14) {
|
||||
t = empty_tuple();
|
||||
t = emptyTuple();
|
||||
tuple t2 = empty_tuple();
|
||||
;; This actually computes left-to-right even without compute-asm-ltr
|
||||
tuple t2 = asm_func_4(foo(11), (foo(22), (foo(33), foo(44))), foo(55));
|
||||
|
@ -44,13 +50,13 @@ int foo(int x) {
|
|||
(tuple, tuple) test_old_modify() method_id(15) {
|
||||
t = empty_tuple();
|
||||
tuple t2 = empty_tuple();
|
||||
t2~asm_func_modify(foo(22), foo(33));
|
||||
t2~asmFuncModify(foo(22), foo(33));
|
||||
return (t, t2);
|
||||
}
|
||||
|
||||
(tuple, tuple) test_old_dot() method_id(16) {
|
||||
t = empty_tuple();
|
||||
tuple t2 = foo(11).asm_func_3(foo(22), foo(33));
|
||||
tuple t2 = foo(11).asmFunc3(foo(22), foo(33));
|
||||
return (t, t2);
|
||||
}
|
||||
|
||||
|
@ -58,7 +64,7 @@ int foo(int x) {
|
|||
|
||||
(tuple, tuple) test_new_1() method_id(21) {
|
||||
t = empty_tuple();
|
||||
tuple t2 = asm_func_1(foo(11), foo(22), foo(33));
|
||||
tuple t2 = asmFunc1(foo(11), foo(22), foo(33));
|
||||
return (t, t2);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,10 @@ slice endcs(builder b) asm "ENDC" "CTOS";
|
|||
int sdeq (slice s1, slice s2) asm "SDEQ";
|
||||
builder stslicer(builder b, slice s) asm "STSLICER";
|
||||
|
||||
builder storeUint(builder b, int x, int len) { return store_uint(b, x, len); }
|
||||
_ endSlice(builder b) { return endcs(b); }
|
||||
() throwUnless(int excno, int cond) impure { return throw_unless(excno, cond); }
|
||||
|
||||
_ main() {
|
||||
int i1 = iget1();
|
||||
int i2 = iget2();
|
||||
|
@ -46,8 +50,8 @@ _ main() {
|
|||
slice s2 = sget2();
|
||||
slice s3 = newc().stslicer(str1).stslicer(str2r).endcs();
|
||||
|
||||
throw_unless(int111, sdeq(s1, newc().store_uint(str1int, 12 * nibbles).endcs()));
|
||||
throw_unless(112, sdeq(s2, newc().store_uint(str2int, 6 * nibbles).endcs()));
|
||||
throw_unless(int111, sdeq(s1, newc().storeUint(str1int, 12 * nibbles).endcs()));
|
||||
throwUnless(112, sdeq(s2, newc().store_uint(str2int, 6 * nibbles).endSlice()));
|
||||
throw_unless(113, sdeq(s3, newc().store_uint(0x636f6e737431AABBCC, 18 * nibbles).endcs()));
|
||||
|
||||
int i4 = iget240();
|
||||
|
|
|
@ -17,8 +17,11 @@ int foo(int y) {
|
|||
}
|
||||
return (x + 1, y);
|
||||
}
|
||||
(int,int) bar2(int x, int y) {
|
||||
return bar(x, y);
|
||||
}
|
||||
(int, int) main(int x, int y) {
|
||||
(x, y) = bar(x, y);
|
||||
(x, y) = bar2(x, y);
|
||||
return (x, y * 10);
|
||||
}
|
||||
{-
|
||||
|
|
Loading…
Reference in a new issue