Browse Source

Changes in Solidity Tests to use the new bytesXX type

cl-refactor
Lefteris Karapetsas 10 years ago
parent
commit
81beec48bf
  1. 10
      test/SolidityABIJSON.cpp
  2. 10
      test/SolidityInterface.cpp

10
test/SolidityABIJSON.cpp

@ -339,10 +339,10 @@ BOOST_AUTO_TEST_CASE(inherited)
char const* sourceCode = char const* sourceCode =
" contract Base { \n" " contract Base { \n"
" function baseFunction(uint p) returns (uint i) { return p; } \n" " function baseFunction(uint p) returns (uint i) { return p; } \n"
" event baseEvent(string32 indexed evtArgBase); \n" " event baseEvent(bytes32 indexed evtArgBase); \n"
" } \n" " } \n"
" contract Derived is Base { \n" " contract Derived is Base { \n"
" function derivedFunction(string32 p) returns (string32 i) { return p; } \n" " function derivedFunction(bytes32 p) returns (bytes32 i) { return p; } \n"
" event derivedEvent(uint indexed evtArgDerived); \n" " event derivedEvent(uint indexed evtArgDerived); \n"
" }"; " }";
@ -369,12 +369,12 @@ BOOST_AUTO_TEST_CASE(inherited)
"inputs": "inputs":
[{ [{
"name": "p", "name": "p",
"type": "string32" "type": "bytes32"
}], }],
"outputs": "outputs":
[{ [{
"name": "i", "name": "i",
"type": "string32" "type": "bytes32"
}] }]
}, },
{ {
@ -394,7 +394,7 @@ BOOST_AUTO_TEST_CASE(inherited)
[{ [{
"indexed": true, "indexed": true,
"name": "evtArgBase", "name": "evtArgBase",
"type": "string32" "type": "bytes32"
}] }]
}])"; }])";

10
test/SolidityInterface.cpp

@ -84,10 +84,10 @@ BOOST_AUTO_TEST_CASE(single_function)
BOOST_AUTO_TEST_CASE(single_constant_function) BOOST_AUTO_TEST_CASE(single_constant_function)
{ {
ContractDefinition const& contract = checkInterface( ContractDefinition const& contract = checkInterface(
"contract test { function f(uint a) constant returns(hash8 x) { 1==2; } }"); "contract test { function f(uint a) constant returns(bytes1 x) { 1==2; } }");
BOOST_REQUIRE_EQUAL(1, contract.getDefinedFunctions().size()); BOOST_REQUIRE_EQUAL(1, contract.getDefinedFunctions().size());
BOOST_CHECK_EQUAL(getSourcePart(*contract.getDefinedFunctions().front()), BOOST_CHECK_EQUAL(getSourcePart(*contract.getDefinedFunctions().front()),
"function f(uint256 a)constant returns(hash8 x){}"); "function f(uint256 a)constant returns(bytes1 x){}");
} }
BOOST_AUTO_TEST_CASE(multiple_functions) BOOST_AUTO_TEST_CASE(multiple_functions)
@ -128,15 +128,15 @@ BOOST_AUTO_TEST_CASE(inheritance)
char const* sourceCode = char const* sourceCode =
" contract Base { \n" " contract Base { \n"
" function baseFunction(uint p) returns (uint i) { return p; } \n" " function baseFunction(uint p) returns (uint i) { return p; } \n"
" event baseEvent(string32 indexed evtArgBase); \n" " event baseEvent(bytes32 indexed evtArgBase); \n"
" } \n" " } \n"
" contract Derived is Base { \n" " contract Derived is Base { \n"
" function derivedFunction(string32 p) returns (string32 i) { return p; } \n" " function derivedFunction(bytes32 p) returns (bytes32 i) { return p; } \n"
" event derivedEvent(uint indexed evtArgDerived); \n" " event derivedEvent(uint indexed evtArgDerived); \n"
" }"; " }";
ContractDefinition const& contract = checkInterface(sourceCode); ContractDefinition const& contract = checkInterface(sourceCode);
set<string> expectedFunctions({"function baseFunction(uint256 p)returns(uint256 i){}", set<string> expectedFunctions({"function baseFunction(uint256 p)returns(uint256 i){}",
"function derivedFunction(string32 p)returns(string32 i){}"}); "function derivedFunction(bytes32 p)returns(bytes32 i){}"});
BOOST_REQUIRE_EQUAL(2, contract.getDefinedFunctions().size()); BOOST_REQUIRE_EQUAL(2, contract.getDefinedFunctions().size());
BOOST_CHECK(expectedFunctions == set<string>({getSourcePart(*contract.getDefinedFunctions().at(0)), BOOST_CHECK(expectedFunctions == set<string>({getSourcePart(*contract.getDefinedFunctions().at(0)),
getSourcePart(*contract.getDefinedFunctions().at(1))})); getSourcePart(*contract.getDefinedFunctions().at(1))}));

Loading…
Cancel
Save