Beispiel #1
0
            public TestContext(bool forSealing, ReportingContractBasedValidator.Cache cache = null, Address[] initialValidators = null)
            {
                BlockHeader        parentHeader      = Build.A.BlockHeader.TestObject;
                IValidatorContract validatorContract = Substitute.For <IValidatorContract>();

                Address[] validators = initialValidators ?? new[] { MaliciousMinerAddress, NodeAddress };
                validatorContract.GetValidators(parentHeader).Returns(validators);

                ContractBasedValidator = new ContractBasedValidator(
                    validatorContract,
                    Substitute.For <IBlockTree>(),
                    Substitute.For <IReceiptFinder>(),
                    Substitute.For <IValidatorStore>(),
                    Substitute.For <IValidSealerStrategy>(),
                    Substitute.For <IAuRaBlockFinalizationManager>(),
                    parentHeader,
                    LimboLogs.Instance,
                    0,
                    PosdaoTransition,
                    forSealing);

                ContractBasedValidator.Validators ??= validators;

                ReportingValidatorContract = Substitute.For <IReportingValidatorContract>();
                ReportingValidatorContract.NodeAddress.Returns(NodeAddress);

                TxSender = Substitute.For <ITxSender>();
                ITxPool        txPool        = Substitute.For <ITxPool>();
                IStateProvider stateProvider = Substitute.For <IStateProvider>();
                ISpecProvider  specProvider  = Substitute.For <ISpecProvider>();

                stateProvider.GetNonce(ReportingValidatorContract.NodeAddress).Returns(UInt256.One);

                Validator = new ReportingContractBasedValidator(
                    ContractBasedValidator,
                    ReportingValidatorContract,
                    PosdaoTransition,
                    TxSender,
                    txPool,
                    new MiningConfig(),
                    stateProvider,
                    cache ?? new ReportingContractBasedValidator.Cache(),
                    specProvider,
                    Substitute.For <IGasPriceOracle>(),
                    LimboLogs.Instance);
            }
Beispiel #2
0
 public ContractBasedValidator(
     IValidatorContract validatorContract,
     IBlockTree blockTree,
     IReceiptFinder receiptFinder,
     IValidatorStore validatorStore,
     IValidSealerStrategy validSealerStrategy,
     IAuRaBlockFinalizationManager finalizationManager,
     BlockHeader parentHeader,
     ILogManager logManager,
     long startBlockNumber,
     long posdaoTransition = long.MaxValue,
     bool forSealing       = false) : base(validSealerStrategy, validatorStore, logManager, startBlockNumber, forSealing)
 {
     BlockTree         = blockTree ?? throw new ArgumentNullException(nameof(blockTree));
     _receiptFinder    = receiptFinder ?? throw new ArgumentNullException(nameof(receiptFinder));
     _posdaoTransition = posdaoTransition;
     _logger           = logManager?.GetClassLogger <ContractBasedValidator>() ?? throw new ArgumentNullException(nameof(logManager));
     ValidatorContract = validatorContract ?? throw new ArgumentNullException(nameof(validatorContract));
     SetPendingValidators(LoadPendingValidators());
     SetFinalizationManager(finalizationManager, parentHeader ?? BlockTree.Head?.Header);
 }