From c0718589c83ece186d8447a7e0a761f3990d99b2 Mon Sep 17 00:00:00 2001 From: radrow Date: Sun, 8 May 2022 10:53:35 +0200 Subject: [PATCH] Remove unused tests --- test/contracts/Makefile | 15 ---- test/contracts/abort_test.aes | 31 ------- test/contracts/abort_test_int.aes | 27 ------ test/contracts/channel_env.aes | 8 -- ...nnel_on_chain_contract_name_resolution.aes | 7 -- .../channel_on_chain_contract_oracle.aes | 51 ----------- ...mote_on_chain_contract_name_resolution.aes | 9 -- test/contracts/chess.aes | 51 ----------- test/contracts/contract_types.aes | 20 ----- test/contracts/erc20_token.aes | 87 ------------------- test/contracts/exploits.aes | 6 -- test/contracts/init_error.aes | 9 -- test/contracts/local_poly_fail.aes | 7 -- test/contracts/map_of_maps.aes | 36 -------- test/contracts/maps_benchmark.aes | 29 ------- test/contracts/minimal_init.aes | 6 -- test/contracts/multiplication_server.aes | 7 -- test/contracts/oracles_err.aes | 11 --- test/contracts/oracles_gas.aes | 22 ----- test/contracts/oracles_no_vm.aes | 35 -------- test/contracts/polymorphism_test.aes | 16 ---- test/contracts/primitive_map.aes | 57 ------------ test/contracts/remote_gas_test.aes | 20 ----- test/contracts/remote_state.aes | 23 ----- test/contracts/remote_type_check.aes | 22 ----- test/contracts/remote_value_on_err.aes | 21 ----- test/contracts/upfront_charges.aes | 6 -- test/contracts/value_on_err.aes | 7 -- 28 files changed, 646 deletions(-) delete mode 100644 test/contracts/Makefile delete mode 100644 test/contracts/abort_test.aes delete mode 100644 test/contracts/abort_test_int.aes delete mode 100644 test/contracts/channel_env.aes delete mode 100644 test/contracts/channel_on_chain_contract_name_resolution.aes delete mode 100644 test/contracts/channel_on_chain_contract_oracle.aes delete mode 100644 test/contracts/channel_remote_on_chain_contract_name_resolution.aes delete mode 100644 test/contracts/chess.aes delete mode 100644 test/contracts/contract_types.aes delete mode 100644 test/contracts/erc20_token.aes delete mode 100644 test/contracts/exploits.aes delete mode 100644 test/contracts/init_error.aes delete mode 100644 test/contracts/local_poly_fail.aes delete mode 100644 test/contracts/map_of_maps.aes delete mode 100644 test/contracts/maps_benchmark.aes delete mode 100644 test/contracts/minimal_init.aes delete mode 100644 test/contracts/multiplication_server.aes delete mode 100644 test/contracts/oracles_err.aes delete mode 100644 test/contracts/oracles_gas.aes delete mode 100644 test/contracts/oracles_no_vm.aes delete mode 100644 test/contracts/polymorphism_test.aes delete mode 100644 test/contracts/primitive_map.aes delete mode 100644 test/contracts/remote_gas_test.aes delete mode 100644 test/contracts/remote_state.aes delete mode 100644 test/contracts/remote_type_check.aes delete mode 100644 test/contracts/remote_value_on_err.aes delete mode 100644 test/contracts/upfront_charges.aes delete mode 100644 test/contracts/value_on_err.aes diff --git a/test/contracts/Makefile b/test/contracts/Makefile deleted file mode 100644 index 0034194..0000000 --- a/test/contracts/Makefile +++ /dev/null @@ -1,15 +0,0 @@ - -## Requires ocaml >= 4.02, < 4.06 -## and reason-3.0.0 (opam install reason). - -default : voting_test - -%.ml : %.re - refmt -p ml $< > $@ - - -voting_test : rte.ml voting.ml voting_test.ml - ocamlopt -o $@ $^ - -clean : - rm -f *.cmi *.cmx *.ml *.o voting_test diff --git a/test/contracts/abort_test.aes b/test/contracts/abort_test.aes deleted file mode 100644 index 3da5324..0000000 --- a/test/contracts/abort_test.aes +++ /dev/null @@ -1,31 +0,0 @@ -// A simple test of the abort built-in function. - -contract AbortTest = - - record state = { value : int } - - public function init(v : int) = - { value = v } - - // Aborting - public function do_abort(v : int, s : string) : unit = - put_value(v) - revert_abort(s) - - // Accessing the value - public function get_value() = state.value - public function put_value(v : int) = put(state{value = v}) - public function get_values() : list(int) = [state.value] - public function put_values(v : int) = put(state{value = v}) - - // Some basic statistics - public function get_stats(acct : address) = - ( Contract.balance, Chain.balance(acct) ) - - // Abort functions. - private function revert_abort(s : string) = - abort(s) - - // This is still legal but will be stripped out. - // TODO: This function confuses the type inference, so it cannot be present. - //private function abort(s : string) = 42 diff --git a/test/contracts/abort_test_int.aes b/test/contracts/abort_test_int.aes deleted file mode 100644 index ab1e9fe..0000000 --- a/test/contracts/abort_test_int.aes +++ /dev/null @@ -1,27 +0,0 @@ -contract Interface = - function do_abort : (int, string) => unit - function get_value : () => int - function put_value : (int) => unit - function get_values : () => list(int) - function put_values : (int) => unit - -contract AbortTestInt = - - record state = {r : Interface, value : int} - - public function init(r : Interface, value : int) = - {r = r, value = value} - - // Aborting - public function do_abort(v : int, s : string) = - put_value(v) - state.r.do_abort(v + 100, s) - - // Accessing the value - public function put_value(v : int) = put(state{value = v}) - public function get_value() = state.value - public function get_values() : list(int) = - state.value :: state.r.get_values() - public function put_values(v : int) = - put_value(v) - state.r.put_values(v + 1000) diff --git a/test/contracts/channel_env.aes b/test/contracts/channel_env.aes deleted file mode 100644 index e3d5860..0000000 --- a/test/contracts/channel_env.aes +++ /dev/null @@ -1,8 +0,0 @@ -contract ChannelEnv = - public function coinbase() : address = Chain.coinbase - - public function timestamp() : int = Chain.timestamp - - public function block_height() : int = Chain.block_height - - public function difficulty() : int = Chain.difficulty diff --git a/test/contracts/channel_on_chain_contract_name_resolution.aes b/test/contracts/channel_on_chain_contract_name_resolution.aes deleted file mode 100644 index 6171286..0000000 --- a/test/contracts/channel_on_chain_contract_name_resolution.aes +++ /dev/null @@ -1,7 +0,0 @@ -contract ChannelOnChainContractNameResolution = - - public function can_resolve(name: string, key: string) : bool = - switch(AENS.resolve(name, key) : option(string)) - None => false - Some(_address) => true - diff --git a/test/contracts/channel_on_chain_contract_oracle.aes b/test/contracts/channel_on_chain_contract_oracle.aes deleted file mode 100644 index de681aa..0000000 --- a/test/contracts/channel_on_chain_contract_oracle.aes +++ /dev/null @@ -1,51 +0,0 @@ -contract ChannelOnChainContractOracle = - - type query_t = string - type answer_t = string - type oracle_id = oracle(query_t, answer_t) - type query_id = oracle_query(query_t, answer_t) - - record state = { oracle : oracle_id, - question : string, - bets : map(string, address) - } - - - public function init(oracle: oracle_id, question: string) : state = - { oracle = oracle, - question = question, - bets = {} - } - - public stateful function place_bet(answer: string) = - switch(Map.lookup(answer, state.bets)) - None => - put(state{ bets = state.bets{[answer] = Call.caller}}) - "ok" - Some(_value) => - "bet_already_taken" - - public function expiry() = - Oracle.expiry(state.oracle) - - public function query_fee() = - Oracle.query_fee(state.oracle) - - public function get_question(q: query_id) = - Oracle.get_question(state.oracle, q) - - public stateful function resolve(q: query_id) = - switch(Oracle.get_answer(state.oracle, q)) - None => - "no response" - Some(result) => - if(state.question == Oracle.get_question(state.oracle, q)) - switch(Map.lookup(result, state.bets)) - None => - "no winning bet" - Some(winner) => - Chain.spend(winner, Contract.balance) - "ok" - else - "different question" - diff --git a/test/contracts/channel_remote_on_chain_contract_name_resolution.aes b/test/contracts/channel_remote_on_chain_contract_name_resolution.aes deleted file mode 100644 index 8847335..0000000 --- a/test/contracts/channel_remote_on_chain_contract_name_resolution.aes +++ /dev/null @@ -1,9 +0,0 @@ -contract Remote = - function get : () => int - function can_resolve : (string, string) => bool - -contract RemoteCall = - - function remote_resolve(r : Remote, name: string, key: string) : bool = - r.can_resolve(name, key) - diff --git a/test/contracts/chess.aes b/test/contracts/chess.aes deleted file mode 100644 index 571297f..0000000 --- a/test/contracts/chess.aes +++ /dev/null @@ -1,51 +0,0 @@ - -contract Chess = - - type board = map(int, map(int, string)) - type state = board - - private function get_row(r, m : board) = - Map.lookup_default(r, m, {}) - - private function set_piece(r, c, p, m : board) = - m { [r] = get_row(r, m) { [c] = p } } - - private function get_piece(r, c, m : board) = - Map.lookup(c, get_row(r, m)) - - private function from_list(xs, m : board) = - switch(xs) - [] => m - (r, c, p) :: xs => from_list(xs, set_piece(r, c, p, m)) - - function init() = - from_list([ (2, 1, "white pawn"), (7, 1, "black pawn") - , (2, 2, "white pawn"), (7, 2, "black pawn") - , (2, 3, "white pawn"), (7, 3, "black pawn") - , (2, 4, "white pawn"), (7, 4, "black pawn") - , (2, 5, "white pawn"), (7, 5, "black pawn") - , (2, 6, "white pawn"), (7, 6, "black pawn") - , (2, 7, "white pawn"), (7, 7, "black pawn") - , (2, 8, "white pawn"), (7, 8, "black pawn") - , (1, 1, "white rook"), (8, 1, "black rook") - , (1, 2, "white knight"), (8, 2, "black knight") - , (1, 3, "white bishop"), (8, 3, "black bishop") - , (1, 4, "white queen"), (8, 4, "black queen") - , (1, 5, "white king"), (8, 5, "black king") - , (1, 6, "white bishop"), (8, 6, "black bishop") - , (1, 7, "white knight"), (8, 7, "black knight") - , (1, 8, "white rook"), (8, 8, "black rook") - ], {}) - - function piece(r, c) = get_piece(r, c, state) - - function move_piece(r, c, r1, c1) = - switch(piece(r, c)) - Some(p) => put(set_piece(r1, c1, p, state)) - - function destroy_piece(r, c) = - put(state{ [r] = Map.delete(c, get_row(r, state)) }) - - function delete_row(r) = - put(Map.delete(r, state)) - diff --git a/test/contracts/contract_types.aes b/test/contracts/contract_types.aes deleted file mode 100644 index 99ecfca..0000000 --- a/test/contracts/contract_types.aes +++ /dev/null @@ -1,20 +0,0 @@ - -contract OtherContract = - - function multiply : (int, int) => int - -contract ThisContract = - - record state = { server : OtherContract, n : int } - - function init(server : OtherContract) = - { server = server, n = 2 } - - function square() = - put(state{ n @ n = state.server.multiply(value = 100, n, n) }) - - function get_n() = state.n - - function tip_server() = - Chain.spend(state.server.address, Call.value) - diff --git a/test/contracts/erc20_token.aes b/test/contracts/erc20_token.aes deleted file mode 100644 index 517b9f4..0000000 --- a/test/contracts/erc20_token.aes +++ /dev/null @@ -1,87 +0,0 @@ -contract ERC20Token = - record state = { - totalSupply : int, - decimals : int, - name : string, - symbol : string, - balances : map(address, int), - allowed : map(address, map(address,int)), - // Logs, remove when native Events are there - transfer_log : list((address,address,int)), - approval_log : list((address,address,int))} - - // init(100000000, 10, "Token Name", "TKN") - public stateful function init(_totalSupply : int, _decimals : int, _name : string, _symbol : string ) = { - totalSupply = _totalSupply, - decimals = _decimals, - name = _name, - symbol = _symbol, - balances = {[Call.caller] = _totalSupply }, // creator gets all Tokens - allowed = {}, - // Logs, remove when native Events are there - transfer_log = [], - approval_log = []} - - public stateful function totalSupply() : int = state.totalSupply - public stateful function decimals() : int = state.decimals - public stateful function name() : string = state.name - public stateful function symbol() : string = state.symbol - - public stateful function balanceOf(tokenOwner : address ) : int = - Map.lookup_default(tokenOwner, state.balances, 0) - - public stateful function transfer(to : address, tokens : int) = - put( state{balances[Call.caller] = sub(state.balances[Call.caller], tokens) }) - put( state{balances[to] = add(Map.lookup_default(to, state.balances, 0), tokens) }) - transferEvent(Call.caller, to, tokens) - true - - public stateful function approve(spender : address, tokens : int) = - // allowed[Call.caller] field must have a value! - ensure_allowed(Call.caller) - put( state{allowed[Call.caller][spender] = tokens} ) - approvalEvent(Call.caller, spender, tokens) - true - - public stateful function transferFrom(from : address, to : address, tokens : int) = - put( state{ balances[from] = sub(state.balances[from], tokens) }) - put( state{ allowed[from][Call.caller] = sub(state.allowed[from][Call.caller], tokens) }) - put( state{ balances[to] = add(balanceOf(to), tokens) }) - transferEvent(from, to, tokens) - true - - public function allowance(_owner : address, _spender : address) : int = - state.allowed[_owner][_spender] - - public stateful function getTransferLog() : list((address,address,int)) = - state.transfer_log - public stateful function getApprovalLog() : list((address,address,int)) = - state.approval_log - - // - // Private Functions - // - - private function ensure_allowed(key : address) = - switch(Map.lookup(key, state.allowed)) - None => put(state{allowed[key] = {}}) - Some(_) => () - - private function transferEvent(from : address, to : address, tokens : int) = - let e = (from, to, tokens) - put( state{transfer_log = e :: state.transfer_log }) - e - - private function approvalEvent(from : address, to : address, tokens : int) = - let e = (from, to, tokens) - put( state{approval_log = e :: state.approval_log }) - e - - private function sub(_a : int, _b : int) : int = - require(_b =< _a, "Error") - _a - _b - - private function add(_a : int, _b : int) : int = - let c : int = _a + _b - require(c >= _a, "Error") - c diff --git a/test/contracts/exploits.aes b/test/contracts/exploits.aes deleted file mode 100644 index bbc16e1..0000000 --- a/test/contracts/exploits.aes +++ /dev/null @@ -1,6 +0,0 @@ - -contract Exploits = - - // We'll hack the bytecode of this changing the return type to string. - function pair(n : int) = (n, 0) - diff --git a/test/contracts/init_error.aes b/test/contracts/init_error.aes deleted file mode 100644 index 9d81a3a..0000000 --- a/test/contracts/init_error.aes +++ /dev/null @@ -1,9 +0,0 @@ -contract Remote = - function missing : (int) => int - -contract Init_error = - - record state = {value : int} - - function init(r : Remote, x : int) = - {value = r.missing(x)} diff --git a/test/contracts/local_poly_fail.aes b/test/contracts/local_poly_fail.aes deleted file mode 100644 index 189ab23..0000000 --- a/test/contracts/local_poly_fail.aes +++ /dev/null @@ -1,7 +0,0 @@ - -contract Fail = - - entrypoint tttt() : bool * int = - let f(x : 'a) : 'a = x - (f(true), f(1)) - diff --git a/test/contracts/map_of_maps.aes b/test/contracts/map_of_maps.aes deleted file mode 100644 index 49599c1..0000000 --- a/test/contracts/map_of_maps.aes +++ /dev/null @@ -1,36 +0,0 @@ - -contract MapOfMaps = - - type board = map(int, map(int, string)) - type map2('a, 'b, 'c) = map('a, map('b, 'c)) - - record state = { big1 : map2(string, string, string), - big2 : map2(string, string, string), - small1 : map(string, string), - small2 : map(string, string) } - - private function empty_state() = - { big1 = {}, big2 = {}, - small1 = {}, small2 = {} } - - function init() = empty_state() - - function setup_state() = - let small = {["key"] = "val"} - put({ big1 = {["one"] = small}, - big2 = {["two"] = small}, - small1 = small, - small2 = small }) - - // -- Garbage collection of inner map when outer map is garbage collected - function test1_setup() = - let inner = {["key"] = "val"} - put(empty_state() { big1 = {["one"] = inner} }) - - function test1_execute() = - put(state{ big1 = {} }) - - function test1_check() = - state.big1 - - diff --git a/test/contracts/maps_benchmark.aes b/test/contracts/maps_benchmark.aes deleted file mode 100644 index fd8204d..0000000 --- a/test/contracts/maps_benchmark.aes +++ /dev/null @@ -1,29 +0,0 @@ - -contract MapUpdater = - function update_map : (int, string, map(int, string)) => map(int, string) - -contract Benchmark = - - record state = { updater : MapUpdater, - map : map(int, string) } - - function init(u, m) = { updater = u, map = m } - - function set_updater(u) = put(state{ updater = u }) - - function update_map(k : int, v : string, m) = m{ [k] = v } - - function update(a : int, b : int, v : string) = - if (a > b) () - else - put(state{ map[a] = v }) - update(a + 1, b, v) - - function get(k) = state.map[k] - function noop() = () - - function benchmark(k, v) = - let m = state.updater.update_map(k, v, state.map) - put(state{ map = m }) - m - diff --git a/test/contracts/minimal_init.aes b/test/contracts/minimal_init.aes deleted file mode 100644 index 28e618a..0000000 --- a/test/contracts/minimal_init.aes +++ /dev/null @@ -1,6 +0,0 @@ -contract MinimalInit = - - record state = {foo : int} - - function init() = - { foo = 0 } diff --git a/test/contracts/multiplication_server.aes b/test/contracts/multiplication_server.aes deleted file mode 100644 index 859cd44..0000000 --- a/test/contracts/multiplication_server.aes +++ /dev/null @@ -1,7 +0,0 @@ - -contract MultiplicationServer = - - function multiply(x : int, y : int) = - switch(Call.value >= 100) - true => x * y - diff --git a/test/contracts/oracles_err.aes b/test/contracts/oracles_err.aes deleted file mode 100644 index 7a5aa22..0000000 --- a/test/contracts/oracles_err.aes +++ /dev/null @@ -1,11 +0,0 @@ -contract OraclesErr = - - public function unsafeCreateQueryThenErr( - o : oracle(string, int), - q : string, - qfee : int, - qttl : Chain.ttl, - rttl : Chain.ttl) : oracle_query(string, int) = - let x = Oracle.query(o, q, qfee, qttl, rttl) - switch(0) 1 => () - x // Never reached. diff --git a/test/contracts/oracles_gas.aes b/test/contracts/oracles_gas.aes deleted file mode 100644 index 87c8b28..0000000 --- a/test/contracts/oracles_gas.aes +++ /dev/null @@ -1,22 +0,0 @@ -contract OraclesGas = - - type fee = int - type question_t = string - type answer_t = int - - public function happyPathWithAllBuiltinsAtSameHeight( - qfee : fee, - ottl : Chain.ttl, - ettl : Chain.ttl, - qttl : Chain.ttl, - rttl : Chain.ttl - ) = - let question = "why" - let answer = 42 - let o = Oracle.register(Contract.address, qfee, ottl) : oracle(question_t, answer_t) - Oracle.extend(o, ettl) - require(qfee =< Call.value, "insufficient value for qfee") - let q = Oracle.query(o, question, qfee, qttl, rttl) - Oracle.respond(o, q, answer) - () - diff --git a/test/contracts/oracles_no_vm.aes b/test/contracts/oracles_no_vm.aes deleted file mode 100644 index 28d3c3f..0000000 --- a/test/contracts/oracles_no_vm.aes +++ /dev/null @@ -1,35 +0,0 @@ -contract Oracles = - - type fee = int - type ttl = Chain.ttl - - type query_t = string - type answer_t = string - - type oracle_id = oracle(query_t, answer_t) - type query_id = oracle_query(query_t, answer_t) - - function createQuery(o : oracle_id, - q : query_t, - qfee : fee, - qttl : ttl, - rttl : ttl) : query_id = - require(qfee =< Call.value, "insufficient value for qfee") - Oracle.query(o, q, qfee, qttl, rttl) - - - function respond(o : oracle_id, - q : query_id, - sign : signature, - r : answer_t) : unit = - Oracle.respond(o, q, signature = sign, r) - - - function getQuestion(o : oracle_id, - q : query_id) : query_t = - Oracle.get_question(o, q) - - function getAnswer(o : oracle_id, - q : query_id) : option(answer_t) = - Oracle.get_answer(o, q) - diff --git a/test/contracts/polymorphism_test.aes b/test/contracts/polymorphism_test.aes deleted file mode 100644 index a6c4c91..0000000 --- a/test/contracts/polymorphism_test.aes +++ /dev/null @@ -1,16 +0,0 @@ - -contract Identity = - - function zip_with(f, xs, ys) = - switch((xs, ys)) - (x :: xs, y :: ys) => f(x, y) :: zip_with(f, xs, ys) - _ => [] - - // Check that we can use zip_with at different types - - function foo() = - zip_with((x, y) => x + y, [1, 2, 3], [4, 5, 6, 7]) - - function bar() = - zip_with((x, y) => if(x) y else 0, [true, false, true, false], [1, 2, 3]) - diff --git a/test/contracts/primitive_map.aes b/test/contracts/primitive_map.aes deleted file mode 100644 index 73c2e41..0000000 --- a/test/contracts/primitive_map.aes +++ /dev/null @@ -1,57 +0,0 @@ - -contract MapServer = - - function insert : (string, string, map(string, string)) => map(string, string) - function delete : (string, map(string, string)) => map(string, string) - -contract PrimitiveMaps = - - record state = { remote : MapServer, - map : map(string, string), - map2 : map(string, string) } - - function init(r) = - let m = {} - { remote = r, map = m, map2 = m } - - function set_remote(r) = put(state{ remote = r }) - - function insert(k, v, m) : map(string, string) = m{ [k] = v } - function delete(k, m) : map(string, string) = Map.delete(k, m) - - function remote_insert(k, v, m) = - state.remote.insert(k, v, m) - - function remote_delete(k, m) = - state.remote.delete(k, m) - - function get_state_map() = state.map - function set_state_map(m) = put(state{ map = m }) - - function clone_state() = put(state{ map2 = state.map }) - - function insert_state(k, v) = put(state{ map @ m = m { [k] = v } }) - function delete_state(k) = put(state{ map @ m = Map.delete(k, m) }) - function lookup_state(k) = Map.lookup(k, state.map) - - function double_insert_state(k, v1, v2) = - put(state{ map @ m = m { [k] = v1 }, - map2 @ m = m { [k] = v2 } }) - - function test() = - let m = {} : map(string, string) - let m1 = m { ["foo"] = "value_of_foo", - ["bla"] = "value_of_bla" } - let m2 = Map.delete("foo", m1) - let m3 = m2 { ["bla"] = "new_value_of_bla" } - [Map.lookup("foo", m), Map.lookup("bla", m), - Map.lookup("foo", m1), Map.lookup("bla", m1), - Map.lookup("foo", m2), Map.lookup("bla", m2), - Map.lookup("foo", m3), Map.lookup("bla", m3)] - - function return_map() = - Map.delete("goo", {["foo"] = "bar", ["goo"] = "gaa"}) - - function argument_map(m : map(string, string)) = - m["foo"] - diff --git a/test/contracts/remote_gas_test.aes b/test/contracts/remote_gas_test.aes deleted file mode 100644 index ee88cf2..0000000 --- a/test/contracts/remote_gas_test.aes +++ /dev/null @@ -1,20 +0,0 @@ -contract Remote1 = - function set : (int) => int - -contract RemoteCall = - record state = { i : int } - - function init(x) = { i = x } - - function set( x : int) : int = - let old = state.i - put(state{ i = x }) - old - - function call(r : Remote1, x : int, g : int) : int = - r.set(gas = g, value = 10, x) - - function get() = state.i - - - diff --git a/test/contracts/remote_state.aes b/test/contracts/remote_state.aes deleted file mode 100644 index c9bfff3..0000000 --- a/test/contracts/remote_state.aes +++ /dev/null @@ -1,23 +0,0 @@ -contract RemoteState = - record rstate = { i : int, s : string, m : map(int, int) } - - function look_at(s : rstate) = () - function return_s(big : bool) = - let x = "short" - let y = "______longer_string_at_least_32_bytes_long___________longer_string_at_least_32_bytes_long___________longer_string_at_least_32_bytes_long_____" - if(big) y else x - function return_m(big : bool) = - let x = { [1] = 2 } - let y = { [1] = 2, [3] = 4, [5] = 6 } - if(big) y else x - - function get(s : rstate) = s - function get_i(s : rstate) = s.i - function get_s(s : rstate) = s.s - function get_m(s : rstate) = s.m - - function fun_update_i(s : rstate, ni) = s{ i = ni } - function fun_update_s(s : rstate, ns) = s{ s = ns } - function fun_update_m(s : rstate, nm) = s{ m = nm } - function fun_update_mk(s : rstate, k, v) = s{ m = s.m{[k] = v} } - diff --git a/test/contracts/remote_type_check.aes b/test/contracts/remote_type_check.aes deleted file mode 100644 index ed62fe9..0000000 --- a/test/contracts/remote_type_check.aes +++ /dev/null @@ -1,22 +0,0 @@ -contract Remote = - function id : ('a) => 'a - function missing : ('a) => 'a - function wrong_type : (string) => string - -contract Main = - - function id(x : int) = - x - - function wrong_type(x : int) = - x - - function remote_id(r : Remote, x) = - r.id(x) - - function remote_missing(r : Remote, x) = - r.missing(x) - - function remote_wrong_type(r : Remote, x) = - r.wrong_type(x) - diff --git a/test/contracts/remote_value_on_err.aes b/test/contracts/remote_value_on_err.aes deleted file mode 100644 index 4a5de6a..0000000 --- a/test/contracts/remote_value_on_err.aes +++ /dev/null @@ -1,21 +0,0 @@ -contract ValueOnErr = - function err : () => int - function ok : () => int - -contract RemoteValueOnErr = - - public function callErr( - r : ValueOnErr, - value : int) : int = - r.err(value = value) - - public function callErrLimitGas( - r : ValueOnErr, - value : int, - gas : int) : int = - r.err(value = value, gas = gas) - - public function callOk( - r : ValueOnErr, - value : int) : int = - r.ok(value = value) diff --git a/test/contracts/upfront_charges.aes b/test/contracts/upfront_charges.aes deleted file mode 100644 index 74041d0..0000000 --- a/test/contracts/upfront_charges.aes +++ /dev/null @@ -1,6 +0,0 @@ -contract UpfrontCharges = - record state = { b : int } // For enabling retrieval of sender balance observed inside init. - public function init() : state = { b = b() } - public function initialSenderBalance() : int = state.b - public function senderBalance() : int = b() - private function b() = Chain.balance(Call.origin) diff --git a/test/contracts/value_on_err.aes b/test/contracts/value_on_err.aes deleted file mode 100644 index 43cbb93..0000000 --- a/test/contracts/value_on_err.aes +++ /dev/null @@ -1,7 +0,0 @@ -contract ValueOnErr = - - public function err() : int = - switch(0) 1 => 5 - - public function ok() : int = - 11