public void SetUp() { var ui = new TestUi(); Manager = new Station( ui, SystemTestData.Key, SystemTestData.Password, SystemTestData.ManagerPort, "CommandsTestsManagerTestVoters.sqlite", "CommandsTestsManagerLogTestDb.sqlite"); NewPeer = new Station( ui, SystemTestData.PeerPort, "CommandsTestsManagerPeerTestDb.sqlite"); Manager.Manager = Manager.Address; Station.Manager = Manager.Address; NewPeer.Manager = Manager.Address; Manager.AddPeer(Station.Address, new AsymmetricKey(Station.Crypto.KeyPair.Public)); Station.AddPeer(Manager.Address, new AsymmetricKey(Manager.Crypto.KeyPair.Public)); Station.AddPeer(NewPeer.Address, new AsymmetricKey(NewPeer.Crypto.KeyPair.Public)); Station.Crypto.VoterDataEncryptionKey = Manager.Crypto.VoterDataEncryptionKey; NewPeer.AddPeer(Manager.Address, new AsymmetricKey(Manager.Crypto.KeyPair.Public)); }
/// <summary> /// The exchange public keys test. /// </summary> [Test] public void ExchangePublicKeysTest() { var ui = new TestUi(); using ( var manager = new Station( ui, SystemTestData.Key, SystemTestData.Password, SystemTestData.ManagerPort, "ExchangePublicKeysTestManagerVoters.sqlite", "ExchangePublicKeysTestManagerLog.sqlite")) using (var station = new Station(ui, SystemTestData.StationPort, "ExchangePublicKeysTestStationVoters.sqlite")) { Assert.That(!manager.Peers.ContainsKey(station.Address)); Assert.That(!station.Peers.ContainsKey(manager.Address)); manager.ExchangePublicKeys(station.Address); // Wait some time while they synchronize. Thread.Sleep(3000); Assert.That(manager.Peers.ContainsKey(station.Address)); Assert.That(station.Peers.ContainsKey(manager.Address)); } File.Delete("ExchangePublicKeysTestManagerVoters.sqlite"); File.Delete("ExchangePublicKeysTestStationVoters.sqlite"); File.Delete("ExchangePublicKeysTestManagerLog.sqlite"); }
public void PublicKeyExchangeCommandTest() { var ui = new TestUi(); using ( var manager = new Station( ui, SystemTestData.Key, SystemTestData.Password, SystemTestData.ManagerPort, "CommandsTestPublicKeyExchangeCommandTestManagerVoters.sqlite", "CommandsTestPublicKeyExchangeCommandTestManagerLog.sqlite")) using ( var receiver = new Station( ui, SystemTestData.StationPort, "CommandsTestPublicKeyExchangeCommandTestReceiverVoters.sqlite")) { var cmd = new PublicKeyExchangeCommand(manager, receiver.Address); Assert.That(cmd.Sender.Equals(manager.Address)); Assert.That(!receiver.Peers.ContainsKey(manager.Address)); Assert.Null(receiver.Manager); cmd.Execute(receiver); Assert.That(receiver.Peers.ContainsKey(manager.Address)); Assert.That(receiver.Manager.Equals(manager.Address)); } File.Delete("CommandsTestPublicKeyExchangeCommandTestManagerVoters.sqlite"); File.Delete("CommandsTestPublicKeyExchangeCommandTestManagerLog.sqlite"); File.Delete("CommandsTestPublicKeyExchangeCommandTestReceiverVoters.sqlite"); }
/// <summary> /// The start new manager election test. /// </summary> [Test] public void StartNewManagerElectionTest() { var ui = new TestUi(); using ( var manager = new Station( ui, SystemTestData.Key, SystemTestData.Password, SystemTestData.ManagerPort, "ExchangePublicKeysTestManagerVoters.sqlite", "ExchangePublicKeysTestManagerLog.sqlite")) { AsymmetricKey pswd = manager.Crypto.VoterDataEncryptionKey; using ( var station = new Station(ui, SystemTestData.StationPort, "ExchangePublicKeysTestStationVoters.sqlite") { Manager = manager.Address, Crypto = { VoterDataEncryptionKey = pswd }, MasterPassword = manager.MasterPassword }) using ( var station2 = new Station(ui, SystemTestData.PeerPort, "ExchangePublicKeysTestStation2Voters.sqlite") { Manager = manager.Address, Crypto = { VoterDataEncryptionKey = pswd }, MasterPassword = manager.MasterPassword }) { station.Logger = new Logger(station, "ExchangePublicKeysTestStationLog.sqlite"); station2.Logger = new Logger(station2, "ExchangePublicKeysTestStation2Log.sqlite"); Assert.That(station.Manager.Equals(manager.Address)); Assert.That(station2.Manager.Equals(manager.Address)); Assert.That(station2.Manager.Equals(station.Manager)); station.AddPeer(manager.Address, new AsymmetricKey(manager.Crypto.KeyPair.Public)); station.AddPeer(station2.Address, new AsymmetricKey(station2.Crypto.KeyPair.Public)); station2.AddPeer(manager.Address, new AsymmetricKey(manager.Crypto.KeyPair.Public)); station2.AddPeer(station.Address, new AsymmetricKey(station.Crypto.KeyPair.Public)); manager.StopListening(); station.StartNewManagerElection(); Thread.Sleep(5000); Assert.That(!station.Manager.Equals(manager.Address)); Assert.That(!station2.Manager.Equals(manager.Address)); Assert.That(station2.Manager.Equals(station.Manager)); } } File.Delete("ExchangePublicKeysTestManagerVoters.sqlite"); File.Delete("ExchangePublicKeysTestStationVoters.sqlite"); File.Delete("ExchangePublicKeysTestStation2Voters.sqlite"); File.Delete("ExchangePublicKeysTestManagerLog.sqlite"); File.Delete("ExchangePublicKeysTestStationLog.sqlite"); File.Delete("ExchangePublicKeysTestStation2Log.sqlite"); }
public void PublicKeyExchangeCommandTest() { var ui = new TestUi(); using (var manager = new Station(ui, "dataEncryption.key", "pw", 65432, "CommandsTestPublicKeyExchangeCommandTestManagerVoters.sqlite", "CommandsTestPublicKeyExchangeCommandTestManagerLog.sqlite")) using (var receiver = new Station(ui, 65433, "CommandsTestPublicKeyExchangeCommandTestReceiverVoters.sqlite")) { var cmd = new PublicKeyExchangeCommand(manager); Assert.That(cmd.Sender.Equals(manager.Address)); Assert.That(!receiver.Peers.ContainsKey(manager.Address)); Assert.That(receiver.Manager == null); cmd.Execute(receiver); Assert.That(receiver.Peers.ContainsKey(manager.Address)); Assert.That(receiver.Manager.Equals(manager.Address)); } File.Delete("CommandsTestPublicKeyExchangeCommandTestManagerVoters.sqlite"); File.Delete("CommandsTestPublicKeyExchangeCommandTestManagerLog.sqlite"); File.Delete("CommandsTestPublicKeyExchangeCommandTestReceiverVoters.sqlite"); }
public void ExchangePublicKeysTest() { var ui = new TestUi(); using (var manager = new Station(ui, "dataEncryption.key", "sup homey", 63554, "ExchangePublicKeysTestManagerVoters.sqlite", "ExchangePublicKeysTestManagerLog.sqlite")) using (var station = new Station(ui, 63555, "ExchangePublicKeysTestStationVoters.sqlite")) { Assert.That(!manager.Peers.ContainsKey(station.Address)); Assert.That(!station.Peers.ContainsKey(manager.Address)); manager.ExchangePublicKeys(station.Address); //Wait some time while they synchronize. Thread.Sleep(3000); Assert.That(manager.Peers.ContainsKey(station.Address)); Assert.That(station.Peers.ContainsKey(manager.Address)); } File.Delete("ExchangePublicKeysTestManagerVoters.sqlite"); File.Delete("ExchangePublicKeysTestStationVoters.sqlite"); File.Delete("ExchangePublicKeysTestManagerLog.sqlite"); }
public void SetUp() { var ui = new TestUi(); Sender = new Station(ui, "dataEncryption.key", "yo boii", 62345, "CommunicatorTestsSenderVoters.sqlite", "CommunicatorTestsSenderLog.sqlite"); Receiver = new Station(ui, 62346, "CommunicatorTestsReceiverVoters.sqlite") { Manager = Sender.Address, Crypto = { VoterDataEncryptionKey = Sender.Crypto.VoterDataEncryptionKey }, MasterPassword = Sender.Crypto.Hash(Bytes.From("_½æøåÆÅا.^\\,QBsa(/YHh*^#3£()cZ?\\}`|`´ '*jJxCvZ;;;<><aQ\\ ><yo boii")) }; //Receiver.Logger = new Logger(Receiver, "CommunicatorTestsReceiverLog.sqlite"); Sender.StopListening(); Receiver.StopListening(); BadEndPoint = new IPEndPoint(Receiver.Address.Address, Receiver.Address.Port + 5); _timer = new Stopwatch(); _timer.Start(); }
public void StartNewManagerElectionTest() { var ui = new TestUi(); using (var manager = new Station(ui, "dataEncryption.key", "sup homey", 63554, "ExchangePublicKeysTestManagerVoters.sqlite", "ExchangePublicKeysTestManagerLog.sqlite")) { var pswd = manager.Crypto.VoterDataEncryptionKey; using (var station = new Station(ui, 63555, "ExchangePublicKeysTestStationVoters.sqlite") { Manager = manager.Address, Crypto = { VoterDataEncryptionKey = pswd }, MasterPassword = manager.MasterPassword }) using (var station2 = new Station(ui, 63556, "ExchangePublicKeysTestStation2Voters.sqlite") { Manager = manager.Address, Crypto = { VoterDataEncryptionKey = pswd }, MasterPassword = manager.MasterPassword }) { station.Logger = new Logger(station, "ExchangePublicKeysTestStationLog.sqlite"); station2.Logger = new Logger(station2, "ExchangePublicKeysTestStation2Log.sqlite"); Assert.That(station.Manager.Equals(manager.Address)); Assert.That(station2.Manager.Equals(manager.Address)); Assert.That(station2.Manager.Equals(station.Manager)); station.AddPeer(manager.Address, manager.Crypto.Keys.Item1); station.AddPeer(station2.Address, station2.Crypto.Keys.Item1); station2.AddPeer(manager.Address, manager.Crypto.Keys.Item1); station2.AddPeer(station.Address, station.Crypto.Keys.Item1); manager.StopListening(); station.StartNewManagerElection(); Thread.Sleep(5000); Assert.That(!station.Manager.Equals(manager.Address)); Assert.That(!station2.Manager.Equals(manager.Address)); Assert.That(station2.Manager.Equals(station.Manager)); } } File.Delete("ExchangePublicKeysTestManagerVoters.sqlite"); File.Delete("ExchangePublicKeysTestStationVoters.sqlite"); File.Delete("ExchangePublicKeysTestStation2Voters.sqlite"); File.Delete("ExchangePublicKeysTestManagerLog.sqlite"); File.Delete("ExchangePublicKeysTestStationLog.sqlite"); File.Delete("ExchangePublicKeysTestStation2Log.sqlite"); }
public void SetUp() { var ui = new TestUi(); Manager = new Station(ui, "dataEncryption.key", "yo boii", 62001, "CommandsTestsManagerVoters.sqlite", "CommandsTestsLog.sqlite"); Station = new Station(ui, 62002, "CommandsTestsStationVoters.sqlite"); NewPeer = new Station(ui, 62003, "CommandsTestsNewPeerVoters.sqlite"); Manager.Manager = Manager.Address; Station.Manager = Manager.Address; NewPeer.Manager = Manager.Address; Manager.AddPeer(Station.Address, Station.Crypto.Keys.Item1); Station.AddPeer(Manager.Address, Manager.Crypto.Keys.Item1); Station.AddPeer(NewPeer.Address, NewPeer.Crypto.Keys.Item1); Station.Crypto.VoterDataEncryptionKey = Manager.Crypto.VoterDataEncryptionKey; NewPeer.AddPeer(Manager.Address, Manager.Crypto.Keys.Item1); }
/// <summary> /// SetUp test helper properties. /// </summary> [SetUp] public void SetUp() { var ui = new TestUi(); Sender = new Station( ui, SystemTestData.Key, SystemTestData.Password, SystemTestData.StationPort, "CommunicatorTestsSenderVoters.sqlite", "CommunicatorTestsSenderLog.sqlite"); Receiver = new Station(ui, SystemTestData.PeerPort, "CommunicatorTestsReceiverVoters.sqlite") { Manager = Sender.Address, Crypto = { VoterDataEncryptionKey = Sender.Crypto.VoterDataEncryptionKey }, MasterPassword = Sender.Crypto.Hash(Bytes.From(SystemTestData.Password)) }; // Receiver.Logger = new Logger(Receiver, "CommunicatorTestsReceiverLog.sqlite"); Sender.StopListening(); Receiver.StopListening(); BadEndPoint = new IPEndPoint(Receiver.Address.Address, Receiver.Address.Port + 5); _timer = new Stopwatch(); _timer.Start(); }
/// <summary> /// The receiver failure test. /// </summary> [Test] public void ReceiverFailureTest() { var ui = new TestUi(); using ( var manager = new Station( ui, SystemTestData.Key, SystemTestData.Password, SystemTestData.ManagerPort, "CommunicatorTestsReceiverFailureTestManagerVoters.sqlite", "CommunicatorTestsReceiverFailureTestManagerLog.sqlite")) { byte[] pswd = manager.Crypto.Hash(Bytes.From(SystemTestData.Password)); using (var peer1 = new Station(ui, SystemTestData.StationPort, "CommunicatorTestsReceiverFailureTestPeer1Voters.sqlite") { Manager = manager.Address, MasterPassword = pswd, Crypto = { VoterDataEncryptionKey = manager.Crypto.VoterDataEncryptionKey } }) using (var peer2 = new Station(ui, SystemTestData.StationPort + 1, "CommunicatorTestsReceiverFailureTestPeer2Voters.sqlite") { Manager = manager.Address, MasterPassword = pswd, Crypto = { VoterDataEncryptionKey = manager.Crypto.VoterDataEncryptionKey } }) using (var peer3 = new Station(ui, SystemTestData.StationPort + 2, "CommunicatorTestsReceiverFailureTestPeer3Voters.sqlite") { Manager = manager.Address, MasterPassword = pswd, Crypto = { VoterDataEncryptionKey = manager.Crypto.VoterDataEncryptionKey } }) { peer1.Logger = new Logger(peer1, "CommunicatorTestsReceiverFailureTestPeer1log.sqlite"); peer2.Logger = new Logger(peer2, "CommunicatorTestsReceiverFailureTestPeer2log.sqlite"); peer3.Logger = new Logger(peer3, "CommunicatorTestsReceiverFailureTestPeer3log.sqlite"); peer1.StopListening(); manager.AddPeer(peer1.Address, new AsymmetricKey(peer1.Crypto.KeyPair.Public)); manager.AddPeer(peer2.Address, new AsymmetricKey(peer2.Crypto.KeyPair.Public)); manager.AddPeer(peer3.Address, new AsymmetricKey(peer3.Crypto.KeyPair.Public)); peer1.AddPeer(peer2.Address, new AsymmetricKey(peer2.Crypto.KeyPair.Public)); peer1.AddPeer(peer3.Address, new AsymmetricKey(peer3.Crypto.KeyPair.Public)); peer1.AddPeer(manager.Address, new AsymmetricKey(manager.Crypto.KeyPair.Public)); peer2.AddPeer(peer1.Address, new AsymmetricKey(peer1.Crypto.KeyPair.Public)); peer2.AddPeer(peer3.Address, new AsymmetricKey(peer3.Crypto.KeyPair.Public)); peer2.AddPeer(manager.Address, new AsymmetricKey(manager.Crypto.KeyPair.Public)); peer3.AddPeer(peer1.Address, new AsymmetricKey(peer1.Crypto.KeyPair.Public)); peer3.AddPeer(peer2.Address, new AsymmetricKey(peer2.Crypto.KeyPair.Public)); peer3.AddPeer(manager.Address, new AsymmetricKey(manager.Crypto.KeyPair.Public)); Assert.That(manager.IsManager); Assert.That(!peer1.IsManager); Assert.That(!peer2.IsManager); Assert.That(!peer3.IsManager); Assert.That(peer2.Peers.ContainsKey(peer1.Address) && !peer2.ElectionInProgress); Assert.That(peer3.Peers.ContainsKey(peer1.Address) && !peer3.ElectionInProgress); Assert.That(manager.Peers.ContainsKey(peer1.Address) && !manager.ElectionInProgress); manager.Communicator.Send(new StartElectionCommand(manager.Address), peer1.Address); Thread.Sleep(5000); Assert.That(!peer2.Peers.ContainsKey(peer1.Address)); Assert.That(!peer3.Peers.ContainsKey(peer1.Address)); Assert.That(!manager.Peers.ContainsKey(peer1.Address)); } } File.Delete("CommunicatorTestsReceiverFailureTestManagerVoters.sqlite"); File.Delete("CommunicatorTestsReceiverFailureTestPeer1Voters.sqlite"); File.Delete("CommunicatorTestsReceiverFailureTestPeer2Voters.sqlite"); File.Delete("CommunicatorTestsReceiverFailureTestPeer3Voters.sqlite"); File.Delete("CommunicatorTestsReceiverFailureTestManagerLog.sqlite"); }
public void ReceiverFailureTest() { var ui = new TestUi(); using (var manager = new Station(ui, "dataEncryption.key", "yo boii", 60000, "CommunicatorTestsReceiverFailureTestManagerVoters.sqlite", "CommunicatorTestsReceiverFailureTestManagerLog.sqlite")) { var pswd = manager.Crypto.Hash(Bytes.From("_½æøåÆÅا.^\\,QBsa(/YHh*^#3£()cZ?\\}`|`´ '*jJxCvZ;;;<><aQ\\ ><yo boii")); using (var peer1 = new Station(ui, 61000, "CommunicatorTestsReceiverFailureTestPeer1Voters.sqlite") { Manager = manager.Address, MasterPassword = pswd, Crypto = { VoterDataEncryptionKey = manager.Crypto.VoterDataEncryptionKey } }) using (var peer2 = new Station(ui, 62000, "CommunicatorTestsReceiverFailureTestPeer2Voters.sqlite") { Manager = manager.Address, MasterPassword = pswd, Crypto = { VoterDataEncryptionKey = manager.Crypto.VoterDataEncryptionKey } }) using (var peer3 = new Station(ui, 63000, "CommunicatorTestsReceiverFailureTestPeer3Voters.sqlite") { Manager = manager.Address, MasterPassword = pswd, Crypto = { VoterDataEncryptionKey = manager.Crypto.VoterDataEncryptionKey } }) { peer1.Logger = new Logger(peer1, "CommunicatorTestsReceiverFailureTestPeer1log.sqlite"); peer2.Logger = new Logger(peer2, "CommunicatorTestsReceiverFailureTestPeer2log.sqlite"); peer3.Logger = new Logger(peer3, "CommunicatorTestsReceiverFailureTestPeer3log.sqlite"); peer1.StopListening(); manager.AddPeer(peer1.Address, peer1.Crypto.Keys.Item1); manager.AddPeer(peer2.Address, peer2.Crypto.Keys.Item1); manager.AddPeer(peer3.Address, peer3.Crypto.Keys.Item1); peer1.AddPeer(peer2.Address, peer2.Crypto.Keys.Item1); peer1.AddPeer(peer3.Address, peer3.Crypto.Keys.Item1); peer1.AddPeer(manager.Address, manager.Crypto.Keys.Item1); peer2.AddPeer(peer1.Address, peer1.Crypto.Keys.Item1); peer2.AddPeer(peer3.Address, peer3.Crypto.Keys.Item1); peer2.AddPeer(manager.Address, manager.Crypto.Keys.Item1); peer3.AddPeer(peer1.Address, peer1.Crypto.Keys.Item1); peer3.AddPeer(peer2.Address, peer2.Crypto.Keys.Item1); peer3.AddPeer(manager.Address, manager.Crypto.Keys.Item1); Assert.That(manager.IsManager); Assert.That(!peer1.IsManager); Assert.That(!peer2.IsManager); Assert.That(!peer3.IsManager); Assert.That(peer2.Peers.ContainsKey(peer1.Address) && !peer2.ElectionInProgress); Assert.That(peer3.Peers.ContainsKey(peer1.Address) && !peer3.ElectionInProgress); Assert.That(manager.Peers.ContainsKey(peer1.Address) && !manager.ElectionInProgress); manager.Communicator.Send(new StartElectionCommand(manager.Address), peer1.Address); Thread.Sleep(5000); Assert.That(!peer2.Peers.ContainsKey(peer1.Address)); Assert.That(!peer3.Peers.ContainsKey(peer1.Address)); Assert.That(!manager.Peers.ContainsKey(peer1.Address)); } } File.Delete("CommunicatorTestsReceiverFailureTestManagerVoters.sqlite"); File.Delete("CommunicatorTestsReceiverFailureTestPeer1Voters.sqlite"); File.Delete("CommunicatorTestsReceiverFailureTestPeer2Voters.sqlite"); File.Delete("CommunicatorTestsReceiverFailureTestPeer3Voters.sqlite"); File.Delete("CommunicatorTestsReceiverFailureTestManagerLog.sqlite"); }
/// <summary> /// The request ballot and announce ballot received and revoked test. /// </summary> /* * [Test] public void RequestBallotAndAnnounceBallotReceivedAndRevokedTest() { * var vn = new VoterNumber(250000); * var cpr = new CPR(2312881234); * Assert.That(Peer1.Database[vn] == BallotStatus.Unavailable); * Assert.That(Peer2.Database[vn] == BallotStatus.Unavailable); * Assert.That(Peer3.Database[vn] == BallotStatus.Unavailable); * Assert.That(Manager.Database[vn] == BallotStatus.Unavailable); * var data = new List<EncryptedVoterData> { * new EncryptedVoterData( * new CipherText( * Peer1.Crypto.AsymmetricEncrypt(Bytes.From(vn.Value), Peer1.Crypto.VoterDataEncryptionKey)), * new CipherText( * Peer1.Crypto.AsymmetricEncrypt(Bytes.From(cpr.Value), Peer1.Crypto.VoterDataEncryptionKey)), * new CipherText( * Peer1.Crypto.AsymmetricEncrypt( * Bytes.From(cpr.Value + (uint)BallotStatus.NotReceived), Peer1.Crypto.VoterDataEncryptionKey))) * }; * Peer1.Database.Import(data); * Peer2.Database.Import(data); * Peer3.Database.Import(data); * Manager.Database.Import(data); * * Assert.That(Peer1.Database[vn] == BallotStatus.NotReceived); * Assert.That(Peer2.Database[vn] == BallotStatus.NotReceived); * Assert.That(Peer3.Database[vn] == BallotStatus.NotReceived); * Assert.That(Manager.Database[vn] == BallotStatus.NotReceived); * IAsyncResult managerListenerResult = ManagerListener.BeginInvoke(null, null); * AsyncManagerAnnounce(() => Peer1.RequestBallot(vn)); * ManagerListener.EndInvoke(managerListenerResult); * Assert.That(Peer1.Database[vn] == BallotStatus.Received); * Assert.That(Peer2.Database[vn] == BallotStatus.Received); * Assert.That(Peer3.Database[vn] == BallotStatus.Received); * Assert.That(Manager.Database[vn] == BallotStatus.Received); * AsyncManagerAnnounce(() => Manager.AnnounceRevokeBallot(vn, cpr)); * Assert.That(Peer1.Database[vn] == BallotStatus.NotReceived); * Assert.That(Peer2.Database[vn] == BallotStatus.NotReceived); * Assert.That(Peer3.Database[vn] == BallotStatus.NotReceived); * Assert.That(Manager.Database[vn] == BallotStatus.NotReceived); * * managerListenerResult = ManagerListener.BeginInvoke(null, null); * AsyncManagerAnnounce(() => Peer1.RequestBallot(cpr, "yo boii")); * ManagerListener.EndInvoke(managerListenerResult); * Assert.That(Peer1.Database[vn] == BallotStatus.Received); * Assert.That(Peer2.Database[vn] == BallotStatus.Received); * Assert.That(Peer3.Database[vn] == BallotStatus.Received); * Assert.That(Manager.Database[vn] == BallotStatus.Received); * * AsyncManagerAnnounce(() => Manager.AnnounceRevokeBallot(cpr, "yo boii")); * Assert.That(Peer1.Database[vn] == BallotStatus.NotReceived); * Assert.That(Peer2.Database[vn] == BallotStatus.NotReceived); * Assert.That(Peer3.Database[vn] == BallotStatus.NotReceived); * Assert.That(Manager.Database[vn] == BallotStatus.NotReceived); * } */ /// <summary> /// SetUp test helper properties. /// </summary> [SetUp] public void SetUp() { var ui = new TestUi(); Manager = new Station( ui, SystemTestData.Key, SystemTestData.Password, SystemTestData.ManagerPort, "StationTestsManagerVoters.sqlite", "StationTestsManagerLog.sqlite"); byte[] pswd = Manager.Crypto.Hash( Bytes.From(SystemTestData.Password)); Peer1 = new Station(ui, SystemTestData.StationPort, "StationTestsPeer1Voters.sqlite") { Manager = Manager.Address, MasterPassword = pswd, Crypto = { VoterDataEncryptionKey = Manager.Crypto.VoterDataEncryptionKey } }; Peer2 = new Station(ui, SystemTestData.StationPort + 1, "StationTestsPeer2Voters.sqlite") { Manager = Manager.Address, MasterPassword = pswd, Crypto = { VoterDataEncryptionKey = Manager.Crypto.VoterDataEncryptionKey } }; Peer3 = new Station(ui, SystemTestData.StationPort + 2, "StationTestsPeer3Voters.sqlite") { Manager = Manager.Address, MasterPassword = pswd, Crypto = { VoterDataEncryptionKey = Manager.Crypto.VoterDataEncryptionKey } }; Peer4 = new Station(ui, SystemTestData.StationPort + 3, "StationTestsPeer4Voters.sqlite") { Manager = Manager.Address, MasterPassword = pswd, Crypto = { VoterDataEncryptionKey = Manager.Crypto.VoterDataEncryptionKey } }; Manager.StopListening(); Peer1.StopListening(); Peer2.StopListening(); Peer3.StopListening(); Peer4.StopListening(); Peer1.Logger = new Logger(Peer1, "StationsTestsPeer1Log.sqlite"); Peer2.Logger = new Logger(Peer2, "StationsTestsPeer2Log.sqlite"); Peer3.Logger = new Logger(Peer3, "StationsTestsPeer3Log.sqlite"); Peer4.Logger = new Logger(Peer4, "StationsTestsPeer4Log.sqlite"); Manager.AddPeer(Peer1.Address, new AsymmetricKey(Peer1.Crypto.KeyPair.Public)); Manager.AddPeer(Peer2.Address, new AsymmetricKey(Peer2.Crypto.KeyPair.Public)); Manager.AddPeer(Peer3.Address, new AsymmetricKey(Peer3.Crypto.KeyPair.Public)); Peer1.AddPeer(Manager.Address, new AsymmetricKey(Manager.Crypto.KeyPair.Public)); Peer1.AddPeer(Peer2.Address, new AsymmetricKey(Peer2.Crypto.KeyPair.Public)); Peer1.AddPeer(Peer3.Address, new AsymmetricKey(Peer3.Crypto.KeyPair.Public)); Peer2.AddPeer(Manager.Address, new AsymmetricKey(Manager.Crypto.KeyPair.Public)); Peer2.AddPeer(Peer1.Address, new AsymmetricKey(Peer1.Crypto.KeyPair.Public)); Peer2.AddPeer(Peer3.Address, new AsymmetricKey(Peer3.Crypto.KeyPair.Public)); Peer3.AddPeer(Manager.Address, new AsymmetricKey(Manager.Crypto.KeyPair.Public)); Peer3.AddPeer(Peer1.Address, new AsymmetricKey(Peer1.Crypto.KeyPair.Public)); Peer3.AddPeer(Peer2.Address, new AsymmetricKey(Peer2.Crypto.KeyPair.Public)); /* * ManagerListener = Manager.Communicator.NetworkReceiveThread; * Peer1Listener = Peer1.Communicator.NetworkReceiveThread; * Peer2Listener = Peer2.Communicator.NetworkReceiveThread; * Peer3Listener = Peer3.Communicator.NetworkReceiveThread; * */ }
public void SetUp() { const string masterpassword = "******"; var ui = new TestUi(); Manager = new Station(ui, "dataEncryption.key", masterpassword, 62000, "StationTestsManagerVoters.sqlite", "StationTestsManagerLog.sqlite"); var pswd = Manager.Crypto.Hash(Bytes.From("_½æøåÆÅا.^\\,QBsa(/YHh*^#3£()cZ?\\}`|`´ '*jJxCvZ;;;<><aQ\\ ><" + masterpassword)); Peer1 = new Station(ui, 62001, "StationTestsPeer1Voters.sqlite") { Manager = Manager.Address, MasterPassword = pswd, Crypto = { VoterDataEncryptionKey = Manager.Crypto.VoterDataEncryptionKey } }; Peer2 = new Station(ui, 62002, "StationTestsPeer2Voters.sqlite") { Manager = Manager.Address, MasterPassword = pswd, Crypto = { VoterDataEncryptionKey = Manager.Crypto.VoterDataEncryptionKey } }; Peer3 = new Station(ui, 62003, "StationTestsPeer3Voters.sqlite") { Manager = Manager.Address, MasterPassword = pswd, Crypto = { VoterDataEncryptionKey = Manager.Crypto.VoterDataEncryptionKey } }; Peer4 = new Station(ui, 62004, "StationTestsPeer4Voters.sqlite") { Manager = Manager.Address, MasterPassword = pswd, Crypto = { VoterDataEncryptionKey = Manager.Crypto.VoterDataEncryptionKey } }; Manager.StopListening(); Peer1.StopListening(); Peer2.StopListening(); Peer3.StopListening(); Peer4.StopListening(); Peer1.Logger = new Logger(Peer1, "StationsTestsPeer1Log.sqlite"); Peer2.Logger = new Logger(Peer2, "StationsTestsPeer2Log.sqlite"); Peer3.Logger = new Logger(Peer3, "StationsTestsPeer3Log.sqlite"); Peer4.Logger = new Logger(Peer4, "StationsTestsPeer4Log.sqlite"); Manager.AddPeer(Peer1.Address, Peer1.Crypto.Keys.Item1); Manager.AddPeer(Peer2.Address, Peer2.Crypto.Keys.Item1); Manager.AddPeer(Peer3.Address, Peer3.Crypto.Keys.Item1); Peer1.AddPeer(Manager.Address, Manager.Crypto.Keys.Item1); Peer1.AddPeer(Peer2.Address, Peer2.Crypto.Keys.Item1); Peer1.AddPeer(Peer3.Address, Peer3.Crypto.Keys.Item1); Peer2.AddPeer(Manager.Address, Manager.Crypto.Keys.Item1); Peer2.AddPeer(Peer1.Address, Peer1.Crypto.Keys.Item1); Peer2.AddPeer(Peer3.Address, Peer3.Crypto.Keys.Item1); Peer3.AddPeer(Manager.Address, Manager.Crypto.Keys.Item1); Peer3.AddPeer(Peer1.Address, Peer1.Crypto.Keys.Item1); Peer3.AddPeer(Peer2.Address, Peer2.Crypto.Keys.Item1); ManagerListener = Manager.Communicator.ReceiveAndHandle; Peer1Listener = Peer1.Communicator.ReceiveAndHandle; Peer2Listener = Peer2.Communicator.ReceiveAndHandle; Peer3Listener = Peer3.Communicator.ReceiveAndHandle; }