diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/libsolidity/ErrorCheck.cpp | 2 | ||||
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 88 |
2 files changed, 89 insertions, 1 deletions
diff --git a/test/libsolidity/ErrorCheck.cpp b/test/libsolidity/ErrorCheck.cpp index 00424b4c..b1e94061 100644 --- a/test/libsolidity/ErrorCheck.cpp +++ b/test/libsolidity/ErrorCheck.cpp @@ -32,7 +32,7 @@ bool dev::solidity::searchErrorMessage(Error const& _err, std::string const& _su { if (errorMessage->find(_substr) == std::string::npos) { - cout << "Expected message \"" << _substr << "\" but found" << *errorMessage << endl; + cout << "Expected message \"" << _substr << "\" but found \"" << *errorMessage << "\".\n"; return false; } return true; diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 2ee5baac..472f1b97 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -6146,6 +6146,94 @@ BOOST_AUTO_TEST_CASE(callable_crash) CHECK_ERROR(text, TypeError, "Type is not callable"); } +BOOST_AUTO_TEST_CASE(error_transfer_non_payable_fallback) +{ + char const* text = R"( + contract A { + function() {} + } + + contract B { + A a; + + function() { + a.transfer(100); + } + } + )"; + CHECK_ERROR(text, TypeError, "Value transfer to a contract without a payable fallback function."); +} + +BOOST_AUTO_TEST_CASE(error_transfer_no_fallback) +{ + char const* text = R"( + contract A {} + + contract B { + A a; + + function() { + a.transfer(100); + } + } + )"; + CHECK_ERROR(text, TypeError, "Value transfer to a contract without a payable fallback function."); +} + +BOOST_AUTO_TEST_CASE(error_send_non_payable_fallback) +{ + char const* text = R"( + contract A { + function() {} + } + + contract B { + A a; + + function() { + require(a.send(100)); + } + } + )"; + CHECK_ERROR(text, TypeError, "Value transfer to a contract without a payable fallback function."); +} + +BOOST_AUTO_TEST_CASE(does_not_error_transfer_payable_fallback) +{ + char const* text = R"( + contract A { + function() payable {} + } + + contract B { + A a; + + function() { + a.transfer(100); + } + } + )"; + CHECK_SUCCESS_NO_WARNINGS(text); +} + +BOOST_AUTO_TEST_CASE(does_not_error_transfer_regular_function) +{ + char const* text = R"( + contract A { + function transfer(uint) {} + } + + contract B { + A a; + + function() { + a.transfer(100); + } + } + )"; + CHECK_SUCCESS_NO_WARNINGS(text); +} + BOOST_AUTO_TEST_CASE(returndatacopy_as_variable) { char const* text = R"( |