mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +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?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue