Browse Source

skip web preview for contracts which are not deployed yet

cl-refactor
arkpar 10 years ago
parent
commit
59d9fb49ff
  1. 3
      mix/HttpServer.cpp
  2. 13
      mix/qml/WebPreview.qml
  3. 9
      mix/test/qml/TestMain.qml
  4. 9
      mix/test/qml/js/TestDebugger.js
  5. 3
      mix/test/qml/js/TestProject.js

3
mix/HttpServer.cpp

@ -110,7 +110,10 @@ void HttpServer::updateListening()
return;
if (!QTcpServer::listen(QHostAddress::LocalHost, m_port))
{
errorStringChanged();
return;
}
if (m_port != QTcpServer::serverPort())
{

13
mix/qml/WebPreview.qml

@ -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) + ")");
}

9
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");

9
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)");
}

3
mix/test/qml/js/TestProject.js

@ -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);

Loading…
Cancel
Save