mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Merge remote-tracking branch 'upstream/develop' into RefundOverflow
This commit is contained in:
		
						commit
						1298b8605c
					
				| @ -92,6 +92,26 @@ BOOST_AUTO_TEST_CASE(multiple_functions) | |||||||
| 	BOOST_CHECK(callContractFunction("i_am_not_there()", bytes()) == bytes()); | 	BOOST_CHECK(callContractFunction("i_am_not_there()", bytes()) == bytes()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | BOOST_AUTO_TEST_CASE(named_args) | ||||||
|  | { | ||||||
|  | 	char const* sourceCode = "contract test {\n" | ||||||
|  | 							 "  function a(uint a, uint b, uint c) returns (uint r) { r = a * 100 + b * 10 + c * 1; }\n" | ||||||
|  | 							 "  function b() returns (uint r) { r = a({a: 1, b: 2, c: 3}); }\n" | ||||||
|  | 							 "}\n"; | ||||||
|  | 	compileAndRun(sourceCode); | ||||||
|  | 	BOOST_CHECK(callContractFunction("b()", bytes()) == toBigEndian(u256(123))); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | BOOST_AUTO_TEST_CASE(disorder_named_args) | ||||||
|  | { | ||||||
|  | 	char const* sourceCode = "contract test {\n" | ||||||
|  | 							 "  function a(uint a, uint b, uint c) returns (uint r) { r = a * 100 + b * 10 + c * 1; }\n" | ||||||
|  | 							 "  function b() returns (uint r) { r = a({c: 3, a: 1, b: 2}); }\n" | ||||||
|  | 							 "}\n"; | ||||||
|  | 	compileAndRun(sourceCode); | ||||||
|  | 	BOOST_CHECK(callContractFunction("b()", bytes()) == toBigEndian(u256(123))); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| BOOST_AUTO_TEST_CASE(while_loop) | BOOST_AUTO_TEST_CASE(while_loop) | ||||||
| { | { | ||||||
| 	char const* sourceCode = "contract test {\n" | 	char const* sourceCode = "contract test {\n" | ||||||
| @ -885,7 +905,7 @@ BOOST_AUTO_TEST_CASE(constructor) | |||||||
| BOOST_AUTO_TEST_CASE(simple_accessor) | BOOST_AUTO_TEST_CASE(simple_accessor) | ||||||
| { | { | ||||||
| 	char const* sourceCode = "contract test {\n" | 	char const* sourceCode = "contract test {\n" | ||||||
| 							 "  uint256 data;\n" | 							 "  uint256 public data;\n" | ||||||
| 							 "  function test() {\n" | 							 "  function test() {\n" | ||||||
| 							 "    data = 8;\n" | 							 "    data = 8;\n" | ||||||
| 							 "  }\n" | 							 "  }\n" | ||||||
| @ -897,10 +917,10 @@ BOOST_AUTO_TEST_CASE(simple_accessor) | |||||||
| BOOST_AUTO_TEST_CASE(multiple_elementary_accessors) | BOOST_AUTO_TEST_CASE(multiple_elementary_accessors) | ||||||
| { | { | ||||||
| 	char const* sourceCode = "contract test {\n" | 	char const* sourceCode = "contract test {\n" | ||||||
| 							 "  uint256 data;\n" | 							 "  uint256 public data;\n" | ||||||
| 							 "  string6 name;\n" | 							 "  string6 public name;\n" | ||||||
| 							 "  hash a_hash;\n" | 							 "  hash public a_hash;\n" | ||||||
| 							 "  address an_address;\n" | 							 "  address public an_address;\n" | ||||||
| 							 "  function test() {\n" | 							 "  function test() {\n" | ||||||
| 							 "    data = 8;\n" | 							 "    data = 8;\n" | ||||||
| 							 "    name = \"Celina\";\n" | 							 "    name = \"Celina\";\n" | ||||||
| @ -908,7 +928,6 @@ BOOST_AUTO_TEST_CASE(multiple_elementary_accessors) | |||||||
| 							 "    an_address = address(0x1337);\n" | 							 "    an_address = address(0x1337);\n" | ||||||
| 							 "    super_secret_data = 42;\n" | 							 "    super_secret_data = 42;\n" | ||||||
| 							 "  }\n" | 							 "  }\n" | ||||||
| 							 "  private:" |  | ||||||
| 							 "  uint256 super_secret_data;" | 							 "  uint256 super_secret_data;" | ||||||
| 							 "}\n"; | 							 "}\n"; | ||||||
| 	compileAndRun(sourceCode); | 	compileAndRun(sourceCode); | ||||||
| @ -919,6 +938,27 @@ BOOST_AUTO_TEST_CASE(multiple_elementary_accessors) | |||||||
| 	BOOST_CHECK(callContractFunction("super_secret_data()") == bytes()); | 	BOOST_CHECK(callContractFunction("super_secret_data()") == bytes()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | BOOST_AUTO_TEST_CASE(complex_accessors) | ||||||
|  | { | ||||||
|  | 	char const* sourceCode = "contract test {\n" | ||||||
|  | 							 "  mapping(uint256 => string4) public to_string_map;\n" | ||||||
|  | 							 "  mapping(uint256 => bool) public to_bool_map;\n" | ||||||
|  | 							 "  mapping(uint256 => uint256) public to_uint_map;\n" | ||||||
|  | 							 "  mapping(uint256 => mapping(uint256 => uint256)) public to_multiple_map;\n" | ||||||
|  | 							 "  function test() {\n" | ||||||
|  | 							 "    to_string_map[42] = \"24\";\n" | ||||||
|  | 							 "    to_bool_map[42] = false;\n" | ||||||
|  | 							 "    to_uint_map[42] = 12;\n" | ||||||
|  | 							 "    to_multiple_map[42][23] = 31;\n" | ||||||
|  | 							 "  }\n" | ||||||
|  | 							 "}\n"; | ||||||
|  | 	compileAndRun(sourceCode); | ||||||
|  | 	BOOST_CHECK(callContractFunction("to_string_map(uint256)", 42) == encodeArgs("24")); | ||||||
|  | 	BOOST_CHECK(callContractFunction("to_bool_map(uint256)", 42) == encodeArgs(false)); | ||||||
|  | 	BOOST_CHECK(callContractFunction("to_uint_map(uint256)", 42) == encodeArgs(12)); | ||||||
|  | 	BOOST_CHECK(callContractFunction("to_multiple_map(uint256,uint256)", 42, 23) == encodeArgs(31)); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| BOOST_AUTO_TEST_CASE(balance) | BOOST_AUTO_TEST_CASE(balance) | ||||||
| { | { | ||||||
| 	char const* sourceCode = "contract test {\n" | 	char const* sourceCode = "contract test {\n" | ||||||
| @ -1490,8 +1530,7 @@ BOOST_AUTO_TEST_CASE(functions_called_by_constructor) | |||||||
| 				setName("abc"); | 				setName("abc"); | ||||||
| 			} | 			} | ||||||
| 			function getName() returns (string3 ret) { return name; } | 			function getName() returns (string3 ret) { return name; } | ||||||
| 		private: | 			function setName(string3 _name) private { name = _name; } | ||||||
| 			function setName(string3 _name) { name = _name; } |  | ||||||
| 		})"; | 		})"; | ||||||
| 	compileAndRun(sourceCode); | 	compileAndRun(sourceCode); | ||||||
| 	BOOST_REQUIRE(callContractFunction("getName()") == encodeArgs("abc")); | 	BOOST_REQUIRE(callContractFunction("getName()") == encodeArgs("abc")); | ||||||
|  | |||||||
| @ -467,6 +467,24 @@ BOOST_AUTO_TEST_CASE(illegal_override_indirect) | |||||||
| 	BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError); | 	BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | BOOST_AUTO_TEST_CASE(illegal_override_visibility) | ||||||
|  | { | ||||||
|  | 	char const* text = R"( | ||||||
|  | 		contract B { function f() protected {} } | ||||||
|  | 		contract C is B { function f() public {} } | ||||||
|  | 	)"; | ||||||
|  | 	BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | BOOST_AUTO_TEST_CASE(illegal_override_constness) | ||||||
|  | { | ||||||
|  | 	char const* text = R"( | ||||||
|  | 		contract B { function f() constant {} } | ||||||
|  | 		contract C is B { function f() {} } | ||||||
|  | 	)"; | ||||||
|  | 	BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| BOOST_AUTO_TEST_CASE(complex_inheritance) | BOOST_AUTO_TEST_CASE(complex_inheritance) | ||||||
| { | { | ||||||
| 	char const* text = R"( | 	char const* text = R"( | ||||||
| @ -636,7 +654,9 @@ BOOST_AUTO_TEST_CASE(state_variable_accessors) | |||||||
| 					   "  function fun() {\n" | 					   "  function fun() {\n" | ||||||
| 					   "    uint64(2);\n" | 					   "    uint64(2);\n" | ||||||
| 					   "  }\n" | 					   "  }\n" | ||||||
| 					   "uint256 foo;\n" | 					   "uint256 public foo;\n" | ||||||
|  | 					   "mapping(uint=>string4) public map;\n" | ||||||
|  | 					   "mapping(uint=>mapping(uint=>string4)) public multiple_map;\n" | ||||||
| 					   "}\n"; | 					   "}\n"; | ||||||
| 
 | 
 | ||||||
| 	ASTPointer<SourceUnit> source; | 	ASTPointer<SourceUnit> source; | ||||||
| @ -644,10 +664,27 @@ BOOST_AUTO_TEST_CASE(state_variable_accessors) | |||||||
| 	BOOST_CHECK_NO_THROW(source = parseTextAndResolveNamesWithChecks(text)); | 	BOOST_CHECK_NO_THROW(source = parseTextAndResolveNamesWithChecks(text)); | ||||||
| 	BOOST_REQUIRE((contract = retrieveContract(source, 0)) != nullptr); | 	BOOST_REQUIRE((contract = retrieveContract(source, 0)) != nullptr); | ||||||
| 	FunctionTypePointer function = retrieveFunctionBySignature(contract, "foo()"); | 	FunctionTypePointer function = retrieveFunctionBySignature(contract, "foo()"); | ||||||
| 	BOOST_REQUIRE(function->hasDeclaration()); | 	BOOST_REQUIRE(function && function->hasDeclaration()); | ||||||
| 	auto returnParams = function->getReturnParameterTypeNames(); | 	auto returnParams = function->getReturnParameterTypeNames(); | ||||||
| 	BOOST_CHECK_EQUAL(returnParams.at(0), "uint256"); | 	BOOST_CHECK_EQUAL(returnParams.at(0), "uint256"); | ||||||
| 	BOOST_CHECK(function->isConstant()); | 	BOOST_CHECK(function->isConstant()); | ||||||
|  | 
 | ||||||
|  | 	function = retrieveFunctionBySignature(contract, "map(uint256)"); | ||||||
|  | 	BOOST_REQUIRE(function && function->hasDeclaration()); | ||||||
|  | 	auto params = function->getParameterTypeNames(); | ||||||
|  | 	BOOST_CHECK_EQUAL(params.at(0), "uint256"); | ||||||
|  | 	returnParams = function->getReturnParameterTypeNames(); | ||||||
|  | 	BOOST_CHECK_EQUAL(returnParams.at(0), "string4"); | ||||||
|  | 	BOOST_CHECK(function->isConstant()); | ||||||
|  | 
 | ||||||
|  | 	function = retrieveFunctionBySignature(contract, "multiple_map(uint256,uint256)"); | ||||||
|  | 	BOOST_REQUIRE(function && function->hasDeclaration()); | ||||||
|  | 	params = function->getParameterTypeNames(); | ||||||
|  | 	BOOST_CHECK_EQUAL(params.at(0), "uint256"); | ||||||
|  | 	BOOST_CHECK_EQUAL(params.at(1), "uint256"); | ||||||
|  | 	returnParams = function->getReturnParameterTypeNames(); | ||||||
|  | 	BOOST_CHECK_EQUAL(returnParams.at(0), "string4"); | ||||||
|  | 	BOOST_CHECK(function->isConstant()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| BOOST_AUTO_TEST_CASE(function_clash_with_state_variable_accessor) | BOOST_AUTO_TEST_CASE(function_clash_with_state_variable_accessor) | ||||||
| @ -668,16 +705,19 @@ BOOST_AUTO_TEST_CASE(private_state_variable) | |||||||
| 					   "  function fun() {\n" | 					   "  function fun() {\n" | ||||||
| 					   "    uint64(2);\n" | 					   "    uint64(2);\n" | ||||||
| 					   "  }\n" | 					   "  }\n" | ||||||
| 					   "private:\n" | 					   "uint256 private foo;\n" | ||||||
| 					   "uint256 foo;\n" | 					   "uint256 protected bar;\n" | ||||||
| 					   "}\n"; | 					   "}\n"; | ||||||
| 
 | 
 | ||||||
| 	ASTPointer<SourceUnit> source; | 	ASTPointer<SourceUnit> source; | ||||||
| 	ContractDefinition const* contract; | 	ContractDefinition const* contract; | ||||||
| 	BOOST_CHECK_NO_THROW(source = parseTextAndResolveNamesWithChecks(text)); | 	BOOST_CHECK_NO_THROW(source = parseTextAndResolveNamesWithChecks(text)); | ||||||
| 	BOOST_CHECK((contract = retrieveContract(source, 0)) != nullptr); | 	BOOST_CHECK((contract = retrieveContract(source, 0)) != nullptr); | ||||||
| 	FunctionTypePointer function = retrieveFunctionBySignature(contract, "foo()"); | 	FunctionTypePointer function; | ||||||
|  | 	function = retrieveFunctionBySignature(contract, "foo()"); | ||||||
| 	BOOST_CHECK_MESSAGE(function == nullptr, "Accessor function of a private variable should not exist"); | 	BOOST_CHECK_MESSAGE(function == nullptr, "Accessor function of a private variable should not exist"); | ||||||
|  | 	function = retrieveFunctionBySignature(contract, "bar()"); | ||||||
|  | 	BOOST_CHECK_MESSAGE(function == nullptr, "Accessor function of a protected variable should not exist"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| BOOST_AUTO_TEST_CASE(fallback_function) | BOOST_AUTO_TEST_CASE(fallback_function) | ||||||
| @ -780,6 +820,90 @@ BOOST_AUTO_TEST_CASE(multiple_events_argument_clash) | |||||||
| 	BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text)); | 	BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | BOOST_AUTO_TEST_CASE(access_to_default_function_visibility) | ||||||
|  | { | ||||||
|  | 	char const* text = R"( | ||||||
|  | 		contract c { | ||||||
|  | 			function f() {} | ||||||
|  | 		} | ||||||
|  | 		contract d { | ||||||
|  | 			function g() { c(0).f(); } | ||||||
|  | 		})"; | ||||||
|  | 	BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text)); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | BOOST_AUTO_TEST_CASE(access_to_protected_function) | ||||||
|  | { | ||||||
|  | 	char const* text = R"( | ||||||
|  | 		contract c { | ||||||
|  | 			function f() protected {} | ||||||
|  | 		} | ||||||
|  | 		contract d { | ||||||
|  | 			function g() { c(0).f(); } | ||||||
|  | 		})"; | ||||||
|  | 	BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | BOOST_AUTO_TEST_CASE(access_to_default_state_variable_visibility) | ||||||
|  | { | ||||||
|  | 	char const* text = R"( | ||||||
|  | 		contract c { | ||||||
|  | 			uint a; | ||||||
|  | 		} | ||||||
|  | 		contract d { | ||||||
|  | 			function g() { c(0).a(); } | ||||||
|  | 		})"; | ||||||
|  | 	BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | BOOST_AUTO_TEST_CASE(access_to_protected_state_variable) | ||||||
|  | { | ||||||
|  | 	char const* text = R"( | ||||||
|  | 		contract c { | ||||||
|  | 			uint public a; | ||||||
|  | 		} | ||||||
|  | 		contract d { | ||||||
|  | 			function g() { c(0).a(); } | ||||||
|  | 		})"; | ||||||
|  | 	BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text)); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | BOOST_AUTO_TEST_CASE(error_count_in_named_args) | ||||||
|  | { | ||||||
|  | 	char const* sourceCode = "contract test {\n" | ||||||
|  | 							 "  function a(uint a, uint b) returns (uint r) { r = a + b; }\n" | ||||||
|  | 							 "  function b() returns (uint r) { r = a({a: 1}); }\n" | ||||||
|  | 							 "}\n"; | ||||||
|  | 	BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | BOOST_AUTO_TEST_CASE(empty_in_named_args) | ||||||
|  | { | ||||||
|  | 	char const* sourceCode = "contract test {\n" | ||||||
|  | 							 "  function a(uint a, uint b) returns (uint r) { r = a + b; }\n" | ||||||
|  | 							 "  function b() returns (uint r) { r = a({}); }\n" | ||||||
|  | 							 "}\n"; | ||||||
|  | 	BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | BOOST_AUTO_TEST_CASE(duplicate_parameter_names_in_named_args) | ||||||
|  | { | ||||||
|  | 	char const* sourceCode = "contract test {\n" | ||||||
|  | 							 "  function a(uint a, uint b) returns (uint r) { r = a + b; }\n" | ||||||
|  | 							 "  function b() returns (uint r) { r = a({a: 1, a: 2}); }\n" | ||||||
|  | 							 "}\n"; | ||||||
|  | 	BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | BOOST_AUTO_TEST_CASE(invalid_parameter_names_in_named_args) | ||||||
|  | { | ||||||
|  | 	char const* sourceCode = "contract test {\n" | ||||||
|  | 							 "  function a(uint a, uint b) returns (uint r) { r = a + b; }\n" | ||||||
|  | 							 "  function b() returns (uint r) { r = a({a: 1, c: 2}); }\n" | ||||||
|  | 							 "}\n"; | ||||||
|  | 	BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| BOOST_AUTO_TEST_SUITE_END() | BOOST_AUTO_TEST_SUITE_END() | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | |||||||
| @ -124,14 +124,30 @@ BOOST_AUTO_TEST_CASE(single_function_param) | |||||||
| 	BOOST_CHECK_NO_THROW(parseText(text)); | 	BOOST_CHECK_NO_THROW(parseText(text)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | BOOST_AUTO_TEST_CASE(missing_parameter_name_in_named_args) | ||||||
|  | { | ||||||
|  | 	char const* text = "contract test {\n" | ||||||
|  | 					   "  function a(uint a, uint b, uint c) returns (uint r) { r = a * 100 + b * 10 + c * 1; }\n" | ||||||
|  | 					   "  function b() returns (uint r) { r = a({: 1, : 2, : 3}); }\n" | ||||||
|  | 					   "}\n"; | ||||||
|  | 	BOOST_CHECK_THROW(parseText(text), ParserError); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | BOOST_AUTO_TEST_CASE(missing_argument_in_named_args) | ||||||
|  | { | ||||||
|  | 	char const* text = "contract test {\n" | ||||||
|  | 					   "  function a(uint a, uint b, uint c) returns (uint r) { r = a * 100 + b * 10 + c * 1; }\n" | ||||||
|  | 					   "  function b() returns (uint r) { r = a({a: , b: , c: }); }\n" | ||||||
|  | 					   "}\n"; | ||||||
|  | 	BOOST_CHECK_THROW(parseText(text), ParserError); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| BOOST_AUTO_TEST_CASE(function_natspec_documentation) | BOOST_AUTO_TEST_CASE(function_natspec_documentation) | ||||||
| { | { | ||||||
| 	ASTPointer<ContractDefinition> contract; | 	ASTPointer<ContractDefinition> contract; | ||||||
| 	ASTPointer<FunctionDefinition> function; | 	ASTPointer<FunctionDefinition> function; | ||||||
| 	char const* text = "contract test {\n" | 	char const* text = "contract test {\n" | ||||||
| 					   "  private:\n" |  | ||||||
| 					   "  uint256 stateVar;\n" | 					   "  uint256 stateVar;\n" | ||||||
| 	                   "  public:\n" |  | ||||||
| 					   "  /// This is a test function\n" | 					   "  /// This is a test function\n" | ||||||
| 					   "  function functionName(hash hashin) returns (hash hashout) {}\n" | 					   "  function functionName(hash hashin) returns (hash hashout) {}\n" | ||||||
| 					   "}\n"; | 					   "}\n"; | ||||||
| @ -162,9 +178,7 @@ BOOST_AUTO_TEST_CASE(multiple_functions_natspec_documentation) | |||||||
| 	ASTPointer<ContractDefinition> contract; | 	ASTPointer<ContractDefinition> contract; | ||||||
| 	ASTPointer<FunctionDefinition> function; | 	ASTPointer<FunctionDefinition> function; | ||||||
| 	char const* text = "contract test {\n" | 	char const* text = "contract test {\n" | ||||||
| 					   "  private:\n" |  | ||||||
| 					   "  uint256 stateVar;\n" | 					   "  uint256 stateVar;\n" | ||||||
| 					   "  public:\n" |  | ||||||
| 					   "  /// This is test function 1\n" | 					   "  /// This is test function 1\n" | ||||||
| 					   "  function functionName1(hash hashin) returns (hash hashout) {}\n" | 					   "  function functionName1(hash hashin) returns (hash hashout) {}\n" | ||||||
| 					   "  /// This is test function 2\n" | 					   "  /// This is test function 2\n" | ||||||
| @ -621,6 +635,31 @@ BOOST_AUTO_TEST_CASE(event_arguments_indexed) | |||||||
| 	BOOST_CHECK_NO_THROW(parseText(text)); | 	BOOST_CHECK_NO_THROW(parseText(text)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | BOOST_AUTO_TEST_CASE(visibility_specifiers) | ||||||
|  | { | ||||||
|  | 	char const* text = R"( | ||||||
|  | 		contract c { | ||||||
|  | 			uint private a; | ||||||
|  | 			uint protected b; | ||||||
|  | 			uint public c; | ||||||
|  | 			uint d; | ||||||
|  | 			function f() {} | ||||||
|  | 			function f_priv() private {} | ||||||
|  | 			function f_public() public {} | ||||||
|  | 			function f_protected() protected {} | ||||||
|  | 		})"; | ||||||
|  | 	BOOST_CHECK_NO_THROW(parseText(text)); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | BOOST_AUTO_TEST_CASE(multiple_visibility_specifiers) | ||||||
|  | { | ||||||
|  | 	char const* text = R"( | ||||||
|  | 		contract c { | ||||||
|  | 			uint private protected a; | ||||||
|  | 		})"; | ||||||
|  | 	BOOST_CHECK_THROW(parseText(text), ParserError); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| BOOST_AUTO_TEST_SUITE_END() | BOOST_AUTO_TEST_SUITE_END() | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | |||||||
| @ -20,7 +20,8 @@ | |||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include <boost/test/unit_test.hpp> | #include <boost/test/unit_test.hpp> | ||||||
| #include <libdevcore/CommonJS.h> | #include <libdevcore/Log.h> | ||||||
|  | #include <libethcore/CommonJS.h> | ||||||
| 
 | 
 | ||||||
| BOOST_AUTO_TEST_SUITE(commonjs) | BOOST_AUTO_TEST_SUITE(commonjs) | ||||||
| using namespace std; | using namespace std; | ||||||
| @ -41,7 +42,7 @@ BOOST_AUTO_TEST_CASE(jsToAddress) | |||||||
| 	cnote << "Testing jsToPublic..."; | 	cnote << "Testing jsToPublic..."; | ||||||
| 	KeyPair kp = KeyPair::create(); | 	KeyPair kp = KeyPair::create(); | ||||||
| 	string string = toJS(kp.address()); | 	string string = toJS(kp.address()); | ||||||
| 	Address address = dev::jsToAddress(string); | 	Address address = dev::eth::jsToAddress(string); | ||||||
| 	BOOST_CHECK_EQUAL(kp.address(), address); | 	BOOST_CHECK_EQUAL(kp.address(), address); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										2
									
								
								fork.cpp
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								fork.cpp
									
									
									
									
									
								
							| @ -23,7 +23,7 @@ | |||||||
| #include <boost/test/unit_test.hpp> | #include <boost/test/unit_test.hpp> | ||||||
| #include <boost/filesystem/operations.hpp> | #include <boost/filesystem/operations.hpp> | ||||||
| #include <libethereum/Client.h> | #include <libethereum/Client.h> | ||||||
| #include <libethereum/BlockChain.h> | #include <libethereum/CanonBlockChain.h> | ||||||
| #include <libethereum/EthereumHost.h> | #include <libethereum/EthereumHost.h> | ||||||
| #include "TestHelper.h" | #include "TestHelper.h" | ||||||
| using namespace std; | using namespace std; | ||||||
|  | |||||||
| @ -24,7 +24,7 @@ | |||||||
| #include <random> | #include <random> | ||||||
| #include "JsonSpiritHeaders.h" | #include "JsonSpiritHeaders.h" | ||||||
| #include <libdevcore/CommonIO.h> | #include <libdevcore/CommonIO.h> | ||||||
| #include <libethereum/BlockChain.h> | #include <libethereum/CanonBlockChain.h> | ||||||
| #include <boost/test/unit_test.hpp> | #include <boost/test/unit_test.hpp> | ||||||
| #include "TestHelper.h" | #include "TestHelper.h" | ||||||
| 
 | 
 | ||||||
| @ -58,9 +58,9 @@ BOOST_AUTO_TEST_CASE(genesis_tests) | |||||||
| 
 | 
 | ||||||
| 	js::mObject o = v.get_obj(); | 	js::mObject o = v.get_obj(); | ||||||
| 
 | 
 | ||||||
| 	BOOST_CHECK_EQUAL(BlockChain::genesis().stateRoot, h256(o["genesis_state_root"].get_str())); | 	BOOST_CHECK_EQUAL(CanonBlockChain::genesis().stateRoot, h256(o["genesis_state_root"].get_str())); | ||||||
| 	BOOST_CHECK_EQUAL(toHex(BlockChain::createGenesisBlock()), toHex(fromHex(o["genesis_rlp_hex"].get_str()))); | 	BOOST_CHECK_EQUAL(toHex(CanonBlockChain::createGenesisBlock()), toHex(fromHex(o["genesis_rlp_hex"].get_str()))); | ||||||
| 	BOOST_CHECK_EQUAL(BlockInfo::headerHash(BlockChain::createGenesisBlock()), h256(o["genesis_hash"].get_str())); | 	BOOST_CHECK_EQUAL(BlockInfo::headerHash(CanonBlockChain::createGenesisBlock()), h256(o["genesis_hash"].get_str())); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| BOOST_AUTO_TEST_SUITE_END() | BOOST_AUTO_TEST_SUITE_END() | ||||||
|  | |||||||
| @ -28,7 +28,7 @@ | |||||||
| #include <boost/lexical_cast.hpp> | #include <boost/lexical_cast.hpp> | ||||||
| #include <libdevcore/Log.h> | #include <libdevcore/Log.h> | ||||||
| #include <libdevcore/CommonIO.h> | #include <libdevcore/CommonIO.h> | ||||||
| #include <libdevcore/CommonJS.h> | #include <libethcore/CommonJS.h> | ||||||
| #include <libwebthree/WebThree.h> | #include <libwebthree/WebThree.h> | ||||||
| #include <libweb3jsonrpc/WebThreeStubServer.h> | #include <libweb3jsonrpc/WebThreeStubServer.h> | ||||||
| #include <jsonrpccpp/server/connectors/httpserver.h> | #include <jsonrpccpp/server/connectors/httpserver.h> | ||||||
|  | |||||||
| @ -24,7 +24,7 @@ | |||||||
| #include <boost/test/unit_test.hpp> | #include <boost/test/unit_test.hpp> | ||||||
| #include "JsonSpiritHeaders.h" | #include "JsonSpiritHeaders.h" | ||||||
| #include <libdevcore/CommonIO.h> | #include <libdevcore/CommonIO.h> | ||||||
| #include <libethereum/BlockChain.h> | #include <libethereum/CanonBlockChain.h> | ||||||
| #include <libethereum/State.h> | #include <libethereum/State.h> | ||||||
| #include <libethereum/ExtVM.h> | #include <libethereum/ExtVM.h> | ||||||
| #include <libethereum/Defaults.h> | #include <libethereum/Defaults.h> | ||||||
|  | |||||||
| @ -22,7 +22,7 @@ | |||||||
| 
 | 
 | ||||||
| #include <boost/filesystem/operations.hpp> | #include <boost/filesystem/operations.hpp> | ||||||
| #include <secp256k1/secp256k1.h> | #include <secp256k1/secp256k1.h> | ||||||
| #include <libethereum/BlockChain.h> | #include <libethereum/CanonBlockChain.h> | ||||||
| #include <libethereum/State.h> | #include <libethereum/State.h> | ||||||
| #include <libethereum/Defaults.h> | #include <libethereum/Defaults.h> | ||||||
| using namespace std; | using namespace std; | ||||||
| @ -40,7 +40,7 @@ int stateTest() | |||||||
| 	Defaults::setDBPath(boost::filesystem::temp_directory_path().string()); | 	Defaults::setDBPath(boost::filesystem::temp_directory_path().string()); | ||||||
| 
 | 
 | ||||||
| 	OverlayDB stateDB = State::openDB(); | 	OverlayDB stateDB = State::openDB(); | ||||||
| 	BlockChain bc; | 	CanonBlockChain bc; | ||||||
| 	State s(myMiner.address(), stateDB); | 	State s(myMiner.address(), stateDB); | ||||||
| 
 | 
 | ||||||
| 	cout << bc; | 	cout << bc; | ||||||
| @ -51,7 +51,7 @@ int stateTest() | |||||||
| 	cout << s; | 	cout << s; | ||||||
| 
 | 
 | ||||||
| 	// Mine to get some ether!
 | 	// Mine to get some ether!
 | ||||||
| 	s.commitToMine(); | 	s.commitToMine(bc); | ||||||
| 	while (!s.mine(100).completed) {} | 	while (!s.mine(100).completed) {} | ||||||
| 	s.completeMine(); | 	s.completeMine(); | ||||||
| 	bc.attemptImport(s.blockData(), stateDB); | 	bc.attemptImport(s.blockData(), stateDB); | ||||||
| @ -74,8 +74,9 @@ int stateTest() | |||||||
| 	cout << s; | 	cout << s; | ||||||
| 
 | 
 | ||||||
| 	// Mine to get some ether and set in stone.
 | 	// Mine to get some ether and set in stone.
 | ||||||
| 	s.commitToMine(); | 	s.commitToMine(bc); | ||||||
| 	while (!s.mine(100).completed) {} | 	s.commitToMine(bc); | ||||||
|  | 	while (!s.mine(50).completed) { s.commitToMine(bc); } | ||||||
| 	s.completeMine(); | 	s.completeMine(); | ||||||
| 	bc.attemptImport(s.blockData(), stateDB); | 	bc.attemptImport(s.blockData(), stateDB); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -23,7 +23,7 @@ | |||||||
| #include <boost/test/unit_test.hpp> | #include <boost/test/unit_test.hpp> | ||||||
| #include <boost/filesystem/operations.hpp> | #include <boost/filesystem/operations.hpp> | ||||||
| #include <libethereum/Client.h> | #include <libethereum/Client.h> | ||||||
| #include <libethereum/BlockChain.h> | #include <libethereum/CanonBlockChain.h> | ||||||
| #include <libethereum/EthereumHost.h> | #include <libethereum/EthereumHost.h> | ||||||
| #include "TestHelper.h" | #include "TestHelper.h" | ||||||
| using namespace std; | using namespace std; | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user