mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge remote-tracking branch 'upstream/develop' into blockTests
This commit is contained in:
commit
dd96558634
@ -102,6 +102,16 @@ BOOST_AUTO_TEST_CASE(named_args)
|
||||
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)
|
||||
{
|
||||
char const* sourceCode = "contract test {\n"
|
||||
|
@ -868,6 +868,42 @@ BOOST_AUTO_TEST_CASE(access_to_protected_state_variable)
|
||||
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()
|
||||
|
||||
}
|
||||
|
@ -124,6 +124,24 @@ BOOST_AUTO_TEST_CASE(single_function_param)
|
||||
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)
|
||||
{
|
||||
ASTPointer<ContractDefinition> contract;
|
||||
|
@ -20,7 +20,8 @@
|
||||
*/
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <libdevcore/CommonJS.h>
|
||||
#include <libdevcore/Log.h>
|
||||
#include <libethcore/CommonJS.h>
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(commonjs)
|
||||
using namespace std;
|
||||
@ -41,7 +42,7 @@ BOOST_AUTO_TEST_CASE(jsToAddress)
|
||||
cnote << "Testing jsToPublic...";
|
||||
KeyPair kp = KeyPair::create();
|
||||
string string = toJS(kp.address());
|
||||
Address address = dev::jsToAddress(string);
|
||||
Address address = dev::eth::jsToAddress(string);
|
||||
BOOST_CHECK_EQUAL(kp.address(), address);
|
||||
}
|
||||
|
||||
|
2
fork.cpp
2
fork.cpp
@ -23,7 +23,7 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <libethereum/Client.h>
|
||||
#include <libethereum/BlockChain.h>
|
||||
#include <libethereum/CanonBlockChain.h>
|
||||
#include <libethereum/EthereumHost.h>
|
||||
#include "TestHelper.h"
|
||||
using namespace std;
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <random>
|
||||
#include "JsonSpiritHeaders.h"
|
||||
#include <libdevcore/CommonIO.h>
|
||||
#include <libethereum/BlockChain.h>
|
||||
#include <libethereum/CanonBlockChain.h>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include "TestHelper.h"
|
||||
|
||||
@ -58,9 +58,9 @@ BOOST_AUTO_TEST_CASE(genesis_tests)
|
||||
|
||||
js::mObject o = v.get_obj();
|
||||
|
||||
BOOST_CHECK_EQUAL(BlockChain::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(BlockInfo::headerHash(BlockChain::createGenesisBlock()), h256(o["genesis_hash"].get_str()));
|
||||
BOOST_CHECK_EQUAL(CanonBlockChain::genesis().stateRoot, h256(o["genesis_state_root"].get_str()));
|
||||
BOOST_CHECK_EQUAL(toHex(CanonBlockChain::createGenesisBlock()), toHex(fromHex(o["genesis_rlp_hex"].get_str())));
|
||||
BOOST_CHECK_EQUAL(BlockInfo::headerHash(CanonBlockChain::createGenesisBlock()), h256(o["genesis_hash"].get_str()));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <libdevcore/Log.h>
|
||||
#include <libdevcore/CommonIO.h>
|
||||
#include <libdevcore/CommonJS.h>
|
||||
#include <libethcore/CommonJS.h>
|
||||
#include <libwebthree/WebThree.h>
|
||||
#include <libweb3jsonrpc/WebThreeStubServer.h>
|
||||
#include <jsonrpccpp/server/connectors/httpserver.h>
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include "JsonSpiritHeaders.h"
|
||||
#include <libdevcore/CommonIO.h>
|
||||
#include <libethereum/BlockChain.h>
|
||||
#include <libethereum/CanonBlockChain.h>
|
||||
#include <libethereum/State.h>
|
||||
#include <libethereum/ExtVM.h>
|
||||
#include <libethereum/Defaults.h>
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <secp256k1/secp256k1.h>
|
||||
#include <libethereum/BlockChain.h>
|
||||
#include <libethereum/CanonBlockChain.h>
|
||||
#include <libethereum/State.h>
|
||||
#include <libethereum/Defaults.h>
|
||||
using namespace std;
|
||||
@ -40,7 +40,7 @@ int stateTest()
|
||||
Defaults::setDBPath(boost::filesystem::temp_directory_path().string());
|
||||
|
||||
OverlayDB stateDB = State::openDB();
|
||||
BlockChain bc;
|
||||
CanonBlockChain bc;
|
||||
State s(myMiner.address(), stateDB);
|
||||
|
||||
cout << bc;
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <libethereum/Client.h>
|
||||
#include <libethereum/BlockChain.h>
|
||||
#include <libethereum/CanonBlockChain.h>
|
||||
#include <libethereum/EthereumHost.h>
|
||||
#include "TestHelper.h"
|
||||
using namespace std;
|
||||
|
Loading…
Reference in New Issue
Block a user