public void Vote_duplicated() { Members_Register(); var question = blockchain.Trunk.SelectMany(c => c.Questions).First(); var pendings1 = new BlockItem[] { new Vote { QuestionId = question.Id, ChoiceId = question.Choices[0].Id }, new Vote { QuestionId = question.Id, ChoiceId = question.Choices[1].Id } }; signer.Sign(pendings1[0], alicia); signer.Sign(pendings1[1], roberto); blockchain.MineNextBlock(pendings1); var pendings2 = new BlockItem[] { new Vote { QuestionId = question.Id, ChoiceId = question.Choices[1].Id }, // este voto está repetido new Vote { QuestionId = question.Id, ChoiceId = question.Choices[0].Id } }; signer.Sign(pendings2[0], roberto); signer.Sign(pendings2[1], camila); blockchain.MineNextBlock(pendings2); var query = new VotesQuery(blockchain); var result = query.Execute(question.Id).ToArray(); Assert.AreEqual(3, result.Length); }
public ObjectResult Get(Guid questionId) { var query = new VotesQuery(node.Blockchain); return(Ok(query.Execute(questionId))); }