Skip to content

Commit

Permalink
skip web preview for contracts which are not deployed yet
Browse files Browse the repository at this point in the history
  • Loading branch information
arkpar committed Apr 15, 2015
1 parent 3911c2f commit 872c6c4
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 13 deletions.
3 changes: 3 additions & 0 deletions HttpServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ void HttpServer::updateListening()
return;

if (!QTcpServer::listen(QHostAddress::LocalHost, m_port))
{
errorStringChanged();
return;
}

if (m_port != QTcpServer::serverPort())
{
Expand Down
13 changes: 8 additions & 5 deletions qml/WebPreview.qml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ Item {
var contracts = {};
for (var c in codeModel.contracts) {
var contract = codeModel.contracts[c];
contracts[c] = {
name: contract.contract.name,
address: clientModel.contractAddresses[contract.contract.name],
interface: JSON.parse(contract.contractInterface),
};
var address = clientModel.contractAddresses[contract.contract.name];
if (address) {
contracts[c] = {
name: contract.contract.name,
address: address,
interface: JSON.parse(contract.contractInterface),
};
}
}
webView.runJavaScript("updateContracts(" + JSON.stringify(contracts) + ")");
}
Expand Down
9 changes: 9 additions & 0 deletions test/qml/TestMain.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
9 changes: 3 additions & 6 deletions test/qml/js/TestDebugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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)");
}
Expand Down Expand Up @@ -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)");
}
Expand Down
3 changes: 1 addition & 2 deletions test/qml/js/TestProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ function test_contractRename()
tryCompare(mainApplication.mainContent.projectNavigator.sections.itemAt(0).model.get(0), "name", "Contract");
editContract("contract Renamed {}");
mainApplication.mainContent.startQuickDebugging();
if (!ts.waitForSignal(mainApplication.clientModel, "runComplete()", 5000))
fail("Error running transaction");
waitForExecution();
wait(1000);
tryCompare(mainApplication.mainContent.projectNavigator.sections.itemAt(0).model.get(0), "name", "Renamed");
mainApplication.projectModel.stateListModel.editState(0);
Expand Down

0 comments on commit 872c6c4

Please sign in to comment.