Cleaner solution to provide standard sources.

This commit is contained in:
Christian 2015-01-28 13:39:04 +01:00
parent f9109f2eea
commit 77374a46ce
4 changed files with 23 additions and 2 deletions

View File

@ -35,6 +35,8 @@ namespace test
class InterfaceChecker
{
public:
InterfaceChecker(): m_compilerStack(false) {}
void checkInterface(std::string const& _code, std::string const& _expectedInterfaceString)
{
try

View File

@ -1862,6 +1862,21 @@ BOOST_AUTO_TEST_CASE(function_modifier_for_constructor)
BOOST_CHECK(callContractFunction("getData()") == encodeArgs(4 | 2));
}
BOOST_AUTO_TEST_CASE(use_std_lib)
{
char const* sourceCode = R"(
import "mortal";
contract Icarus is mortal { }
)";
u256 amount(130);
u160 address(23);
compileAndRun(sourceCode, amount, "Icarus");
u256 balanceBefore = m_state.balance(m_sender);
BOOST_CHECK(callContractFunction("kill()") == bytes());
BOOST_CHECK(!m_state.addressHasCode(m_contractAddress));
BOOST_CHECK(m_state.balance(m_sender) > balanceBefore);
}
BOOST_AUTO_TEST_SUITE_END()
}

View File

@ -36,6 +36,8 @@ namespace test
class DocumentationChecker
{
public:
DocumentationChecker(): m_compilerStack(false) {}
void checkNatspec(std::string const& _code,
std::string const& _expectedDocumentationString,
bool _userDocumentation)

View File

@ -45,10 +45,12 @@ public:
bytes const& compileAndRun(std::string const& _sourceCode, u256 const& _value = 0, std::string const& _contractName = "")
{
dev::solidity::CompilerStack compiler;
// add standard sources only if contract name is given
dev::solidity::CompilerStack compiler(!_contractName.empty());
try
{
compiler.compile(_sourceCode, m_optimize);
compiler.addSource("", _sourceCode);
compiler.compile(m_optimize);
}
catch(boost::exception const& _e)
{