Browse Source

Merge pull request #1618 from yann300/bugFix

Mix - Test Cases for Miner Selection.
cl-refactor
Arkadiy Paronyan 10 years ago
parent
commit
b1892ee881
  1. 17
      mix/qml/StateDialog.qml
  2. 4
      mix/qml/StateListModel.qml
  3. 3
      mix/test/qml/TestMain.qml
  4. 20
      mix/test/qml/js/TestMiner.js

17
mix/qml/StateDialog.qml

@ -22,6 +22,8 @@ Dialog {
property alias isDefault: defaultCheckBox.checked
property alias model: transactionsModel
property alias transactionDialog: transactionDialog
property alias minerComboBox: comboMiner
property alias newAccAction: newAccountAction
property int stateIndex
property var stateTransactions: []
property var stateAccounts: []
@ -46,12 +48,11 @@ Dialog {
accountsModel.clear();
stateAccounts = [];
var miner = 0;
for (var k = 0; k < item.accounts.length; k++)
{
accountsModel.append(item.accounts[k]);
stateAccounts.push(item.accounts[k]);
if (item.accounts[k].name === item.miner.name)
if (item.miner && item.accounts[k].name === item.miner.name)
miner = k;
}
@ -91,6 +92,7 @@ Dialog {
}
return item;
}
contentItem: Rectangle {
color: stateDialogStyle.generic.backgroundColor
Rectangle {
@ -138,6 +140,7 @@ Dialog {
Button
{
id: newAccountButton
anchors.top: accountsLabel.bottom
anchors.topMargin: 10
iconSource: "qrc:/qml/img/plus.png"
@ -148,10 +151,16 @@ Dialog {
id: newAccountAction
tooltip: qsTr("Add new Account")
onTriggered:
{
add();
}
function add()
{
var account = stateListModel.newAccount("1000000", QEther.Ether);
stateAccounts.push(account);
accountsModel.append(account);
return account;
}
}
}
@ -194,8 +203,12 @@ Dialog {
alertAlreadyUsed.open();
else
{
if (stateAccounts[styleData.row].name === comboMiner.currentText)
comboMiner.currentIndex = 0;
stateAccounts.splice(styleData.row, 1);
accountsModel.remove(styleData.row);
comboMiner.model = stateAccounts;
comboMiner.update();
}
}
}

4
mix/qml/StateListModel.qml

@ -193,7 +193,9 @@ Item {
accounts: []
};
item.accounts.push(newAccount("1000000", QEther.Ether, defaultAccount));
var account = newAccount("1000000", QEther.Ether, defaultAccount)
item.accounts.push(account);
item.miner = account;
//add all stdc contracts
for (var i = 0; i < contractLibrary.model.count; i++) {

3
mix/test/qml/TestMain.qml

@ -4,6 +4,7 @@ import org.ethereum.qml.TestService 1.0
import "../../qml"
import "js/TestDebugger.js" as TestDebugger
import "js/TestTutorial.js" as TestTutorial
import "js/TestMiner.js" as TestMiner
import "js/TestProject.js" as TestProject
TestCase
@ -75,6 +76,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_miner_getDefaultiner() { TestMiner.test_getDefaultMiner(); }
function test_miner_selectMiner() { TestMiner.test_selectMiner(); }
function test_project_contractRename() { TestProject.test_contractRename(); }
}

20
mix/test/qml/js/TestMiner.js

@ -0,0 +1,20 @@
function test_getDefaultMiner()
{
newProject();
var state = mainApplication.projectModel.stateListModel.get(0);
compare(state.miner.secret, "cb73d9408c4720e230387d956eb0f829d8a4dd2c1055f96257167e14e7169074");
}
function test_selectMiner()
{
newProject();
mainApplication.projectModel.stateListModel.editState(0);
var account = mainApplication.projectModel.stateDialog.newAccAction.add();
account = mainApplication.projectModel.stateDialog.newAccAction.add();
mainApplication.projectModel.stateDialog.minerComboBox.currentIndex = 2;
ts.waitForRendering(mainApplication.projectModel.stateDialog.minerComboBox, 3000);
mainApplication.projectModel.stateDialog.acceptAndClose();
var state = mainApplication.projectModel.stateListModel.get(0);
compare(state.miner.secret, account.secret);
}
Loading…
Cancel
Save