internal async Task <Dictionary <string, DPoSTriggerInformation> > GenerateEncryptedMessagesTest() { var firstRound = await BootMiner.GetCurrentRoundInformation.CallAsync(new Empty()); var randomHashes = Enumerable.Range(0, MinersCount).Select(_ => Hash.Generate()).ToList(); var triggers = Enumerable.Range(0, MinersCount).Select(i => new DPoSTriggerInformation { PublicKey = ByteString.CopyFrom(InitialMinersKeyPairs[i].PublicKey), RandomHash = randomHashes[i] }).ToDictionary(t => t.PublicKey.ToHex(), t => t); foreach (var minerInRound in firstRound.RealTimeMinersInformation.Values.OrderBy(m => m.Order)) { var currentKeyPair = InitialMinersKeyPairs.First(p => p.PublicKey.ToHex() == minerInRound.PublicKey); ECKeyPairProvider.SetECKeyPair(currentKeyPair); BlockTimeProvider.SetBlockTime(minerInRound.ExpectedMiningTime.ToDateTime()); var tester = GetConsensusContractTester(currentKeyPair); var headerInformation = await tester.GetInformationToUpdateConsensus.CallAsync(triggers[minerInRound.PublicKey]); var encryptedInValues = headerInformation.Round.RealTimeMinersInformation[minerInRound.PublicKey] .EncryptedInValues; encryptedInValues.Count.ShouldBe(MinersCount - 1); foreach (var(key, value) in encryptedInValues) { InitialMinersKeyPairs.Select(p => p.PublicKey.ToHex()).ShouldContain(key); value.ShouldNotBeEmpty(); } // Update consensus information. var toUpdate = headerInformation.Round.ExtractInformationToUpdateConsensus(minerInRound.PublicKey); await tester.UpdateValue.SendAsync(toUpdate); } var updatedRound = await BootMiner.GetCurrentRoundInformation.CallAsync(new Empty()); foreach (var minerInRound in updatedRound.RealTimeMinersInformation.Values) { minerInRound.EncryptedInValues.Count.ShouldBe(MinersCount - 1); } return(triggers); }