@@ -21,7 +21,7 @@ struct call_evm_tester : basic_evm_tester {
2121 address public lastcaller;
2222
2323 function test(uint256 input) public {
24- require(input != 0);
24+ require(input != 0, "solidity:input can't be zero" );
2525
2626 count += input;
2727 lastcaller = msg.sender;
@@ -56,7 +56,7 @@ struct call_evm_tester : basic_evm_tester {
5656 const intx::uint256 gas_fee_notpayable_version1 = suggested_gas_price * (21274 );
5757
5858 const std::string contract_bytecode =
59- "608060405234801561001057600080fd5b5061030f806100206000396000f3fe60806040526004361061004a5760003560e01c806306661abd1461004f57806329e99f071461007a578063a1a7d817146100a3578063d097e7a6146100ad578063d79e1b6a146100d8575b600080fd5b34801561005b57600080fd5b506100646100ef565b60405161007191906101a1565b60405180910390f35b34801561008657600080fd5b506100a1600480360381019061009c91906101ed565b6100f5565b005b6100ab61015e565b005b3480156100b957600080fd5b506100c2610160565b6040516100cf919061025b565b60405180910390f35b3480156100e457600080fd5b506100ed610186565b005b60005481565b6000810361010257600080fd5b8060008082825461011391906102a5565b9250508190555033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b565b6000819050919050565b61019b81610188565b82525050565b60006020820190506101b66000830184610192565b92915050565b600080fd5b6101ca81610188565b81146101d557600080fd5b50565b6000813590506101e7816101c1565b92915050565b600060208284031215610203576102026101bc565b5b6000610211848285016101d8565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006102458261021a565b9050919050565b6102558161023a565b82525050565b6000602082019050610270600083018461024c565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006102b082610188565b91506102bb83610188565b92508282019050808211156102d3576102d2610276565b5b9291505056fea2646970667358221220ed95d8f74110a8eb6307b7ae52b8623fd3e959169b208830a960c99a9ba1dbf564736f6c63430008120033";
59+ "608060405234801561001057600080fd5b506103c2806100206000396000f3fe60806040526004361061004a5760003560e01c806306661abd1461004f57806329e99f071461007a578063a1a7d817146100a3578063d097e7a6146100ad578063d79e1b6a146100d8575b600080fd5b34801561005b57600080fd5b506100646100ef565b60405161007191906101d7565b60405180910390f35b34801561008657600080fd5b506100a1600480360381019061009c9190610223565b6100f5565b005b6100ab610194565b005b3480156100b957600080fd5b506100c2610196565b6040516100cf9190610291565b60405180910390f35b3480156100e457600080fd5b506100ed6101bc565b005b60005481565b60008103610138576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161012f90610309565b60405180910390fd5b806000808282546101499190610358565b9250508190555033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b565b6000819050919050565b6101d1816101be565b82525050565b60006020820190506101ec60008301846101c8565b92915050565b600080fd5b610200816101be565b811461020b57600080fd5b50565b60008135905061021d816101f7565b92915050565b600060208284031215610239576102386101f2565b5b60006102478482850161020e565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061027b82610250565b9050919050565b61028b81610270565b82525050565b60006020820190506102a66000830184610282565b92915050565b600082825260208201905092915050565b7f736f6c69646974793a696e7075742063616e2774206265207a65726f00000000600082015250565b60006102f3601c836102ac565b91506102fe826102bd565b602082019050919050565b60006020820190508181036000830152610322816102e6565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610363826101be565b915061036e836101be565b925082820190508082111561038657610385610329565b5b9291505056fea264697066735822122072b253e04d7675d9751c68c632df2c04d32dcce47beddcdd35fa75e485afe2fa64736f6c63430008120033";
6060
6161 call_evm_tester () {
6262 create_accounts ({" alice" _n});
@@ -71,7 +71,7 @@ struct call_evm_tester : basic_evm_tester {
7171 return deploy_contract (eoa, evmc::from_hex (contract_bytecode).value ());
7272 }
7373
74- void call_test (const evmc::address& contract_addr, uint64_t amount, name eos, name actor) {
74+ void call_test (const evmc::address& contract_addr, uint64_t amount, name eos, name actor, uint64_t gaslimit = 500000 ) {
7575
7676 auto to = evmc::bytes{std::begin (contract_addr.bytes ), std::end (contract_addr.bytes )};
7777
@@ -82,7 +82,7 @@ struct call_evm_tester : basic_evm_tester {
8282 evmc::bytes32 v;
8383 intx::be::store (v.bytes , intx::uint256 (0 ));
8484
85- call (eos, to, silkworm::Bytes (v), data, 500000 , actor);
85+ call (eos, to, silkworm::Bytes (v), data, gaslimit , actor);
8686 }
8787
8888 void call_testpay (const evmc::address& contract_addr, uint128_t amount, name eos, name actor) {
@@ -282,7 +282,11 @@ BOOST_FIXTURE_TEST_CASE(call_test_function, call_evm_tester) try {
282282 auto evm_account_balance = intx::uint256 (vault_balance (evm_account_name));
283283
284284 BOOST_REQUIRE_EXCEPTION (call_test (token_addr, 0 , " alice" _n, " alice" _n),
285- eosio_assert_message_exception, eosio_assert_message_is (" tx executed inline by contract must succeed" ));
285+ eosio_assert_message_exception, eosio_assert_message_is (" inline evm tx failed, evmc_status_code:2, data:[100]08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001c736f6c69646974793a696e7075742063616e2774206265207a65726f00000000" ));
286+
287+ // call run out of gas, EVMC_OUT_OF_GAS = 3, (gas limit > intrinsic gas)
288+ BOOST_REQUIRE_EXCEPTION (call_test (token_addr, 0 , " alice" _n, " alice" _n, 21200 ),
289+ eosio_assert_message_exception, eosio_assert_message_is (" inline evm tx failed, evmc_status_code:3, data:[0]" ));
286290
287291 BOOST_REQUIRE (intx::uint256 (vault_balance (" alice" _n)) == alice_balance);
288292 BOOST_REQUIRE (intx::uint256 (vault_balance (evm_account_name)) == evm_account_balance);
@@ -316,9 +320,8 @@ BOOST_FIXTURE_TEST_CASE(call_test_function, call_evm_tester) try {
316320 auto caller = get_lastcaller (token_addr);
317321 BOOST_REQUIRE (caller == make_reserved_address (" alice" _n.to_uint64_t ()));
318322
319-
320323 BOOST_REQUIRE_EXCEPTION (call_notpayable (token_addr, 100 , " alice" _n, " alice" _n),
321- eosio_assert_message_exception, eosio_assert_message_is (" tx executed inline by contract must succeed " ));
324+ eosio_assert_message_exception, eosio_assert_message_is (" inline evm tx failed, evmc_status_code:2, data:[0] " ));
322325
323326 BOOST_REQUIRE (intx::uint256 (vault_balance (" alice" _n)) == alice_balance);
324327 BOOST_REQUIRE (intx::uint256 (vault_balance (evm_account_name)) == evm_account_balance);
@@ -418,9 +421,10 @@ BOOST_FIXTURE_TEST_CASE(admincall_test_function, call_evm_tester) try {
418421 BOOST_REQUIRE (evm_balance (evm2) == evm2_balance);
419422 auto evm_account_balance = intx::uint256 (vault_balance (evm_account_name));
420423
421- BOOST_REQUIRE_EXCEPTION (admincall_test (token_addr, 0 , evm2, evm_account_name),
422- eosio_assert_message_exception, eosio_assert_message_is (" tx executed inline by contract must succeed" ));
423-
424+ try {
425+ BOOST_REQUIRE_EXCEPTION (admincall_test (token_addr, 0 , evm2, evm_account_name),
426+ eosio_assert_message_exception, eosio_assert_message_is (" inline evm tx failed, evmc_status_code:2, data:[100]08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001c736f6c69646974793a696e7075742063616e2774206265207a65726f00000000" ));
427+ } FC_LOG_AND_RETHROW ()
424428
425429 // Call and check results
426430 admincall_test (token_addr, 1234 , evm2, evm_account_name);
@@ -451,8 +455,10 @@ BOOST_FIXTURE_TEST_CASE(admincall_test_function, call_evm_tester) try {
451455 auto caller = get_lastcaller (token_addr);
452456 BOOST_REQUIRE (caller== evm2.address );
453457
454- BOOST_REQUIRE_EXCEPTION (admincall_notpayable (token_addr, 100 , evm2, evm_account_name),
455- eosio_assert_message_exception, eosio_assert_message_is (" tx executed inline by contract must succeed" ));
458+ try {
459+ BOOST_REQUIRE_EXCEPTION (admincall_notpayable (token_addr, 100 , evm2, evm_account_name),
460+ eosio_assert_message_exception, eosio_assert_message_is (" inline evm tx failed, evmc_status_code:2, data:[0]" ));
461+ } FC_LOG_AND_RETHROW ()
456462
457463 BOOST_REQUIRE (evm_balance (evm2)== evm2_balance);
458464 BOOST_REQUIRE (intx::uint256 (vault_balance (evm_account_name)) == evm_account_balance);
@@ -642,7 +648,7 @@ BOOST_FIXTURE_TEST_CASE(call_test_function_version_1, call_evm_tester) try {
642648 auto evm_account_balance = intx::uint256 (vault_balance (evm_account_name));
643649
644650 BOOST_REQUIRE_EXCEPTION (call_test (token_addr, 0 , " alice" _n, " alice" _n),
645- eosio_assert_message_exception, eosio_assert_message_is (" tx executed inline by contract must succeed " ));
651+ eosio_assert_message_exception, eosio_assert_message_is (" inline evm tx failed, evmc_status_code:2, data:[100]08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001c736f6c69646974793a696e7075742063616e2774206265207a65726f00000000 " ));
646652
647653 BOOST_REQUIRE (intx::uint256 (vault_balance (" alice" _n)) == alice_balance);
648654 BOOST_REQUIRE (intx::uint256 (vault_balance (evm_account_name)) == evm_account_balance);
@@ -685,7 +691,7 @@ BOOST_FIXTURE_TEST_CASE(call_test_function_version_1, call_evm_tester) try {
685691
686692
687693 BOOST_REQUIRE_EXCEPTION (call_notpayable (token_addr, 100 , " alice" _n, " alice" _n),
688- eosio_assert_message_exception, eosio_assert_message_is (" tx executed inline by contract must succeed " ));
694+ eosio_assert_message_exception, eosio_assert_message_is (" inline evm tx failed, evmc_status_code:2, data:[0] " ));
689695
690696 BOOST_REQUIRE (intx::uint256 (vault_balance (" alice" _n)) == alice_balance);
691697 BOOST_REQUIRE (intx::uint256 (vault_balance (evm_account_name)) == evm_account_balance);
@@ -785,7 +791,7 @@ BOOST_FIXTURE_TEST_CASE(call_other_payer_actually_same_function, call_evm_tester
785791 auto evm_account_balance = intx::uint256 (vault_balance (evm_account_name));
786792
787793 BOOST_REQUIRE_EXCEPTION (callotherpay_test (token_addr, 0 , " alice" _n, " alice" _n, " alice" _n),
788- eosio_assert_message_exception, eosio_assert_message_is (" tx executed inline by contract must succeed " ));
794+ eosio_assert_message_exception, eosio_assert_message_is (" inline evm tx failed, evmc_status_code:2, data:[100]08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001c736f6c69646974793a696e7075742063616e2774206265207a65726f00000000 " ));
789795
790796 BOOST_REQUIRE (intx::uint256 (vault_balance (" alice" _n)) == alice_balance);
791797 BOOST_REQUIRE (intx::uint256 (vault_balance (evm_account_name)) == evm_account_balance);
@@ -826,7 +832,7 @@ BOOST_FIXTURE_TEST_CASE(call_other_payer_actually_same_function, call_evm_tester
826832
827833
828834 BOOST_REQUIRE_EXCEPTION (callotherpay_notpayable (token_addr, 100 , " alice" _n, " alice" _n, " alice" _n),
829- eosio_assert_message_exception, eosio_assert_message_is (" tx executed inline by contract must succeed " ));
835+ eosio_assert_message_exception, eosio_assert_message_is (" inline evm tx failed, evmc_status_code:2, data:[0] " ));
830836
831837 BOOST_REQUIRE (intx::uint256 (vault_balance (" alice" _n)) == alice_balance);
832838 BOOST_REQUIRE (intx::uint256 (vault_balance (evm_account_name)) == evm_account_balance);
@@ -940,7 +946,7 @@ BOOST_FIXTURE_TEST_CASE(call_other_payer_function, call_evm_tester) try {
940946 auto evm_account_balance = intx::uint256 (vault_balance (evm_account_name));
941947
942948 BOOST_REQUIRE_EXCEPTION (callotherpay_test (token_addr, 0 , " alice" _n, " alice" _n, " bob" _n),
943- eosio_assert_message_exception, eosio_assert_message_is (" tx executed inline by contract must succeed " ));
949+ eosio_assert_message_exception, eosio_assert_message_is (" inline evm tx failed, evmc_status_code:2, data:[100]08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001c736f6c69646974793a696e7075742063616e2774206265207a65726f00000000 " ));
944950
945951 BOOST_REQUIRE (intx::uint256 (vault_balance (" alice" _n)) == alice_balance);
946952 BOOST_REQUIRE (intx::uint256 (vault_balance (evm_account_name)) == evm_account_balance);
@@ -989,7 +995,7 @@ BOOST_FIXTURE_TEST_CASE(call_other_payer_function, call_evm_tester) try {
989995 alice_balance = 100_ether;
990996
991997 BOOST_REQUIRE_EXCEPTION (callotherpay_notpayable (token_addr, 100 , " alice" _n, " alice" _n, " bob" _n),
992- eosio_assert_message_exception, eosio_assert_message_is (" tx executed inline by contract must succeed " ));
998+ eosio_assert_message_exception, eosio_assert_message_is (" inline evm tx failed, evmc_status_code:2, data:[0] " ));
993999
9941000 BOOST_REQUIRE (intx::uint256 (vault_balance (" alice" _n)) == alice_balance);
9951001 BOOST_REQUIRE (intx::uint256 (vault_balance (evm_account_name)) == evm_account_balance);
0 commit comments