Browse Source

Merge branch 'develop' of github.com:ethereum/cpp-ethereum into develop

cl-refactor
Gav Wood 10 years ago
parent
commit
1f1b9719cc
  1. 7
      cmake/FindCURL.cmake
  2. 4
      eth/CMakeLists.txt
  3. 4
      mix/ClientModel.cpp
  4. 15
      mix/HttpServer.cpp
  5. 2
      mix/HttpServer.h
  6. 8
      mix/qml/DebugInfoList.qml
  7. 4
      mix/qml/Debugger.qml
  8. 1
      mix/qml/NewProjectDialog.qml
  9. 6
      mix/qml/WebPreview.qml
  10. 11
      mix/test/qml/TestMain.qml
  11. 73
      mix/test/qml/js/TestDebugger.js
  12. 4
      mix/test/qml/js/TestProject.js

7
cmake/FindCURL.cmake

@ -39,6 +39,13 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(CURL_LIBRARIES optimized ${CURL_LIBRARIES} debug ${CURL_LIBRARY_DEBUG})
# prepare dlls
string(REPLACE ".lib" ".dll" CURL_DLL ${CURL_LIBRARY})
string(REPLACE "/lib/" "/bin/" CURL_DLL ${CURL_DLL})
string(REPLACE ".lib" ".dll" CURL_DLL_DEBUG ${CURL_LIBRARY_DEBUG})
string(REPLACE "/lib/" "/bin/" CURL_DLL_DEBUG ${CURL_DLL_DEBUG})
set(CURL_DLLS optimized ${CURL_DLL} debug ${CURL_DLL_DEBUG})
endif()
# handle the QUIETLY and REQUIRED arguments and set CURL_FOUND to TRUE

4
eth/CMakeLists.txt

@ -22,8 +22,10 @@ if (READLINE_FOUND)
endif()
if (JSONRPC)
target_link_libraries(${EXECUTABLE} ${JSON_RPC_CPP_CLIENT_LIBRARIES})
target_link_libraries(${EXECUTABLE} web3jsonrpc)
target_link_libraries(${EXECUTABLE} ${JSON_RPC_CPP_CLIENT_LIBRARIES})
target_link_libraries(${EXECUTABLE} ${CURL_LIBRARIES})
eth_copy_dlls(${EXECUTABLE} CURL_DLLS)
endif()
target_link_libraries(${EXECUTABLE} webthree)

4
mix/ClientModel.cpp

@ -401,9 +401,9 @@ void ClientModel::showDebuggerForTransaction(ExecutionResult const& _t)
AssemblyItem const& prevInstruction = codeItems[s.codeIndex][prevInstructionIndex];
auto functionIter = contract->functions().find(LocationPair(instruction.getLocation().start, instruction.getLocation().end));
if (functionIter != contract->functions().end() && ((prevInstruction.getJumpType() == AssemblyItem::JumpType::IntoFunction) || solCallStack.empty()))
solCallStack.push_back(QVariant::fromValue(functionIter.value()));
solCallStack.push_front(QVariant::fromValue(functionIter.value()));
else if (prevInstruction.getJumpType() == AssemblyItem::JumpType::OutOfFunction && !solCallStack.empty())
solCallStack.pop_back();
solCallStack.pop_front();
}
//format solidity context values

15
mix/HttpServer.cpp

@ -106,8 +106,21 @@ void HttpServer::updateListening()
if (this->isListening())
this->close();
if (!m_listen || QTcpServer::listen(QHostAddress::LocalHost, m_port))
if (!m_listen)
return;
if (!QTcpServer::listen(QHostAddress::LocalHost, m_port))
{
errorStringChanged();
return;
}
if (m_port != QTcpServer::serverPort())
{
m_port = QTcpServer::serverPort();
emit portChanged(m_port);
emit urlChanged(url());
}
}
void HttpServer::incomingConnection(qintptr _socket)

2
mix/HttpServer.h

@ -100,7 +100,7 @@ protected:
signals:
void clientConnected(HttpRequest* _request);
void errorStringChanged(QString const& _errorString);
void errorStringChanged();
void urlChanged(QUrl const& _url);
void portChanged(int _port);
void listenChanged(bool _listen);

8
mix/qml/DebugInfoList.qml

@ -33,8 +33,12 @@ ColumnLayout {
if (storageContainer.parent.parent.height === 25)
storageContainer.collapse();
else
{
if (storageContainer.parent.parent.height === 0)
storageContainer.parent.parent.height = 200;
storageContainer.expand();
}
}
RowLayout {
height: 25
@ -63,6 +67,8 @@ ColumnLayout {
if (collapsed)
{
storageContainer.expand();
if (storedHeight <= 25)
storedHeight = 200;
storageContainer.parent.parent.height = storedHeight;
}
else
@ -105,8 +111,6 @@ ColumnLayout {
height: parent.height - 6
onHeightChanged: {
if (height <= 0 && collapsible) {
if (storedHeight <= 0)
storedHeight = 200;
storageContainer.collapse();
}
else if (height > 0 && collapsed) {

4
mix/qml/Debugger.qml

@ -17,6 +17,10 @@ Rectangle {
property alias solLocals: solLocals
property alias solStorage: solStorage
property alias solCallStack: solCallStack
property alias vmCallStack: callStack
property alias vmStorage: storage
property alias vmMemory: memoryDump
property alias vmCallData: callDataDump
signal debugExecuteLocation(string documentId, var location)
property string compilationErrorMessage
property bool assemblyMode: false

1
mix/qml/NewProjectDialog.qml

@ -28,6 +28,7 @@ Item
Dialog {
id: newProjectWin
modality: Qt.ApplicationModal
title: qsTr("New Project");
width: 640
height: 120

6
mix/qml/WebPreview.qml

@ -40,12 +40,15 @@ Item {
var contracts = {};
for (var c in codeModel.contracts) {
var contract = codeModel.contracts[c];
var address = clientModel.contractAddresses[contract.contract.name];
if (address) {
contracts[c] = {
name: contract.contract.name,
address: clientModel.contractAddresses[contract.contract.name],
address: address,
interface: JSON.parse(contract.contractInterface),
};
}
}
webView.runJavaScript("updateContracts(" + JSON.stringify(contracts) + ")");
}
@ -150,7 +153,6 @@ Item {
id: httpServer
listen: true
accept: true
port: 8893
onClientConnected: {
var urlPath = _request.url.toString();
if (urlPath.indexOf("/rpc/") === 0)

11
mix/test/qml/TestMain.qml

@ -50,12 +50,21 @@ TestCase
function editContract(c)
{
if (mainApplication.codeModel.compiling)
ts.waitForSignal(mainApplication.codeModel, "compilationComplete()", 5000);
mainApplication.mainContent.codeEditor.getEditor("contract.sol").setText(c);
if (!ts.waitForSignal(mainApplication.codeModel, "compilationComplete()", 5000))
fail("not compiled");
ts.keyPressChar(mainApplication, "S", Qt.ControlModifier, 200); //Ctrl+S
}
function waitForExecution()
{
while (mainApplication.clientModel.running)
ts.waitForSignal(mainApplication.clientModel, "runComplete()", 5000);
}
function editHtml(c)
{
mainApplication.projectModel.openDocument("index.html");
@ -76,6 +85,8 @@ TestCase
function test_dbg_transactionWithParameter() { TestDebugger.test_transactionWithParameter(); }
function test_dbg_constructorParameters() { TestDebugger.test_constructorParameters(); }
function test_dbg_arrayParametersAndStorage() { TestDebugger.test_arrayParametersAndStorage(); }
function test_dbg_solidity() { TestDebugger.test_solidityDebugging(); }
function test_dbg_vm() { TestDebugger.test_vmDebugging(); }
function test_miner_getDefaultiner() { TestMiner.test_getDefaultMiner(); }
function test_miner_selectMiner() { TestMiner.test_selectMiner(); }
function test_project_contractRename() { TestProject.test_contractRename(); }

73
mix/test/qml/js/TestDebugger.js

@ -14,8 +14,7 @@ function test_defaultTransactionSequence()
" uint z;\r" +
"}\r"
);
if (!ts.waitForSignal(mainApplication.clientModel, "runComplete()", 5000))
fail("Error running transaction");
waitForExecution();
tryCompare(mainApplication.mainContent.rightPane.transactionLog.transactionModel, "count", 3);
}
@ -47,8 +46,7 @@ function test_transactionWithParameter()
transactionDialog.acceptAndClose();
mainApplication.projectModel.stateDialog.acceptAndClose();
mainApplication.mainContent.startQuickDebugging();
if (!ts.waitForSignal(mainApplication.clientModel, "runComplete()", 5000))
fail("Error running transaction");
waitForExecution();
tryCompare(mainApplication.mainContent.rightPane.transactionLog.transactionModel, "count", 5);
tryCompare(mainApplication.mainContent.rightPane.transactionLog.transactionModel.get(4), "returned", "(442)");
}
@ -79,8 +77,7 @@ function test_constructorParameters()
transactionDialog.acceptAndClose();
mainApplication.projectModel.stateDialog.acceptAndClose();
mainApplication.mainContent.startQuickDebugging();
if (!ts.waitForSignal(mainApplication.clientModel, "runComplete()", 5000))
fail("Error running transaction");
waitForExecution();
tryCompare(mainApplication.mainContent.rightPane.transactionLog.transactionModel, "count", 4);
tryCompare(mainApplication.mainContent.rightPane.transactionLog.transactionModel.get(3), "returned", "(442)");
}
@ -137,3 +134,67 @@ function test_arrayParametersAndStorage()
tryCompare(mainApplication.mainContent.rightPane.solStorage.item.value, "s", "42");
tryCompare(mainApplication.mainContent.rightPane.solCallStack.listModel, 0, "setMV");
}
function test_solidityDebugging()
{
newProject();
editContract(
"contract Contract {\r " +
" function add(uint256 a, uint256 b) returns (uint256)\r " +
" {\r " +
" return a + b;\r " +
" }\r " +
" function Contract()\r " +
" {\r " +
" uint256 local = add(42, 34);\r " +
" storage = local;\r " +
" }\r " +
" uint256 storage;\r " +
"}");
mainApplication.mainContent.startQuickDebugging();
if (!ts.waitForSignal(mainApplication.clientModel, "debugDataReady(QObject*)", 5000))
fail("Error running transaction");
tryCompare(mainApplication.mainContent.rightPane.debugSlider, "maximumValue", 20);
tryCompare(mainApplication.mainContent.rightPane.debugSlider, "value", 0);
mainApplication.mainContent.rightPane.debugSlider.value = 13;
tryCompare(mainApplication.mainContent.rightPane.solCallStack.listModel, 0, "add");
tryCompare(mainApplication.mainContent.rightPane.solCallStack.listModel, 1, "Contract");
tryCompare(mainApplication.mainContent.rightPane.solLocals.item.value, "local", "0");
tryCompare(mainApplication.mainContent.rightPane.solStorage.item.value, "storage", undefined);
mainApplication.mainContent.rightPane.debugSlider.value = 19;
tryCompare(mainApplication.mainContent.rightPane.solLocals.item.value, "local", "76");
tryCompare(mainApplication.mainContent.rightPane.solStorage.item.value, "storage", "76");
}
function test_vmDebugging()
{
newProject();
editContract(
"contract Contract {\r " +
" function add(uint256 a, uint256 b) returns (uint256)\r " +
" {\r " +
" return a + b;\r " +
" }\r " +
" function Contract()\r " +
" {\r " +
" uint256 local = add(42, 34);\r " +
" storage = local;\r " +
" }\r " +
" uint256 storage;\r " +
"}");
mainApplication.mainContent.startQuickDebugging();
if (!ts.waitForSignal(mainApplication.clientModel, "debugDataReady(QObject*)", 5000))
fail("Error running transaction");
mainApplication.mainContent.rightPane.assemblyMode = !mainApplication.mainContent.rightPane.assemblyMode;
tryCompare(mainApplication.mainContent.rightPane.debugSlider, "maximumValue", 41);
tryCompare(mainApplication.mainContent.rightPane.debugSlider, "value", 0);
mainApplication.mainContent.rightPane.debugSlider.value = 35;
tryCompare(mainApplication.mainContent.rightPane.vmCallStack.listModel, 0, mainApplication.clientModel.contractAddresses["Contract"].substring(2));
tryCompare(mainApplication.mainContent.rightPane.vmStorage.listModel, 0, "@ 0 (0x0) 76 (0x4c)");
tryCompare(mainApplication.mainContent.rightPane.vmMemory.listModel, "length", 0);
}

4
mix/test/qml/js/TestProject.js

@ -3,8 +3,8 @@ function test_contractRename()
newProject();
tryCompare(mainApplication.mainContent.projectNavigator.sections.itemAt(0).model.get(0), "name", "Contract");
editContract("contract Renamed {}");
if (!ts.waitForSignal(mainApplication.clientModel, "runComplete()", 5000))
fail("Error running transaction");
mainApplication.mainContent.startQuickDebugging();
waitForExecution();
wait(1000);
tryCompare(mainApplication.mainContent.projectNavigator.sections.itemAt(0).model.get(0), "name", "Renamed");
mainApplication.projectModel.stateListModel.editState(0);

Loading…
Cancel
Save