private void InitialConsensus(DateTime currentBlockTime) { _contractStubs.First().InitialAElfConsensusContract.SendAsync(new InitialAElfConsensusContractInput { MinerIncreaseInterval = AEDPoSExtensionConstants.MinerIncreaseInterval, TimeEachTerm = AEDPoSExtensionConstants.TimeEachTerm }); var initialMinerList = new MinerList { Pubkeys = { MissionedECKeyPairs.InitialKeyPairs.Select(p => ByteString.CopyFrom(p.PublicKey)) } }; _currentRound = initialMinerList.GenerateFirstRoundOfNewTerm(AEDPoSExtensionConstants.MiningInterval, currentBlockTime); _contractStubs.First().FirstRound.SendAsync(_currentRound); }
private async Task InitialConsensus(DateTime currentBlockTime) { // InitialAElfConsensusContract { var executionResult = await _contractStubs.First().InitialAElfConsensusContract.SendAsync( new InitialAElfConsensusContractInput { MinerIncreaseInterval = AEDPoSExtensionConstants.MinerIncreaseInterval, TimeEachTerm = AEDPoSExtensionConstants.TimeEachTerm }); if (executionResult.TransactionResult.Status != TransactionResultStatus.Mined) { throw new InitializationFailedException("Failed to execute InitialAElfConsensusContract.", executionResult.TransactionResult.Error); } } var initialMinerList = new MinerList { Pubkeys = { MissionedECKeyPairs.InitialKeyPairs.Select(p => ByteString.CopyFrom(p.PublicKey)) } }; _currentRound = initialMinerList.GenerateFirstRoundOfNewTerm(AEDPoSExtensionConstants.MiningInterval, currentBlockTime); _testDataProvider.SetBlockTime(currentBlockTime.ToTimestamp()); // FirstRound { var executionResult = await _contractStubs.First().FirstRound.SendAsync(_currentRound); if (executionResult.TransactionResult.Status != TransactionResultStatus.Mined) { throw new InitializationFailedException("Failed to execute FirstRound.", executionResult.TransactionResult.Error); } } _testDataProvider.SetBlockTime(currentBlockTime.AddMilliseconds(AEDPoSExtensionConstants.MiningInterval) .ToTimestamp()); }
protected async Task NextTerm(ECKeyPair keyPair) { var miner = GetConsensusContractTester(keyPair); var round = await miner.GetCurrentRoundInformation.CallAsync(new Empty()); var victories = await ElectionContractStub.GetVictories.CallAsync(new Empty()); var miners = new MinerList { Pubkeys = { victories.Value } }; var firstRoundOfNextTerm = miners.GenerateFirstRoundOfNewTerm(EconomicContractsTestConstants.MiningInterval, BlockTimeProvider.GetBlockTime(), round.RoundNumber, round.TermNumber); var executionResult = (await miner.NextTerm.SendAsync(firstRoundOfNextTerm)).TransactionResult; executionResult.Status.ShouldBe(TransactionResultStatus.Mined); }