Esempio n. 1
0
        public void Call_Mainchain_Gateway_Get_Info()
        {
            var federation = new Federation(new[]
            {
                new PubKey("02fad5f3c4fdf4c22e8be4cfda47882fff89aaa0a48c1ccad7fa80dc5fee9ccec3"),
                new PubKey("02503f03243d41c141172465caca2f5cef7524f149e965483be7ce4e44107d7d35"),
                new PubKey("03be943c3a31359cd8e67bedb7122a0898d2c204cf2d0119e923ded58c429ef97c")
            });

            Network sideChainNetwork = new TestNetwork(federation);

            string redeemScript = PayToFederationTemplate.Instance.GenerateScriptPubKey(federation.Id).ToString();

            string federationIps  = "127.0.0.1:36201,127.0.0.1:36202,127.0.0.1:36203";
            string multisigPubKey = federation.GetFederationDetails().transactionSigningKeys.TakeLast(1).First().ToHex();

            string[] args         = new[] { "-mainchain", "-testnet", $"-federationips={federationIps}", $"-redeemscript={redeemScript}", $"-publickey={multisigPubKey}", "-mincoinmaturity=1", "-mindepositconfirmations=1" };
            var      nodeSettings = new NodeSettings(sideChainNetwork, ProtocolVersion.ALT_PROTOCOL_VERSION, args: args);

            this.federationWalletManager.IsFederationWalletActive().Returns(true);

            var settings = new FederatedPegSettings(nodeSettings, new CounterChainNetworkWrapper(KnownNetworks.StraxRegTest));

            var controller = new FederationGatewayController(
                Substitute.For <IAsyncProvider>(),
                new ChainIndexer(),
                Substitute.For <IConnectionManager>(),
                this.crossChainTransferStore,
                this.GetMaturedBlocksProvider(settings),
                this.network,
                settings,
                this.federationWalletManager,
                Substitute.For <IFullNode>(),
                Substitute.For <IPeerBanning>(),
                this.federationManager);

            IActionResult result = controller.GetInfo();

            result.Should().BeOfType <JsonResult>();
            ((JsonResult)result).Value.Should().BeOfType <FederationGatewayInfoModel>();

            var model = ((JsonResult)result).Value as FederationGatewayInfoModel;

            model.IsMainChain.Should().BeTrue();
            model.FederationMiningPubKeys.Should().BeNull();
            model.MiningPublicKey.Should().BeNull();
            model.MultiSigRedeemScript.Should().Be(redeemScript);
            string.Join(",", model.FederationNodeIpEndPoints).Should().Be(federationIps);
            model.IsActive.Should().BeTrue();
            model.MinimumDepositConfirmationsSmallDeposits.Should().Be(25);
            model.MinimumDepositConfirmationsNormalDeposits.Should().Be(80);
            model.MultisigPublicKey.Should().Be(multisigPubKey);
        }