public RewardClaimerTests()
        {
            this.network = new StraxRegTest
            {
                RewardClaimerBatchActivationHeight = 40,
                RewardClaimerBlockInterval         = 10
            };

            this.addressHelper               = new MultisigAddressHelper(this.network, new CirrusRegTest());
            this.broadCasterManager          = Substitute.For <IBroadcasterManager>();
            this.chainIndexer                = new ChainIndexer(this.network);
            this.consensusManager            = Substitute.For <IConsensusManager>();
            this.dbreezeSerializer           = new DBreezeSerializer(this.network.Consensus.ConsensusFactory);
            this.conversionRequestRepository = Substitute.For <IConversionRequestRepository>();

            this.loggerFactory = Substitute.For <ILoggerFactory>();
            this.signals       = new Signals(this.loggerFactory, null);

            this.initialBlockDownloadState = Substitute.For <IInitialBlockDownloadState>();
            this.initialBlockDownloadState.IsInitialBlockDownload().Returns(false);

            this.opReturnDataReader = new OpReturnDataReader(new CirrusRegTest());

            this.federatedPegSettings = Substitute.For <IFederatedPegSettings>();
            this.federatedPegSettings.MultiSigRedeemScript.Returns(this.addressHelper.PayToMultiSig);

            this.federatedPegSettings.MinimumConfirmationsSmallDeposits.Returns(5);
            this.federatedPegSettings.MinimumConfirmationsNormalDeposits.Returns(10);
            this.federatedPegSettings.MinimumConfirmationsLargeDeposits.Returns(20);

            this.federatedPegSettings.SmallDepositThresholdAmount.Returns(Money.Coins(10));
            this.federatedPegSettings.NormalDepositThresholdAmount.Returns(Money.Coins(100));
        }
        public DepositExtractorTests()
        {
            this.network = new CirrusRegTest();

            this.addressHelper = new MultisigAddressHelper(this.network, new StraxRegTest());

            this.conversionRequestRepository = Substitute.For <IConversionRequestRepository>();

            this.federationSettings = Substitute.For <IFederatedPegSettings>();
            this.federationSettings.IsMainChain.Returns(true);
            this.federationSettings.SmallDepositThresholdAmount.Returns(Money.Coins(10));
            this.federationSettings.NormalDepositThresholdAmount.Returns(Money.Coins(20));
            this.federationSettings.MultiSigRedeemScript.Returns(this.addressHelper.PayToMultiSig);

            this.opReturnDataReader = Substitute.For <IOpReturnDataReader>();
            this.opReturnDataReader.TryGetTargetAddress(null, out string address).Returns(callInfo => { callInfo[1] = null; return(false); });

            IExternalApiClient externalClient = Substitute.For <IExternalApiClient>();

            externalClient.EstimateConversionTransactionFeeAsync().Returns("1.0");
            this.depositExtractor   = new DepositExtractor(this.conversionRequestRepository, this.federationSettings, this.network, this.opReturnDataReader);
            this.transactionBuilder = new TestTransactionBuilder();

            this.retrievalTypeConfirmations = new Dictionary <DepositRetrievalType, int>
            {
                [DepositRetrievalType.Small]            = this.federationSettings.MinimumConfirmationsSmallDeposits,
                [DepositRetrievalType.Normal]           = this.federationSettings.MinimumConfirmationsNormalDeposits,
                [DepositRetrievalType.Large]            = this.federationSettings.MinimumConfirmationsLargeDeposits,
                [DepositRetrievalType.Distribution]     = this.federationSettings.MinimumConfirmationsDistributionDeposits,
                [DepositRetrievalType.ConversionSmall]  = this.federationSettings.MinimumConfirmationsSmallDeposits,
                [DepositRetrievalType.ConversionNormal] = this.federationSettings.MinimumConfirmationsNormalDeposits,
                [DepositRetrievalType.ConversionLarge]  = this.federationSettings.MinimumConfirmationsLargeDeposits
            };
        }
예제 #3
0
        public DepositExtractorTests()
        {
            this.network = new CirrusRegTest();

            ILoggerFactory loggerFactory = Substitute.For <ILoggerFactory>();

            this.addressHelper = new MultisigAddressHelper(this.network, new StraxRegTest());

            this.federationSettings = Substitute.For <IFederatedPegSettings>();
            this.federationSettings.SmallDepositThresholdAmount.Returns(Money.Coins(10));
            this.federationSettings.NormalDepositThresholdAmount.Returns(Money.Coins(20));

            this.federationSettings.MultiSigRedeemScript.Returns(this.addressHelper.PayToMultiSig);
            this.federationSettings.GetWithdrawalTransactionFee(Arg.Any <int>()).ReturnsForAnyArgs((x) =>
            {
                int numInputs = x.ArgAt <int>(0);
                return(FederatedPegSettings.BaseTransactionFee + FederatedPegSettings.InputTransactionFee * numInputs);
            });

            this.opReturnDataReader = Substitute.For <IOpReturnDataReader>();
            this.opReturnDataReader.TryGetTargetAddress(null, out string address).Returns(callInfo => { callInfo[1] = null; return(false); });

            this.depositExtractor   = new DepositExtractor(loggerFactory, this.federationSettings, this.opReturnDataReader);
            this.transactionBuilder = new TestTransactionBuilder();
        }
        public MaturedBlocksProviderTests()
        {
            this.loggerFactory = Substitute.For <ILoggerFactory>();
            this.logger        = Substitute.For <ILogger>();
            this.loggerFactory.CreateLogger(null).ReturnsForAnyArgs(this.logger);
            this.consensusManager = Substitute.For <IConsensusManager>();
            this.network          = CirrusNetwork.NetworksSelector.Regtest();

            this.opReturnDataReader = Substitute.For <IOpReturnDataReader>();
            this.opReturnDataReader.TryGetTargetAddress(null, out string address).Returns(callInfo => { callInfo[1] = null; return(false); });

            this.transactionBuilder = new TestTransactionBuilder();

            this.addressHelper = new MultisigAddressHelper(this.network, Networks.Strax.Regtest());
            this.targetAddress = this.addressHelper.GetNewTargetChainPubKeyAddress();
            this.opReturnBytes = Encoding.UTF8.GetBytes(this.targetAddress.ToString());

            this.federatedPegSettings = Substitute.For <IFederatedPegSettings>();
            this.federatedPegSettings.MultiSigRedeemScript.Returns(this.addressHelper.PayToMultiSig);

            this.federatedPegSettings.MinimumConfirmationsSmallDeposits.Returns(5);
            this.federatedPegSettings.MinimumConfirmationsNormalDeposits.Returns(10);
            this.federatedPegSettings.MinimumConfirmationsLargeDeposits.Returns(20);

            this.federatedPegSettings.SmallDepositThresholdAmount.Returns(Money.Coins(10));
            this.federatedPegSettings.NormalDepositThresholdAmount.Returns(Money.Coins(100));
        }
        public DepositExtractorTests()
        {
            this.network             = CirrusNetwork.NetworksSelector.Regtest();
            this.counterChainNetwork = Networks.Stratis.Regtest();

            this.loggerFactory      = Substitute.For <ILoggerFactory>();
            this.settings           = Substitute.For <IFederatedPegSettings>();
            this.opReturnDataReader = Substitute.For <IOpReturnDataReader>();

            this.addressHelper = new MultisigAddressHelper(this.network, this.counterChainNetwork);

            this.settings.MultiSigRedeemScript.Returns(this.addressHelper.PayToMultiSig);

            this.settings.GetWithdrawalTransactionFee(Arg.Any <int>()).ReturnsForAnyArgs((x) =>
            {
                int numInputs = x.ArgAt <int>(0);

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

            this.opReturnDataReader.TryGetTargetAddress(null, out string address).Returns(callInfo => { callInfo[1] = null; return(false); });

            this.transactionBuilder = new TestTransactionBuilder();

            this.depositExtractor = new DepositExtractor(
                this.loggerFactory,
                this.settings,
                this.opReturnDataReader);
        }
        public MaturedBlocksProviderTests()
        {
            this.loggerFactory = Substitute.For <ILoggerFactory>();
            this.logger        = Substitute.For <ILogger>();
            this.loggerFactory.CreateLogger(null).ReturnsForAnyArgs(this.logger);
            this.conversionRequestRepository = Substitute.For <IConversionRequestRepository>();
            this.consensusManager            = Substitute.For <IConsensusManager>();
            this.network          = new CirrusRegTest();
            this.mainChainNetwork = new StraxRegTest();

            this.opReturnDataReader = Substitute.For <IOpReturnDataReader>();
            this.opReturnDataReader.TryGetTargetAddress(null, out string address).Returns(callInfo => { callInfo[1] = null; return(false); });

            this.transactionBuilder = new TestTransactionBuilder();

            this.addressHelper = new MultisigAddressHelper(this.network, this.mainChainNetwork);
            this.targetAddress = this.addressHelper.GetNewTargetChainPubKeyAddress();
            this.opReturnBytes = Encoding.UTF8.GetBytes(InterFluxOpReturnEncoder.Encode(DestinationChain.STRAX, this.targetAddress.ToString()));

            this.federatedPegSettings = Substitute.For <IFederatedPegSettings>();
            this.federatedPegSettings.MultiSigRedeemScript.Returns(this.addressHelper.PayToMultiSig);

            this.federatedPegSettings.MinimumConfirmationsSmallDeposits.Returns(5);
            this.federatedPegSettings.MinimumConfirmationsNormalDeposits.Returns(10);
            this.federatedPegSettings.MinimumConfirmationsLargeDeposits.Returns(20);

            this.federatedPegSettings.SmallDepositThresholdAmount.Returns(Money.Coins(10));
            this.federatedPegSettings.NormalDepositThresholdAmount.Returns(Money.Coins(100));

            this.consensusManager.GetBlocksAfterBlock(Arg.Any <ChainedHeader>(), MaturedBlocksProvider.MaturedBlocksBatchSize, Arg.Any <CancellationTokenSource>()).Returns(delegate(CallInfo info)
            {
                var chainedHeader = (ChainedHeader)info[0];
                if (chainedHeader == null)
                {
                    return(this.blocks.Where(x => x.ChainedHeader.Height <= this.consensusManager.Tip.Height).ToArray());
                }

                return(this.blocks.SkipWhile(x => x.ChainedHeader.Height <= chainedHeader.Height).Where(x => x.ChainedHeader.Height <= this.consensusManager.Tip.Height).ToArray());
            });

            this.retrievalTypeConfirmations = new Dictionary <DepositRetrievalType, int>
            {
                [DepositRetrievalType.Small]  = this.federatedPegSettings.MinimumConfirmationsSmallDeposits,
                [DepositRetrievalType.Normal] = this.federatedPegSettings.MinimumConfirmationsNormalDeposits,
                [DepositRetrievalType.Large]  = this.federatedPegSettings.MinimumConfirmationsLargeDeposits,
            };

            this.retrievalTypeConfirmations[DepositRetrievalType.Distribution]     = this.federatedPegSettings.MinimumConfirmationsDistributionDeposits;
            this.retrievalTypeConfirmations[DepositRetrievalType.ConversionSmall]  = this.federatedPegSettings.MinimumConfirmationsSmallDeposits;
            this.retrievalTypeConfirmations[DepositRetrievalType.ConversionNormal] = this.federatedPegSettings.MinimumConfirmationsNormalDeposits;
            this.retrievalTypeConfirmations[DepositRetrievalType.ConversionLarge]  = this.federatedPegSettings.MinimumConfirmationsLargeDeposits;
        }
        public DepositExtractorTests()
        {
            this.network = new CirrusRegTest();

            this.addressHelper = new MultisigAddressHelper(this.network, new StraxRegTest());

            this.federationSettings = Substitute.For <IFederatedPegSettings>();
            this.federationSettings.SmallDepositThresholdAmount.Returns(Money.Coins(10));
            this.federationSettings.NormalDepositThresholdAmount.Returns(Money.Coins(20));
            this.federationSettings.MultiSigRedeemScript.Returns(this.addressHelper.PayToMultiSig);

            this.opReturnDataReader = Substitute.For <IOpReturnDataReader>();
            this.opReturnDataReader.TryGetTargetAddress(null, out string address).Returns(callInfo => { callInfo[1] = null; return(false); });

            this.depositExtractor   = new DepositExtractor(this.federationSettings, this.network, this.opReturnDataReader);
            this.transactionBuilder = new TestTransactionBuilder();
        }
        public WithdrawalExtractorTests()
        {
            this.network             = CirrusNetwork.NetworksSelector.Regtest();
            this.counterChainNetwork = Networks.Stratis.Regtest();

            this.settings           = Substitute.For <IFederatedPegSettings>();
            this.opReturnDataReader = Substitute.For <IOpReturnDataReader>();

            this.addressHelper = new MultisigAddressHelper(this.network, this.counterChainNetwork);

            this.settings.MultiSigAddress.Returns(this.addressHelper.TargetChainMultisigAddress);
            this.settings.MultiSigRedeemScript.Returns(this.addressHelper.PayToMultiSig);
            this.settings.FederationPublicKeys.Returns(this.addressHelper.MultisigPrivateKeys.Select(k => k.PubKey).ToArray());

            this.opReturnDataReader.TryGetTargetAddress(null, out string address).Returns(callInfo => { callInfo[1] = null; return(false); });

            this.transactionBuilder = new TestMultisigTransactionBuilder(this.addressHelper);
        }
        public DepositExtractorTests()
        {
            this.network = FederatedPegNetwork.NetworksSelector.Regtest();

            this.loggerFactory      = Substitute.For <ILoggerFactory>();
            this.settings           = Substitute.For <IFederationGatewaySettings>();
            this.opReturnDataReader = Substitute.For <IOpReturnDataReader>();

            this.addressHelper = new MultisigAddressHelper(this.network);

            this.settings.MultiSigRedeemScript.Returns(this.addressHelper.PayToMultiSig);
            this.opReturnDataReader.TryGetTargetAddress(null, out string address).Returns(callInfo => { callInfo[1] = null; return(false); });

            this.transactionBuilder = new TestTransactionBuilder();

            this.depositExtractor = new DepositExtractor(
                this.loggerFactory,
                this.settings,
                this.opReturnDataReader);
        }
예제 #10
0
        public WithdrawalExtractorTests()
        {
            this.network = FederatedPegNetwork.NetworksSelector.Regtest();

            this.loggerFactory      = Substitute.For <ILoggerFactory>();
            this.settings           = Substitute.For <IFederationGatewaySettings>();
            this.opReturnDataReader = Substitute.For <IOpReturnDataReader>();
            this.withdrawalReceiver = Substitute.For <IWithdrawalReceiver>();

            this.addressHelper = new MultisigAddressHelper(this.network);

            this.settings.MultiSigAddress.Returns(this.addressHelper.TargetChainMultisigAddress);
            this.settings.MultiSigRedeemScript.Returns(this.addressHelper.PayToMultiSig);
            this.settings.FederationPublicKeys.Returns(this.addressHelper.MultisigPrivateKeys.Select(k => k.PubKey).ToArray());

            this.opReturnDataReader.TryGetTargetAddress(null).ReturnsForAnyArgs((string)null);

            this.transactionBuilder = new TestMultisigTransactionBuilder(this.addressHelper);

            this.withdrawalExtractor = new WithdrawalExtractor(
                this.loggerFactory, this.settings, this.opReturnDataReader, this.network);
        }
        public DepositExtractorTests()
        {
            this.network = FederatedPegNetwork.NetworksSelector.Regtest();

            this.loggerFactory      = Substitute.For <ILoggerFactory>();
            this.settings           = Substitute.For <IFederationGatewaySettings>();
            this.opReturnDataReader = Substitute.For <IOpReturnDataReader>();
            this.fullNode           = Substitute.For <IFullNode>();
            this.fullNode.NodeService <ConcurrentChain>().Returns(this.chain);

            this.addressHelper = new MultisigAddressHelper(this.network);

            this.settings.MultiSigRedeemScript.Returns(this.addressHelper.PayToMultiSig);
            this.opReturnDataReader.TryGetTargetAddress(null).ReturnsForAnyArgs((string)null);

            this.transactionBuilder = new TestTransactionBuilder();

            this.depositExtractor = new DepositExtractor(
                this.loggerFactory,
                this.settings,
                this.opReturnDataReader,
                this.fullNode);
        }