Browse Source

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

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

4
mix/qml/StateListModel.qml

@ -193,7 +193,9 @@ Item {
accounts: [] 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 //add all stdc contracts
for (var i = 0; i < contractLibrary.model.count; i++) { 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 "../../qml"
import "js/TestDebugger.js" as TestDebugger import "js/TestDebugger.js" as TestDebugger
import "js/TestTutorial.js" as TestTutorial import "js/TestTutorial.js" as TestTutorial
import "js/TestMiner.js" as TestMiner
import "js/TestProject.js" as TestProject import "js/TestProject.js" as TestProject
TestCase TestCase
@ -75,6 +76,8 @@ TestCase
function test_dbg_transactionWithParameter() { TestDebugger.test_transactionWithParameter(); } function test_dbg_transactionWithParameter() { TestDebugger.test_transactionWithParameter(); }
function test_dbg_constructorParameters() { TestDebugger.test_constructorParameters(); } function test_dbg_constructorParameters() { TestDebugger.test_constructorParameters(); }
function test_dbg_arrayParametersAndStorage() { TestDebugger.test_arrayParametersAndStorage(); } 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(); } 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