Exemplo n.º 1
0
        public InteropPoller(NodeSettings nodeSettings, InteropSettings interopSettings, IAsyncProvider asyncProvider, INodeLifetime nodeLifetime,
                             ChainIndexer chainIndexer, IInitialBlockDownloadState initialBlockDownloadState, IFederationManager federationManager, IFederationHistory federationHistory,
                             IFederatedPegBroadcaster federatedPegBroadcaster, IConversionRequestRepository conversionRequestRepository, IInteropTransactionManager interopTransactionManager,
                             CounterChainNetworkWrapper counterChainNetworkWrapper, IETHCompatibleClientProvider clientProvider)
        {
            this.interopSettings             = interopSettings;
            this.clientProvider              = clientProvider;
            this.network                     = nodeSettings.Network;
            this.asyncProvider               = asyncProvider;
            this.nodeLifetime                = nodeLifetime;
            this.chainIndexer                = chainIndexer;
            this.initialBlockDownloadState   = initialBlockDownloadState;
            this.federationManager           = federationManager;
            this.federationHistory           = federationHistory;
            this.federatedPegBroadcaster     = federatedPegBroadcaster;
            this.conversionRequestRepository = conversionRequestRepository;
            this.interopTransactionManager   = interopTransactionManager;
            this.counterChainNetwork         = counterChainNetworkWrapper.CounterChainNetwork;
            this.logger = nodeSettings.LoggerFactory.CreateLogger(this.GetType().FullName);

            this.eventFilterCreationRequired = new Dictionary <DestinationChain, bool>()
            {
                { DestinationChain.ETH, true }
            };
        }
Exemplo n.º 2
0
        public InteropPoller(NodeSettings nodeSettings,
                             InteropSettings interopSettings,
                             IEthereumClientBase ethereumClientBase,
                             IAsyncProvider asyncProvider,
                             INodeLifetime nodeLifetime,
                             ChainIndexer chainIndexer,
                             IInitialBlockDownloadState initialBlockDownloadState,
                             IFederationManager federationManager,
                             IFederationHistory federationHistory,
                             IFederatedPegBroadcaster federatedPegBroadcaster,
                             IConversionRequestRepository conversionRequestRepository,
                             IInteropTransactionManager interopTransactionManager,
                             CounterChainNetworkWrapper counterChainNetworkWrapper)
        {
            this.interopSettings             = interopSettings;
            this.ethereumClientBase          = ethereumClientBase;
            this.network                     = nodeSettings.Network;
            this.asyncProvider               = asyncProvider;
            this.nodeLifetime                = nodeLifetime;
            this.chainIndexer                = chainIndexer;
            this.initialBlockDownloadState   = initialBlockDownloadState;
            this.federationManager           = federationManager;
            this.federationHistory           = federationHistory;
            this.federatedPegBroadcaster     = federatedPegBroadcaster;
            this.conversionRequestRepository = conversionRequestRepository;
            this.interopTransactionManager   = interopTransactionManager;
            this.counterChainNetwork         = counterChainNetworkWrapper.CounterChainNetwork;
            this.logger = nodeSettings.LoggerFactory.CreateLogger(this.GetType().FullName);

            this.firstPoll = true;
        }
Exemplo n.º 3
0
 public PartialTransactionsRequesterTests()
 {
     this.loggerFactory = Substitute.For <ILoggerFactory>();
     this.logger        = Substitute.For <ILogger>();
     this.loggerFactory.CreateLogger(null).ReturnsForAnyArgs(this.logger);
     this.store                   = Substitute.For <ICrossChainTransferStore>();
     this.asyncProvider           = Substitute.For <IAsyncProvider>();
     this.nodeLifetime            = Substitute.For <INodeLifetime>();
     this.federatedPegBroadcaster = Substitute.For <IFederatedPegBroadcaster>();
     this.inputConsolidator       = Substitute.For <IInputConsolidator>();
     this.ibdState                = Substitute.For <IInitialBlockDownloadState>();
     this.federationWalletManager = Substitute.For <IFederationWalletManager>();
     this.federationWalletManager.IsFederationWalletActive().Returns(true);
 }
 public PartialTransactionsRequesterTests()
 {
     this.loggerFactory = Substitute.For <ILoggerFactory>();
     this.logger        = Substitute.For <ILogger>();
     this.loggerFactory.CreateLogger(null).ReturnsForAnyArgs(this.logger);
     this.store                   = Substitute.For <ICrossChainTransferStore>();
     this.asyncProvider           = Substitute.For <IAsyncProvider>();
     this.nodeLifetime            = Substitute.For <INodeLifetime>();
     this.federatedPegBroadcaster = Substitute.For <IFederatedPegBroadcaster>();
     this.inputConsolidator       = Substitute.For <IInputConsolidator>();
     this.ibdState                = Substitute.For <IInitialBlockDownloadState>();
     this.federationSettings      = Substitute.For <IFederatedPegSettings>();
     this.federationSettings.PublicKey.Returns("03191898544c4061ef427dd0a2feff8d7bf66ed6ae9db47f1a00e78f4a6439dc28");
     this.federationWalletManager = Substitute.For <IFederationWalletManager>();
     this.federationWalletManager.IsFederationWalletActive().Returns(true);
 }
Exemplo n.º 5
0
 public PartialTransactionRequester(
     ICrossChainTransferStore crossChainTransferStore,
     IAsyncProvider asyncProvider,
     INodeLifetime nodeLifetime,
     IFederatedPegBroadcaster federatedPegBroadcaster,
     IInitialBlockDownloadState ibdState,
     IFederationWalletManager federationWalletManager,
     IInputConsolidator inputConsolidator)
 {
     this.logger = LogManager.GetCurrentClassLogger();
     this.crossChainTransferStore = crossChainTransferStore;
     this.asyncProvider           = asyncProvider;
     this.nodeLifetime            = nodeLifetime;
     this.ibdState = ibdState;
     this.federatedPegBroadcaster = federatedPegBroadcaster;
     this.federationWalletManager = federationWalletManager;
     this.inputConsolidator       = inputConsolidator;
 }
Exemplo n.º 6
0
        public ConversionRequestFeeService(
            IDateTimeProvider dateTimeProvider,
            IExternalApiPoller externalApiPoller,
            IFederationManager federationManager,
            IFederatedPegSettings federatedPegSettings,
            IFederatedPegBroadcaster federatedPegBroadcaster,
            IConversionRequestFeeKeyValueStore interopRequestKeyValueStore,
            INodeLifetime nodeLifetime,
            INodeStats nodeStats)
        {
            this.dateTimeProvider            = dateTimeProvider;
            this.externalApiPoller           = externalApiPoller;
            this.federationManager           = federationManager;
            this.federatedPegBroadcaster     = federatedPegBroadcaster;
            this.federatedPegSettings        = federatedPegSettings;
            this.interopRequestKeyValueStore = interopRequestKeyValueStore;
            this.nodeLifetime = nodeLifetime;

            this.logger = LogManager.GetCurrentClassLogger();

            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component, this.GetType().Name, 251);
        }
        public PartialTransactionRequester(
            ILoggerFactory loggerFactory,
            ICrossChainTransferStore crossChainTransferStore,
            IAsyncProvider asyncProvider,
            INodeLifetime nodeLifetime,
            IFederatedPegBroadcaster federatedPegBroadcaster,
            IInitialBlockDownloadState ibdState,
            IFederationWalletManager federationWalletManager,
            IInputConsolidator inputConsolidator)
        {
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(crossChainTransferStore, nameof(crossChainTransferStore));
            Guard.NotNull(asyncProvider, nameof(asyncProvider));
            Guard.NotNull(nodeLifetime, nameof(nodeLifetime));

            this.logger = loggerFactory.CreateLogger(this.GetType().FullName);
            this.crossChainTransferStore = crossChainTransferStore;
            this.asyncProvider           = asyncProvider;
            this.nodeLifetime            = nodeLifetime;
            this.ibdState = ibdState;
            this.federatedPegBroadcaster = federatedPegBroadcaster;
            this.federationWalletManager = federationWalletManager;
            this.inputConsolidator       = inputConsolidator;
        }
Exemplo n.º 8
0
        /// <summary>
        /// Initializes the cross-chain transfer tests.
        /// </summary>
        /// <param name="network">The network to run the tests for.</param>
        public CrossChainTestBase(Network network = null, Network counterChainNetwork = null)
        {
            this.network                    = network ?? CirrusNetwork.NetworksSelector.Regtest();
            this.counterChainNetwork        = counterChainNetwork ?? Networks.Stratis.Regtest();
            this.counterChainNetworkWrapper = new CounterChainNetworkWrapper(counterChainNetwork);

            NetworkRegistration.Register(this.network);

            this.loggerFactory = Substitute.For <ILoggerFactory>();
            this.nodeLifetime  = new NodeLifetime();
            this.logger        = Substitute.For <ILogger>();
            this.signals       = Substitute.For <ISignals>();
            this.asyncProvider = new AsyncProvider(this.loggerFactory, this.signals, this.nodeLifetime);
            this.loggerFactory.CreateLogger(null).ReturnsForAnyArgs(this.logger);
            this.dateTimeProvider                   = DateTimeProvider.Default;
            this.opReturnDataReader                 = new OpReturnDataReader(this.loggerFactory, this.counterChainNetworkWrapper);
            this.blockRepository                    = Substitute.For <IBlockRepository>();
            this.fullNode                           = Substitute.For <IFullNode>();
            this.withdrawalTransactionBuilder       = Substitute.For <IWithdrawalTransactionBuilder>();
            this.federationWalletManager            = Substitute.For <IFederationWalletManager>();
            this.federationWalletSyncManager        = Substitute.For <IFederationWalletSyncManager>();
            this.FederationWalletTransactionHandler = Substitute.For <IFederationWalletTransactionHandler>();
            this.walletFeePolicy                    = Substitute.For <IWalletFeePolicy>();
            this.connectionManager                  = Substitute.For <IConnectionManager>();
            this.federatedPegBroadcaster            = Substitute.For <IFederatedPegBroadcaster>();
            this.inputConsolidator                  = Substitute.For <IInputConsolidator>();
            this.dBreezeSerializer                  = new DBreezeSerializer(this.network.Consensus.ConsensusFactory);
            this.ibdState                           = Substitute.For <IInitialBlockDownloadState>();
            this.wallet = null;
            this.federatedPegSettings = Substitute.For <IFederatedPegSettings>();
            this.ChainIndexer         = new ChainIndexer(this.network);
            this.federatedPegSettings.GetWithdrawalTransactionFee(Arg.Any <int>()).ReturnsForAnyArgs((x) =>
            {
                int numInputs = x.ArgAt <int>(0);

                return(FederatedPegSettings.BaseTransactionFee + FederatedPegSettings.InputTransactionFee * numInputs);
            });

            // Generate the keys used by the federation members for our tests.
            this.federationKeys = new[]
            {
                "ensure feel swift crucial bridge charge cloud tell hobby twenty people mandate",
                "quiz sunset vote alley draw turkey hill scrap lumber game differ fiction",
                "exchange rent bronze pole post hurry oppose drama eternal voice client state"
            }.Select(m => HdOperations.GetExtendedKey(m)).ToArray();

            SetExtendedKey(0);

            this.fundingTransactions = new List <Transaction>();

            this.blockDict = new Dictionary <uint256, Block>();
            this.blockDict[this.network.GenesisHash] = this.network.GetGenesis();

            this.blockRepository.GetBlocks(Arg.Any <List <uint256> >()).ReturnsForAnyArgs((x) =>
            {
                List <uint256> hashes = x.ArgAt <List <uint256> >(0);
                var blocks            = new List <Block>();
                for (int i = 0; i < hashes.Count; i++)
                {
                    blocks.Add(this.blockDict.TryGetValue(hashes[i], out Block block) ? block : null);
                }

                return(blocks);
            });

            this.blockRepository.GetBlock(Arg.Any <uint256>()).ReturnsForAnyArgs((x) =>
            {
                uint256 hash = x.ArgAt <uint256>(0);
                this.blockDict.TryGetValue(hash, out Block block);

                return(block);
            });

            this.blockRepository.TipHashAndHeight.Returns((x) => {
                return(new HashHeightPair(this.blockDict.Last().Value.GetHash(), this.blockDict.Count - 1));
            });
        }