Exemplo n.º 1
0
        /// <summary>
        /// Announce to all that they should revoke this update!
        /// </summary>
        /// <param name="cpr">The CPR number to revoke a ballot for.</param>
        /// <param name="masterPassword">The masterpassword that only the election secretary should know.</param>
        public void AnnounceRevokeBallot(CPR cpr, string masterPassword)
        {
            Contract.Requires(masterPassword != null);
            Contract.Requires(ValidMasterPassword(masterPassword));
            Contract.Requires(Database[cpr, masterPassword] == BallotStatus.Received);
            Contract.Requires(IsManager);
            var cmd = new RevokeBallotCPROnlyCommand(Address, cpr, masterPassword);

            Peers.Keys.ForEach(peer => Communicator.Send(cmd, peer));
            cmd.Execute(this);
            if (Logger != null)
            {
                Logger.Log("Announcing that this ballot should be revoked with masterpassword: CPR=" + cpr, Level.Warn);
            }
        }
Exemplo n.º 2
0
        public void ManagerRequirementCheckTest()
        {
            var start = new StartElectionCommand(NewPeer.Address);
            var end   = new EndElectionCommand(NewPeer.Address);

            Assert.That(!((TestUi)Station.UI).OngoingElection);
            start.Execute(Station);
            Assert.That(!((TestUi)Station.UI).OngoingElection);
            Station.StartElection();
            Assert.That(Station.ElectionInProgress);
            end.Execute(Station);
            Assert.That(Station.ElectionInProgress);

            var vn            = new VoterNumber(5);
            var cpr           = new CPR(5);
            var req           = new RequestBallotCommand(NewPeer.Address, vn, cpr);
            var reqCPROnly    = new RequestBallotCPROnlyCommand(NewPeer.Address, cpr, "sup homey");
            var revoke        = new RevokeBallotCommand(NewPeer.Address, vn, cpr);
            var revokeCPROnly = new RevokeBallotCPROnlyCommand(NewPeer.Address, cpr, "sup homey");

            req.Execute(Station);
            reqCPROnly.Execute(Station);
            revoke.Execute(Station);
            revokeCPROnly.Execute(Station);
            Assert.That(Station.Database[vn, cpr] == BallotStatus.Unavailable);

            NewPeer.Crypto.VoterDataEncryptionKey = Manager.Crypto.VoterDataEncryptionKey;
            var sync = new SyncCommand(NewPeer);

            sync.Execute(Station);

            var promoteManager = new PromoteNewManagerCommand(NewPeer.Address, NewPeer.Address);

            promoteManager.Execute(Station);
            Assert.That(!Station.Manager.Equals(NewPeer.Address));
        }