Browse Source

- Add Test Case

cl-refactor
yann300 10 years ago
parent
commit
54a17fc85c
  1. 4
      mix/ClientModel.cpp
  2. 12
      mix/qml/TransactionDialog.qml
  3. 1
      mix/test/qml/TestMain.qml
  4. 44
      mix/test/qml/js/TestDebugger.js
  5. 2
      mix/test/qml/js/TestTutorial.js

4
mix/ClientModel.cpp

@ -282,9 +282,9 @@ void ClientModel::executeSequence(vector<TransactionSettings> const& _sequence,
{ {
QSolidityType const* type = p->type(); QSolidityType const* type = p->type();
QVariant value = transaction.parameterValues.value(p->name()); QVariant value = transaction.parameterValues.value(p->name());
if (type->type().type == SolidityType::Type::Address && value.toString().startsWith("<")) if (type->type().type == SolidityType::Type::Address && value.toString().startsWith("<") && value.toString().endsWith(">"))
{ {
QStringList nb = value.toString().remove("<").remove(">").split(" - ") ; QStringList nb = value.toString().remove("<").remove(">").split(" - ");
value = QVariant(QString::fromStdString("0x" + toHex(deployedContracts.at(nb.back().toInt()).ref()))); value = QVariant(QString::fromStdString("0x" + toHex(deployedContracts.at(nb.back().toInt()).ref())));
} }
encoder.encode(value, type->type()); encoder.encode(value, type->type());

12
mix/qml/TransactionDialog.qml

@ -101,6 +101,18 @@ Dialog {
} }
function selectContract(contractName)
{
for (var k = 0; k < contractsModel.count; k++)
{
if (contractsModel.get(k).cid === contractName)
{
contractComboBox.currentIndex = k;
break;
}
}
}
function selectFunction(functionId) function selectFunction(functionId)
{ {
var functionIndex = -1; var functionIndex = -1;

1
mix/test/qml/TestMain.qml

@ -96,6 +96,7 @@ TestCase
function test_dbg_arrayParametersAndStorage() { TestDebugger.test_arrayParametersAndStorage(); } function test_dbg_arrayParametersAndStorage() { TestDebugger.test_arrayParametersAndStorage(); }
function test_dbg_solidity() { TestDebugger.test_solidityDebugging(); } function test_dbg_solidity() { TestDebugger.test_solidityDebugging(); }
function test_dbg_vm() { TestDebugger.test_vmDebugging(); } function test_dbg_vm() { TestDebugger.test_vmDebugging(); }
function test_dbg_ctrTypeAsParam() { TestDebugger.test_ctrTypeAsParam(); }
function test_miner_getDefaultiner() { TestMiner.test_getDefaultMiner(); } function test_miner_getDefaultiner() { TestMiner.test_getDefaultMiner(); }
function test_miner_selectMiner() { TestMiner.test_selectMiner(); } function test_miner_selectMiner() { TestMiner.test_selectMiner(); }
function test_miner_mine() { TestMiner.test_mine(); } function test_miner_mine() { TestMiner.test_mine(); }

44
mix/test/qml/js/TestDebugger.js

@ -203,3 +203,47 @@ function test_vmDebugging()
tryCompare(mainApplication.mainContent.rightPane.vmMemory.listModel, "length", 0); tryCompare(mainApplication.mainContent.rightPane.vmMemory.listModel, "length", 0);
} }
function test_ctrTypeAsParam()
{
newProject();
editContract(
"contract C1 {\r " +
" function get() returns (uint256)\r " +
" {\r " +
" return 159;\r " +
" }\r " +
"}\r" +
"contract C2 {\r " +
" C1 c1;\r " +
" function getFromC1() returns (uint256)\r " +
" {\r " +
" return c1.get();\r " +
" }\r " +
" function C2(C1 _c1)\r" +
" {\r " +
" c1 = _c1;\r" +
" }\r " +
"}");
mainApplication.projectModel.stateListModel.editState(0); //C1 ctor already added
mainApplication.projectModel.stateDialog.model.addTransaction();
var transactionDialog = mainApplication.projectModel.stateDialog.transactionDialog;
ts.waitForRendering(transactionDialog, 3000);
transactionDialog.selectContract("C2");
transactionDialog.selectFunction("C2");
transactionDialog.acceptAndClose();
mainApplication.projectModel.stateDialog.model.addTransaction();
transactionDialog = mainApplication.projectModel.stateDialog.transactionDialog;
ts.waitForRendering(transactionDialog, 3000);
transactionDialog.selectContract("C2");
transactionDialog.selectFunction("getFromC1");
clickElement(transactionDialog, 406, 340);
clickElement(transactionDialog, 406, 366);
transactionDialog.acceptAndClose();
mainApplication.projectModel.stateDialog.acceptAndClose();
mainApplication.mainContent.startQuickDebugging();
if (!ts.waitForSignal(mainApplication.clientModel, "debugDataReady(QObject*)", 5000))
fail("Error running transaction");
tryCompare(mainApplication.mainContent.rightPane.transactionLog.transactionModel.get(4), "returned", "(159)");
}

2
mix/test/qml/js/TestTutorial.js

@ -52,7 +52,7 @@ function test_tutorial()
transactionDialog.selectFunction("setRating"); transactionDialog.selectFunction("setRating");
clickElement(transactionDialog, 200, 310); clickElement(transactionDialog, 200, 310);
ts.typeString("Titanic", transactionDialog); ts.typeString("Titanic", transactionDialog);
clickElement(transactionDialog, 200, 330); clickElement(transactionDialog, 200, 350);
ts.typeString("2", transactionDialog); ts.typeString("2", transactionDialog);
transactionDialog.acceptAndClose(); transactionDialog.acceptAndClose();
mainApplication.projectModel.stateDialog.acceptAndClose(); mainApplication.projectModel.stateDialog.acceptAndClose();

Loading…
Cancel
Save