diff --git a/src/eval/EvalUtil.ml b/src/eval/EvalUtil.ml index 96a136a0a..724658533 100644 --- a/src/eval/EvalUtil.ml +++ b/src/eval/EvalUtil.ml @@ -341,8 +341,13 @@ module Configuration = struct let incoming' = st.incoming_funds in match sender_balance_l with | UintLit (Uint128L sender_balance) -> - if Uint128.compare incoming' sender_balance >= 0 then - fail0 "Insufficient sender balance for acceptance." + if Uint128.compare incoming' sender_balance > 0 then + fail0 + ("Insufficient sender balance for acceptance. Incoming vs \ + sender_balance: " + ^ Uint128.to_string incoming' + ^ " vs " + ^ Uint128.to_string sender_balance) else if (* Although unsigned integer is used, and this check isn't * necessary, we have it just in case, somehow a malformed diff --git a/tests/contracts/addfunds.scilla b/tests/contracts/addfunds.scilla new file mode 100644 index 000000000..059bd3f16 --- /dev/null +++ b/tests/contracts/addfunds.scilla @@ -0,0 +1,11 @@ +scilla_version 0 + +library SimpleImpl + +contract SimpleImpl() + +transition AddFunds(initiator: ByStr20) + accept; + e = { _eventname : "Funds deposit "; funder : initiator }; + event e +end \ No newline at end of file diff --git a/tests/contracts/addfunds_proxy.scilla b/tests/contracts/addfunds_proxy.scilla new file mode 100644 index 000000000..783420427 --- /dev/null +++ b/tests/contracts/addfunds_proxy.scilla @@ -0,0 +1,28 @@ +scilla_version 0 + +library SimpleProxy + +let one_msg = + fun (m: Message) => + let e = Nil {Message} in + Cons {Message} m e + +contract SimpleProxy( + init_implementation: ByStr20 +) + +field implementation: ByStr20 = init_implementation + +transition AddFunds() + current_impl <- implementation; + accept; + msg = {_tag: "AddFunds"; _recipient: current_impl; _amount: _amount; initiator: _sender}; + msgs = one_msg msg; + send msgs +end + +transition SelfAddFunds() + accept; + e = { _eventname : "Self Add Funds deposit "; funder : _sender; amount: _amount }; + event e +end \ No newline at end of file diff --git a/tests/runner/Testcontracts.ml b/tests/runner/Testcontracts.ml index 2ae2dfb08..f2561a81e 100644 --- a/tests/runner/Testcontracts.ml +++ b/tests/runner/Testcontracts.ml @@ -463,6 +463,19 @@ let contract_tests env = "polymorphic_address" >::: build_contract_tests ~pplit:false env "address_list_traversal" succ_code 1 2 []; + "addfunds_proxy" + >::: build_contract_tests env "addfunds_proxy" succ_code 1 2 []; + "addfunds" + >::: build_contract_tests env "addfunds" succ_code 1 1 []; + "chain-call-balance-1" + >::: build_contract_tests env "chain-call-balance-1" succ_code 1 + 1 []; + "chain-call-balance-2" + >::: build_contract_tests env "chain-call-balance-2" succ_code 1 + 1 []; + "chain-call-balance-3" + >::: build_contract_tests env "chain-call-balance-3" succ_code 1 + 1 []; ]; "these_tests_must_FAIL" >::: [ diff --git a/tests/runner/addfunds/blockchain_1.json b/tests/runner/addfunds/blockchain_1.json new file mode 100644 index 000000000..9c3af9b93 --- /dev/null +++ b/tests/runner/addfunds/blockchain_1.json @@ -0,0 +1 @@ +[ { "vname": "BLOCKNUMBER", "type": "BNum", "value": "100" } ] \ No newline at end of file diff --git a/tests/runner/addfunds/init.json b/tests/runner/addfunds/init.json new file mode 100644 index 000000000..eaae7b188 --- /dev/null +++ b/tests/runner/addfunds/init.json @@ -0,0 +1,17 @@ +[ + { + "vname" : "_scilla_version", + "type" : "Uint32", + "value" : "0" + }, + { + "vname" : "_this_address", + "type" : "ByStr20", + "value" : "0xabfeccdc9012345678901234567890f777567890" + }, + { + "vname" : "_creation_block", + "type" : "BNum", + "value" : "1" + } +] diff --git a/tests/runner/addfunds/message_1.json b/tests/runner/addfunds/message_1.json new file mode 100644 index 000000000..a7a4f4e3d --- /dev/null +++ b/tests/runner/addfunds/message_1.json @@ -0,0 +1,13 @@ +{ + "_tag": "AddFunds", + "_amount": "100", + "_sender": "0x12345678901234567890123456789012345678ab", + "params": [ + { + "vname" : "initiator", + "type" : "ByStr20", + "value" : "0x52345678901234567890123456789012345678ab" + } + ], + "_origin": "0x12345678901234567890123456789012345678ab" +} diff --git a/tests/runner/addfunds/output_1.json b/tests/runner/addfunds/output_1.json new file mode 100644 index 000000000..74f931c16 --- /dev/null +++ b/tests/runner/addfunds/output_1.json @@ -0,0 +1,19 @@ +{ + "scilla_major_version": "0", + "gas_remaining": "7944", + "_accepted": "true", + "messages": [], + "states": [ { "vname": "_balance", "type": "Uint128", "value": "100" } ], + "events": [ + { + "_eventname": "Funds deposit ", + "params": [ + { + "vname": "funder", + "type": "ByStr20", + "value": "0x52345678901234567890123456789012345678ab" + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/runner/addfunds/state_1.json b/tests/runner/addfunds/state_1.json new file mode 100644 index 000000000..6efc2d4a1 --- /dev/null +++ b/tests/runner/addfunds/state_1.json @@ -0,0 +1,19 @@ +[ + { + "vname": "_balance", + "type": "Uint128", + "value": "0" + }, + { + "vname": "_external", + "type": "Unit", + "value": [ + { + "address": "0x12345678901234567890123456789012345678ab", + "state": [ + { "vname": "_balance", "type": "Uint128", "value": "142" } + ] + } + ] + } +] diff --git a/tests/runner/addfunds_proxy/blockchain_1.json b/tests/runner/addfunds_proxy/blockchain_1.json new file mode 100644 index 000000000..9c3af9b93 --- /dev/null +++ b/tests/runner/addfunds_proxy/blockchain_1.json @@ -0,0 +1 @@ +[ { "vname": "BLOCKNUMBER", "type": "BNum", "value": "100" } ] \ No newline at end of file diff --git a/tests/runner/addfunds_proxy/blockchain_2.json b/tests/runner/addfunds_proxy/blockchain_2.json new file mode 100644 index 000000000..9c3af9b93 --- /dev/null +++ b/tests/runner/addfunds_proxy/blockchain_2.json @@ -0,0 +1 @@ +[ { "vname": "BLOCKNUMBER", "type": "BNum", "value": "100" } ] \ No newline at end of file diff --git a/tests/runner/addfunds_proxy/init.json b/tests/runner/addfunds_proxy/init.json new file mode 100644 index 000000000..541513f09 --- /dev/null +++ b/tests/runner/addfunds_proxy/init.json @@ -0,0 +1,22 @@ +[ + { + "vname" : "_scilla_version", + "type" : "Uint32", + "value" : "0" + }, + { + "vname" : "_this_address", + "type" : "ByStr20", + "value" : "0xabfeccdc9012345678901234567890f777567890" + }, + { + "vname" : "_creation_block", + "type" : "BNum", + "value" : "1" + }, + { + "vname": "init_implementation", + "type": "ByStr20", + "value": "0xff345678901234567890123456789012345678ab" + } +] diff --git a/tests/runner/addfunds_proxy/message_1.json b/tests/runner/addfunds_proxy/message_1.json new file mode 100644 index 000000000..9cbb8d3c4 --- /dev/null +++ b/tests/runner/addfunds_proxy/message_1.json @@ -0,0 +1,7 @@ +{ + "_tag": "AddFunds", + "_amount": "100", + "_sender": "0x12345678901234567890123456789012345678ab", + "params": [], + "_origin": "0x12345678901234567890123456789012345678ab" +} diff --git a/tests/runner/addfunds_proxy/message_2.json b/tests/runner/addfunds_proxy/message_2.json new file mode 100644 index 000000000..c424e4c2b --- /dev/null +++ b/tests/runner/addfunds_proxy/message_2.json @@ -0,0 +1,7 @@ +{ + "_tag": "SelfAddFunds", + "_amount": "100", + "_sender": "0x12345678901234567890123456789012345678ab", + "params": [], + "_origin": "0x12345678901234567890123456789012345678ab" +} diff --git a/tests/runner/addfunds_proxy/output_1.json b/tests/runner/addfunds_proxy/output_1.json new file mode 100644 index 000000000..3eed58bca --- /dev/null +++ b/tests/runner/addfunds_proxy/output_1.json @@ -0,0 +1,28 @@ +{ + "scilla_major_version": "0", + "gas_remaining": "7951", + "_accepted": "true", + "messages": [ + { + "_tag": "AddFunds", + "_amount": "100", + "_recipient": "0xff345678901234567890123456789012345678ab", + "params": [ + { + "vname": "initiator", + "type": "ByStr20", + "value": "0x12345678901234567890123456789012345678ab" + } + ] + } + ], + "states": [ + { "vname": "_balance", "type": "Uint128", "value": "0" }, + { + "vname": "implementation", + "type": "ByStr20", + "value": "0xff345678901234567890123456789012345678ab" + } + ], + "events": [] +} \ No newline at end of file diff --git a/tests/runner/addfunds_proxy/output_2.json b/tests/runner/addfunds_proxy/output_2.json new file mode 100644 index 000000000..1f7e3e90e --- /dev/null +++ b/tests/runner/addfunds_proxy/output_2.json @@ -0,0 +1,27 @@ +{ + "scilla_major_version": "0", + "gas_remaining": "7958", + "_accepted": "true", + "messages": [], + "states": [ + { "vname": "_balance", "type": "Uint128", "value": "100" }, + { + "vname": "implementation", + "type": "ByStr20", + "value": "0xff345678901234567890123456789012345678ab" + } + ], + "events": [ + { + "_eventname": "Self Add Funds deposit ", + "params": [ + { + "vname": "funder", + "type": "ByStr20", + "value": "0x12345678901234567890123456789012345678ab" + }, + { "vname": "amount", "type": "Uint128", "value": "100" } + ] + } + ] +} \ No newline at end of file diff --git a/tests/runner/addfunds_proxy/state_1.json b/tests/runner/addfunds_proxy/state_1.json new file mode 100644 index 000000000..dd1bfd858 --- /dev/null +++ b/tests/runner/addfunds_proxy/state_1.json @@ -0,0 +1,24 @@ +[ + { + "vname": "_balance", + "type": "Uint128", + "value": "0" + }, + { + "vname": "implementation", + "type": "ByStr20", + "value": "0xff345678901234567890123456789012345678ab" + }, + { + "vname": "_external", + "type": "Unit", + "value": [ + { + "address": "0x12345678901234567890123456789012345678ab", + "state": [ + { "vname": "_balance", "type": "Uint128", "value": "142" } + ] + } + ] + } +] diff --git a/tests/runner/addfunds_proxy/state_2.json b/tests/runner/addfunds_proxy/state_2.json new file mode 100644 index 000000000..dd1bfd858 --- /dev/null +++ b/tests/runner/addfunds_proxy/state_2.json @@ -0,0 +1,24 @@ +[ + { + "vname": "_balance", + "type": "Uint128", + "value": "0" + }, + { + "vname": "implementation", + "type": "ByStr20", + "value": "0xff345678901234567890123456789012345678ab" + }, + { + "vname": "_external", + "type": "Unit", + "value": [ + { + "address": "0x12345678901234567890123456789012345678ab", + "state": [ + { "vname": "_balance", "type": "Uint128", "value": "142" } + ] + } + ] + } +] diff --git a/tests/runner/chain-call-balance-1/output_1.json b/tests/runner/chain-call-balance-1/output_1.json new file mode 100644 index 000000000..8da391f92 --- /dev/null +++ b/tests/runner/chain-call-balance-1/output_1.json @@ -0,0 +1,21 @@ +{ + "scilla_major_version": "0", + "gas_remaining": "7915", + "_accepted": "true", + "messages": [ + { + "_tag": "b_accept_callC", + "_amount": "50", + "_recipient": "0x22345678901234567890123456789012345678ab", + "params": [ + { + "vname": "addrC", + "type": "ByStr20", + "value": "0x32345678901234567890123456789012345678ab" + } + ] + } + ], + "states": [ { "vname": "_balance", "type": "Uint128", "value": "100" } ], + "events": [] +} \ No newline at end of file diff --git a/tests/runner/chain-call-balance-1/state_1.json b/tests/runner/chain-call-balance-1/state_1.json index 3cb59b6a2..bc1954bba 100644 --- a/tests/runner/chain-call-balance-1/state_1.json +++ b/tests/runner/chain-call-balance-1/state_1.json @@ -1,3 +1,23 @@ [ - { "vname": "_balance", "type": "Uint128", "value": "100" } + { + "vname": "_balance", + "type": "Uint128", + "value": "100" + }, + { + "vname": "_external", + "type": "Unit", + "value": [ + { + "address": "0x02345678901234567890123456789012345678ab", + "state": [ + { + "vname": "_balance", + "type": "Uint128", + "value": "100" + } + ] + } + ] + } ] diff --git a/tests/runner/chain-call-balance-2/output_1.json b/tests/runner/chain-call-balance-2/output_1.json new file mode 100644 index 000000000..cffa10471 --- /dev/null +++ b/tests/runner/chain-call-balance-2/output_1.json @@ -0,0 +1,15 @@ +{ + "scilla_major_version": "0", + "gas_remaining": "7939", + "_accepted": "true", + "messages": [ + { + "_tag": "c_noaccept", + "_amount": "50", + "_recipient": "0x32345678901234567890123456789012345678ab", + "params": [] + } + ], + "states": [ { "vname": "_balance", "type": "Uint128", "value": "100" } ], + "events": [] +} \ No newline at end of file diff --git a/tests/runner/chain-call-balance-2/state_1.json b/tests/runner/chain-call-balance-2/state_1.json index 3cb59b6a2..a01821b6a 100644 --- a/tests/runner/chain-call-balance-2/state_1.json +++ b/tests/runner/chain-call-balance-2/state_1.json @@ -1,3 +1,23 @@ [ - { "vname": "_balance", "type": "Uint128", "value": "100" } + { + "vname": "_balance", + "type": "Uint128", + "value": "100" + }, + { + "vname": "_external", + "type": "Unit", + "value": [ + { + "address": "0x12345678901234567890123456789012345678ab", + "state": [ + { + "vname": "_balance", + "type": "Uint128", + "value": "100" + } + ] + } + ] + } ] diff --git a/tests/runner/chain-call-balance-3/output_1.json b/tests/runner/chain-call-balance-3/output_1.json new file mode 100644 index 000000000..9a36ba0ce --- /dev/null +++ b/tests/runner/chain-call-balance-3/output_1.json @@ -0,0 +1,15 @@ +{ + "scilla_major_version": "0", + "gas_remaining": "7959", + "_accepted": "false", + "messages": [ + { + "_tag": "", + "_amount": "0", + "_recipient": "0xabfeccdc9012345678901234567890f777567890", + "params": [] + } + ], + "states": [ { "vname": "_balance", "type": "Uint128", "value": "100" } ], + "events": [] +} \ No newline at end of file diff --git a/tests/runner/chain-call-balance-3/state_1.json b/tests/runner/chain-call-balance-3/state_1.json index 3cb59b6a2..bc1954bba 100644 --- a/tests/runner/chain-call-balance-3/state_1.json +++ b/tests/runner/chain-call-balance-3/state_1.json @@ -1,3 +1,23 @@ [ - { "vname": "_balance", "type": "Uint128", "value": "100" } + { + "vname": "_balance", + "type": "Uint128", + "value": "100" + }, + { + "vname": "_external", + "type": "Unit", + "value": [ + { + "address": "0x02345678901234567890123456789012345678ab", + "state": [ + { + "vname": "_balance", + "type": "Uint128", + "value": "100" + } + ] + } + ] + } ] diff --git a/tests/runner/remote_state_reads/output_127.json b/tests/runner/remote_state_reads/output_127.json index 069377e6e..ca600122e 100644 --- a/tests/runner/remote_state_reads/output_127.json +++ b/tests/runner/remote_state_reads/output_127.json @@ -2,7 +2,8 @@ "gas_remaining": "7966", "errors": [ { - "error_message": "Insufficient sender balance for acceptance.", + "error_message": + "Insufficient sender balance for acceptance. Incoming vs sender_balance: 100 vs 50", "start_location": { "file": "", "line": 0, "column": 0 }, "end_location": { "file": "", "line": 0, "column": 0 } }