// Checks that node can sync from scratch if federation voted in favor of adding a new fed member. public async Task CanSyncIfFedMemberAddedAsync() { List <IFederationMember> originalFedMembers = this.node1.FullNode.NodeService <IFederationManager>().GetFederationMembers(); TestHelper.Connect(this.node1, this.node2); IFederationMember federationMember = new FederationMember(new PubKey("03025fcadedd28b12665de0542c8096f4cd5af8e01791a4d057f67e2866ca66ba7")); byte[] fedMemberBytes = (this.poaNetwork.Consensus.ConsensusFactory as PoAConsensusFactory).SerializeFederationMember(federationMember); var votingData = new VotingData() { Key = VoteKey.AddFederationMember, Data = fedMemberBytes }; this.node1.FullNode.NodeService <VotingManager>().ScheduleVote(votingData); this.node2.FullNode.NodeService <VotingManager>().ScheduleVote(votingData); await this.node1.MineBlocksAsync(1); CoreNodePoAExtensions.WaitTillSynced(this.node1, this.node2); await this.node2.MineBlocksAsync((int)this.poaNetwork.Consensus.MaxReorgLength * 3); CoreNodePoAExtensions.WaitTillSynced(this.node1, this.node2); List <IFederationMember> newFedMembers = this.node1.FullNode.NodeService <IFederationManager>().GetFederationMembers(); Assert.Equal(originalFedMembers.Count + 1, newFedMembers.Count); TestHelper.Connect(this.node2, this.node3); CoreNodePoAExtensions.WaitTillSynced(this.node1, this.node2, this.node3); }
private IActionResult VoteAddKickFedMember(HexPubKeyModel request, bool addMember) { Guard.NotNull(request, nameof(request)); if (!this.ModelState.IsValid) { return(ModelStateErrors.BuildErrorResponse(this.ModelState)); } if (!this.fedManager.IsFederationMember) { return(ErrorHelpers.BuildErrorResponse(HttpStatusCode.BadRequest, "Only federation members can vote", string.Empty)); } try { var key = new PubKey(request.PubKeyHex); IFederationMember federationMember = new FederationMember(key); byte[] fedMemberBytes = (this.network.Consensus.ConsensusFactory as PoAConsensusFactory).SerializeFederationMember(federationMember); this.votingManager.ScheduleVote(new VotingData() { Key = addMember ? VoteKey.AddFederationMember : VoteKey.KickFederationMember, Data = fedMemberBytes }); return(this.Ok()); } catch (Exception e) { this.logger.LogError("Exception occurred: {0}", e.ToString()); return(ErrorHelpers.BuildErrorResponse(HttpStatusCode.BadRequest, "There was a problem executing a command.", e.ToString())); } }
public Competition(string beginDate, string endDate, int platformsCount, bool isFinished, CompetitionType competitionType, CompetitionPlace competitionPlace, FederationMember chiefJudge) { this.Id = new Guid(); this.BeginDate = beginDate; this.EndDate = endDate; this.PlatformsCount = platformsCount; this.IsFinished = isFinished; this.CompetitionType = competitionType; this.CompetitionPlace = competitionPlace; this.ChiefJudge = chiefJudge; }
public override string ToString() { if (ConnectedTo == TypeOfConnection.SQLAzureFederation) { return(FederationMember.ToString()); } else if (DatabaseObject == null) { return("[" + DatabaseName + "]"); } return(DatabaseObject.ToString()); }
// Checks that fed members cant vote twice. // Checks that miner adds voting data if it exists. public async Task CantVoteTwiceAsync() { int originalFedMembersCount = this.node1.FullNode.NodeService <IFederationManager>().GetFederationMembers().Count; TestHelper.Connect(this.node1, this.node2); await this.node1.MineBlocksAsync(3); IFederationMember federationMember = new FederationMember(new PubKey("03025fcadedd28b12665de0542c8096f4cd5af8e01791a4d057f67e2866ca66ba7")); byte[] fedMemberBytes = (this.poaNetwork.Consensus.ConsensusFactory as PoAConsensusFactory).SerializeFederationMember(federationMember); var votingData = new VotingData() { Key = VoteKey.AddFederationMember, Data = fedMemberBytes }; this.node1.FullNode.NodeService <VotingManager>().ScheduleVote(votingData); Assert.Single(this.node1.FullNode.NodeService <VotingManager>().GetScheduledVotes()); Assert.Empty(this.node1.FullNode.NodeService <VotingManager>().GetPendingPolls()); await this.node1.MineBlocksAsync(1); CoreNodePoAExtensions.WaitTillSynced(this.node1, this.node2); Assert.Empty(this.node1.FullNode.NodeService <VotingManager>().GetScheduledVotes()); Assert.Single(this.node1.FullNode.NodeService <VotingManager>().GetPendingPolls()); // Vote 2nd time and make sure nothing changed. this.node1.FullNode.NodeService <VotingManager>().ScheduleVote(votingData); await this.node1.MineBlocksAsync(1); Assert.Empty(this.node1.FullNode.NodeService <VotingManager>().GetScheduledVotes()); Assert.Single(this.node1.FullNode.NodeService <VotingManager>().GetPendingPolls()); CoreNodePoAExtensions.WaitTillSynced(this.node1, this.node2); // Node 2 votes. After that it will be enough to change the federation. this.node2.FullNode.NodeService <VotingManager>().ScheduleVote(votingData); await this.node2.MineBlocksAsync((int)this.poaNetwork.Consensus.MaxReorgLength + 1); CoreNodePoAExtensions.WaitTillSynced(this.node1, this.node2); Assert.Equal(originalFedMembersCount + 1, this.node1.FullNode.NodeService <IFederationManager>().GetFederationMembers().Count); Assert.Equal(originalFedMembersCount + 1, this.node2.FullNode.NodeService <IFederationManager>().GetFederationMembers().Count); TestHelper.Connect(this.node2, this.node3); CoreNodePoAExtensions.WaitTillSynced(this.node1, this.node2, this.node3); }
public AthletePerfomance(bool isOutOfCompetition, FederationMember athlete, Competition competition, AgeCategory ageCategory, PerfomanceCategory perfomanceCategory, EvaluationList evaluationList, FederationMember partner) { this.Id = new Guid(); this.IsOutOfCompetition = isOutOfCompetition; this.Athlete = athlete; this.Competition = competition; this.AgeCategory = ageCategory; this.PerfomanceCategory = perfomanceCategory; this.EvaluationList = evaluationList; if (partner != null) { this.Partner = partner; } }
public JudgingPanel(FederationMember judgeA1, FederationMember judgeA2, FederationMember judgeA3, FederationMember judgeB1, FederationMember judgeB2, FederationMember judgeB3, FederationMember judgeC1, FederationMember judgeC2, FederationMember judgeC3, FederationMember seniorJudge, FederationMember secretary) { this.Id = new Guid(); this.JudgeA1 = judgeA1; this.JudgeA2 = judgeA2; this.JudgeA3 = judgeA3; this.JudgeB1 = judgeB1; this.JudgeB2 = judgeB2; this.JudgeB3 = judgeB3; this.JudgeC1 = judgeC1; this.JudgeC2 = judgeC2; this.JudgeC3 = judgeC3; this.SeniorJudge = seniorJudge; this.Secretary = secretary; }
public AthletePerfomance(Guid id, string platformNumber, string place, string perfomanceNumber, bool isOutOfCompetition, FederationMember athlete, Competition competition, AgeCategory ageCategory, PerfomanceCategory perfomanceCategory, EvaluationList evaluationList, JudgingPanel judgingPanel, FederationMember partner) : this(isOutOfCompetition, athlete, competition, ageCategory, perfomanceCategory, evaluationList, partner) { this.Id = id; if (platformNumber != null) { this.PlatformNumber = platformNumber; } if (place != null) { this.Place = place; } if (perfomanceNumber != null) { this.PerfomanceNumber = perfomanceNumber; } if (judgingPanel != null) { this.JudgingPanel = judgingPanel; } }
public void ThrowsIfIncorrectType() { var federationMember = new FederationMember(new Key().PubKey); Assert.Throws <ArgumentException>(() => this.factory.SerializeFederationMember(federationMember)); }
public JudgingPanel(Guid id, FederationMember judgeA1, FederationMember judgeA2, FederationMember judgeA3, FederationMember judgeB1, FederationMember judgeB2, FederationMember judgeB3, FederationMember judgeC1, FederationMember judgeC2, FederationMember judgeC3, FederationMember seniorJudge, FederationMember secretary) : this(judgeA1, judgeA2, judgeA3, judgeB1, judgeB2, judgeB3, judgeC1, judgeC2, judgeC3, seniorJudge, secretary) { this.Id = id; }
public Competition(Guid id, string beginDate, string endDate, int platformsCount, bool isFinished, CompetitionType competitionType, CompetitionPlace competitionPlace, FederationMember chiefJudge) : this(beginDate, endDate, platformsCount, isFinished, competitionType, competitionPlace, chiefJudge) { this.Id = id; }