Enable some tests.

This commit is contained in:
chriseth 2021-01-11 11:52:42 +01:00
parent bbef792568
commit 8058cad772
5 changed files with 277 additions and 191 deletions

View File

@ -2239,10 +2239,13 @@ BOOST_AUTO_TEST_CASE(library_call_in_homestead)
}
}
)";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode, 0, "Lib");
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, h160>{{"Lib", m_contractAddress}});
ABI_CHECK(callContractFunction("f()"), encodeArgs());
ABI_CHECK(callContractFunction("sender()"), encodeArgs(m_sender));
)
}
BOOST_AUTO_TEST_CASE(library_call_protection)
@ -2266,6 +2269,8 @@ BOOST_AUTO_TEST_CASE(library_call_protection)
function pu() public pure returns (uint) { return Lib.pu(); }
}
)";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode, 0, "Lib");
ABI_CHECK(callContractFunction("np(Lib.S storage)", 0), encodeArgs());
ABI_CHECK(callContractFunction("v(Lib.S storage)", 0), encodeArgs(m_sender));
@ -2276,6 +2281,7 @@ BOOST_AUTO_TEST_CASE(library_call_protection)
ABI_CHECK(callContractFunction("s()"), encodeArgs(3));
ABI_CHECK(callContractFunction("v()"), encodeArgs(m_sender));
ABI_CHECK(callContractFunction("pu()"), encodeArgs(2));
)
}
BOOST_AUTO_TEST_CASE(library_staticcall_delegatecall)
@ -2537,6 +2543,8 @@ BOOST_AUTO_TEST_CASE(struct_referencing)
function a2() public pure returns (uint) { L.S memory s; return L.a(s); }
}
)";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode, 0, "L");
ABI_CHECK(callContractFunction("f()"), encodeArgs(0, 3));
ABI_CHECK(callContractFunction("g()"), encodeArgs(4));
@ -2548,6 +2556,7 @@ BOOST_AUTO_TEST_CASE(struct_referencing)
ABI_CHECK(callContractFunction("y()"), encodeArgs(4));
ABI_CHECK(callContractFunction("a1()"), encodeArgs(1));
ABI_CHECK(callContractFunction("a2()"), encodeArgs(2));
)
}
BOOST_AUTO_TEST_CASE(enum_referencing)
@ -2583,6 +2592,8 @@ BOOST_AUTO_TEST_CASE(enum_referencing)
}
}
)";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode, 0, "L");
ABI_CHECK(callContractFunction("f()"), encodeArgs(1));
ABI_CHECK(callContractFunction("g()"), encodeArgs(3));
@ -2592,6 +2603,7 @@ BOOST_AUTO_TEST_CASE(enum_referencing)
ABI_CHECK(callContractFunction("h()"), encodeArgs(1));
ABI_CHECK(callContractFunction("x()"), encodeArgs(1));
ABI_CHECK(callContractFunction("y()"), encodeArgs(3));
)
}
BOOST_AUTO_TEST_CASE(bytes_in_arguments)
@ -3413,9 +3425,12 @@ BOOST_AUTO_TEST_CASE(library_call)
}
}
)";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode, 0, "Lib");
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, h160>{{"Lib", m_contractAddress}});
ABI_CHECK(callContractFunction("f(uint256)", u256(33)), encodeArgs(u256(33) * 9));
)
}
BOOST_AUTO_TEST_CASE(library_function_external)
@ -3428,9 +3443,12 @@ BOOST_AUTO_TEST_CASE(library_function_external)
}
}
)";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode, 0, "Lib");
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, h160>{{"Lib", m_contractAddress}});
ABI_CHECK(callContractFunction("f(bytes)", u256(0x20), u256(5), "abcde"), encodeArgs("c"));
)
}
BOOST_AUTO_TEST_CASE(library_stray_values)
@ -3445,9 +3463,12 @@ BOOST_AUTO_TEST_CASE(library_stray_values)
}
}
)";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode, 0, "Lib");
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, h160>{{"Lib", m_contractAddress}});
ABI_CHECK(callContractFunction("f(uint256)", u256(33)), encodeArgs(u256(42)));
)
}
BOOST_AUTO_TEST_CASE(internal_types_in_library)
@ -3475,9 +3496,12 @@ BOOST_AUTO_TEST_CASE(internal_types_in_library)
}
}
)";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode, 0, "Lib");
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, h160>{{"Lib", m_contractAddress}});
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(4), u256(17)));
)
}
BOOST_AUTO_TEST_CASE(mapping_arguments_in_library)
@ -3506,6 +3530,8 @@ BOOST_AUTO_TEST_CASE(mapping_arguments_in_library)
}
}
)";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode, 0, "Lib");
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, h160>{{"Lib", m_contractAddress}});
ABI_CHECK(callContractFunction("set(uint256,uint256)", u256(1), u256(42)), encodeArgs(u256(0)));
@ -3522,6 +3548,7 @@ BOOST_AUTO_TEST_CASE(mapping_arguments_in_library)
ABI_CHECK(callContractFunction("get(uint256)", u256(1)), encodeArgs(u256(21)));
ABI_CHECK(callContractFunction("get(uint256)", u256(2)), encodeArgs(u256(42)));
ABI_CHECK(callContractFunction("get(uint256)", u256(21)), encodeArgs(u256(14)));
)
}
BOOST_AUTO_TEST_CASE(mapping_returns_in_library)
@ -3554,6 +3581,8 @@ BOOST_AUTO_TEST_CASE(mapping_returns_in_library)
}
}
)";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode, 0, "Lib");
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, h160>{{"Lib", m_contractAddress}});
ABI_CHECK(callContractFunction("set(bool,uint256,uint256)", true, u256(1), u256(42)), encodeArgs(u256(0)));
@ -3600,6 +3629,7 @@ BOOST_AUTO_TEST_CASE(mapping_returns_in_library)
ABI_CHECK(callContractFunction("get(bool,uint256)", false, u256(1)), encodeArgs(u256(30)));
ABI_CHECK(callContractFunction("get(bool,uint256)", false, u256(2)), encodeArgs(u256(31)));
ABI_CHECK(callContractFunction("get(bool,uint256)", false, u256(21)), encodeArgs(u256(32)));
)
}
BOOST_AUTO_TEST_CASE(mapping_returns_in_library_named)
@ -3630,10 +3660,13 @@ BOOST_AUTO_TEST_CASE(mapping_returns_in_library_named)
}
}
)";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode, 0, "Lib");
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, h160>{{"Lib", m_contractAddress}});
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(0), u256(42), u256(0), u256(0), u256(21), u256(84)));
ABI_CHECK(callContractFunction("g()"), encodeArgs(u256(0), u256(42), u256(0), u256(0), u256(21), u256(17)));
)
}
BOOST_AUTO_TEST_CASE(using_library_mappings_public)
@ -3658,9 +3691,12 @@ BOOST_AUTO_TEST_CASE(using_library_mappings_public)
}
}
)";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode, 0, "Lib");
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, h160>{{"Lib", m_contractAddress}});
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(1), u256(0), u256(42), u256(23), u256(0), u256(99)));
)
}
BOOST_AUTO_TEST_CASE(using_library_mappings_external)
@ -3719,9 +3755,12 @@ BOOST_AUTO_TEST_CASE(using_library_mappings_return)
}
}
)";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode, 0, "Lib");
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, h160>{{"Lib", m_contractAddress}});
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(1), u256(0), u256(42), u256(23), u256(0), u256(99)));
)
}
BOOST_AUTO_TEST_CASE(using_library_structs)
@ -3747,9 +3786,12 @@ BOOST_AUTO_TEST_CASE(using_library_structs)
}
}
)";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode, 0, "Lib");
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, h160>{{"Lib", m_contractAddress}});
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(7), u256(8)));
)
}
BOOST_AUTO_TEST_CASE(short_strings)
@ -3860,6 +3902,8 @@ BOOST_AUTO_TEST_CASE(short_strings)
}
}
)";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode, 0, "A");
ABI_CHECK(callContractFunction("data1()"), encodeDyn(string("123")));
ABI_CHECK(callContractFunction("lengthChange()"), encodeArgs(u256(0)));
@ -3868,6 +3912,7 @@ BOOST_AUTO_TEST_CASE(short_strings)
BOOST_CHECK(storageEmpty(m_contractAddress));
ABI_CHECK(callContractFunction("copy()"), encodeArgs(u256(0)));
BOOST_CHECK(storageEmpty(m_contractAddress));
)
}
BOOST_AUTO_TEST_CASE(calldata_offset)
@ -3901,6 +3946,8 @@ BOOST_AUTO_TEST_CASE(reject_ether_sent_to_library)
receive () external payable {}
}
)";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode, 0, "lib");
Address libraryAddress = m_contractAddress;
compileAndRun(sourceCode, 10, "c");
@ -3912,6 +3959,7 @@ BOOST_AUTO_TEST_CASE(reject_ether_sent_to_library)
ABI_CHECK(callContractFunction("f(address)", encodeArgs(m_contractAddress)), encodeArgs(true));
BOOST_CHECK_EQUAL(balanceAt(m_contractAddress), 10);
BOOST_CHECK_EQUAL(balanceAt(libraryAddress), 0);
)
}
BOOST_AUTO_TEST_CASE(create_memory_array_allocation_size)
@ -3970,10 +4018,13 @@ BOOST_AUTO_TEST_CASE(using_for_function_on_struct)
}
}
)";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode, 0, "D");
compileAndRun(sourceCode, 0, "C", bytes(), map<string, h160>{{"D", m_contractAddress}});
ABI_CHECK(callContractFunction("f(uint256)", u256(7)), encodeArgs(u256(3 * 7)));
ABI_CHECK(callContractFunction("x()"), encodeArgs(u256(3 * 7)));
)
}
BOOST_AUTO_TEST_CASE(using_for_overload)
@ -3993,10 +4044,13 @@ BOOST_AUTO_TEST_CASE(using_for_overload)
}
}
)";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode, 0, "D");
compileAndRun(sourceCode, 0, "C", bytes(), map<string, h160>{{"D", m_contractAddress}});
ABI_CHECK(callContractFunction("f(uint256)", u256(7)), encodeArgs(u256(6 * 7)));
ABI_CHECK(callContractFunction("x()"), encodeArgs(u256(6 * 7)));
)
}
BOOST_AUTO_TEST_CASE(using_for_by_name)
@ -4012,10 +4066,13 @@ BOOST_AUTO_TEST_CASE(using_for_by_name)
}
}
)";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode, 0, "D");
compileAndRun(sourceCode, 0, "C", bytes(), map<string, h160>{{"D", m_contractAddress}});
ABI_CHECK(callContractFunction("f(uint256)", u256(7)), encodeArgs(u256(6 * 7)));
ABI_CHECK(callContractFunction("x()"), encodeArgs(u256(6 * 7)));
)
}
BOOST_AUTO_TEST_CASE(bound_function_in_function)
@ -4032,9 +4089,12 @@ BOOST_AUTO_TEST_CASE(bound_function_in_function)
function t() public pure returns (uint) { return 7; }
}
)";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode, 0, "L");
compileAndRun(sourceCode, 0, "C", bytes(), map<string, h160>{{"L", m_contractAddress}});
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(7)));
)
}
BOOST_AUTO_TEST_CASE(bound_function_in_var)
@ -4050,10 +4110,13 @@ BOOST_AUTO_TEST_CASE(bound_function_in_var)
}
}
)";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode, 0, "D");
compileAndRun(sourceCode, 0, "C", bytes(), map<string, h160>{{"D", m_contractAddress}});
ABI_CHECK(callContractFunction("f(uint256)", u256(7)), encodeArgs(u256(6 * 7)));
ABI_CHECK(callContractFunction("x()"), encodeArgs(u256(6 * 7)));
)
}
BOOST_AUTO_TEST_CASE(bound_function_to_string)
@ -4073,10 +4136,13 @@ BOOST_AUTO_TEST_CASE(bound_function_to_string)
}
}
)";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode, 0, "D");
compileAndRun(sourceCode, 0, "C", bytes(), map<string, h160>{{"D", m_contractAddress}});
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(3)));
ABI_CHECK(callContractFunction("g()"), encodeArgs(u256(3)));
)
}
BOOST_AUTO_TEST_CASE(inline_long_string_return)
@ -4271,9 +4337,12 @@ BOOST_AUTO_TEST_CASE(payable_function_calls_library)
}
}
)";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode, 0, "L");
compileAndRun(sourceCode, 0, "C", bytes(), map<string, h160>{{"L", m_contractAddress}});
ABI_CHECK(callContractFunctionWithValue("f()", 27), encodeArgs(u256(7)));
)
}
BOOST_AUTO_TEST_CASE(non_payable_throw)
@ -4296,6 +4365,8 @@ BOOST_AUTO_TEST_CASE(non_payable_throw)
}
)";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode, 0, "C");
ABI_CHECK(callContractFunctionWithValue("f()", 27), encodeArgs());
BOOST_CHECK_EQUAL(balanceAt(m_contractAddress), 0);
@ -4306,6 +4377,7 @@ BOOST_AUTO_TEST_CASE(non_payable_throw)
ABI_CHECK(callContractFunction("a()"), encodeArgs(u256(1)));
ABI_CHECK(callContractFunctionWithValue("a()", 27), encodeArgs());
BOOST_CHECK_EQUAL(balanceAt(m_contractAddress), 0);
)
}
BOOST_AUTO_TEST_CASE(mem_resize_is_not_paid_at_call)
@ -4340,11 +4412,14 @@ BOOST_AUTO_TEST_CASE(receive_external_function_type)
}
)";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode, 0, "C");
ABI_CHECK(callContractFunction(
"f(function)",
m_contractAddress.asBytes() + FixedHash<4>(util::keccak256("g()")).asBytes() + bytes(32 - 4 - 20, 0)
), encodeArgs(u256(7)));
)
}
BOOST_AUTO_TEST_CASE(return_external_function_type)
@ -5266,9 +5341,12 @@ BOOST_AUTO_TEST_CASE(event_signature_in_library)
}
}
)";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode, 0, "C");
BOOST_REQUIRE_EQUAL(numLogTopics(0), 2);
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E((uint8,int16),(uint8,int16))")));
)
}
BOOST_AUTO_TEST_CASE(abi_encode_with_selector)
@ -5556,6 +5634,8 @@ BOOST_AUTO_TEST_CASE(event_wrong_abi_name)
}
}
)";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode, 0, "ClientReceipt", bytes());
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, h160>{{"ClientReceipt", m_contractAddress}});
@ -5564,6 +5644,7 @@ BOOST_AUTO_TEST_CASE(event_wrong_abi_name)
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
BOOST_REQUIRE_EQUAL(numLogTopics(0), 3);
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit(address,bytes32,uint256)")));
)
}
BOOST_AUTO_TEST_CASE(uninitialized_internal_storage_function)

View File

@ -24,6 +24,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// EVMVersion: >homestead
// ----
// library: L

View File

@ -24,6 +24,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// EVMVersion: >homestead
// ----
// library: L

View File

@ -23,6 +23,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// EVMVersion: >homestead
// ----
// library: L

View File

@ -16,6 +16,8 @@ contract C {
assembly { slot := ptr.slot }
}
}
// ====
// compileViaYul: also
// ----
// library: Lib
// f() -> 123