/// <summary>
        /// Builds a node with POS miner and RPC enabled.
        /// </summary>
        /// <param name="dir">Data directory that the node should use.</param>
        /// <returns>Interface to the newly built node.</returns>
        /// <remarks>Currently the node built here does not actually stake as it has no coins in the wallet,
        /// but all the features required for it are enabled.</remarks>
        public IFullNode BuildStakingNode(string dir, bool staking = true)
        {
            NodeSettings nodeSettings    = new NodeSettings().LoadArguments(new string[] { $"-datadir={dir}", $"-stake={(staking ? 1 : 0)}", "-walletname=dummy", "-walletpassword=dummy" });
            var          fullNodeBuilder = new FullNodeBuilder(nodeSettings);
            IFullNode    fullNode        = fullNodeBuilder
                                           .UsePurpleConsensus()
                                           .UseBlockStore()
                                           .UseMempool()
                                           .UseWallet()
                                           .AddPowPosMining()
                                           .AddRPC()
                                           .Build();

            return(fullNode);
        }
Example #2
0
        public void CanHaveAllFullnodeServicesTest()
        {
            // This test is put in the mempool feature because the
            // mempool requires all the features to be a fullnode


            var nodeSettings = NodeSettings.Default();

            nodeSettings.DataDir = "Purple.Bitcoin.Features.MemoryPool.Tests/TestData/FullNodeBuilderTest/CanHaveAllServicesTest";
            var       fullNodeBuilder = new FullNodeBuilder(nodeSettings);
            IFullNode fullNode        = fullNodeBuilder
                                        .UsePurpleConsensus()
                                        .UseBlockStore()
                                        .UseMempool()
                                        .Build();

            IServiceProvider serviceProvider = fullNode.Services.ServiceProvider;
            var network           = serviceProvider.GetService <Network>();
            var settings          = serviceProvider.GetService <NodeSettings>();
            var consensusLoop     = serviceProvider.GetService <ConsensusLoop>();
            var consensus         = serviceProvider.GetService <PosConsensusValidator>();
            var chain             = serviceProvider.GetService <NBitcoin.ConcurrentChain>();
            var chainState        = serviceProvider.GetService <ChainState>();
            var blockStoreManager = serviceProvider.GetService <BlockStoreManager>();
            var mempoolManager    = serviceProvider.GetService <MempoolManager>();
            var connectionManager = serviceProvider.GetService <IConnectionManager>();

            Assert.NotNull(fullNode);
            Assert.NotNull(network);
            Assert.NotNull(settings);
            Assert.NotNull(consensusLoop);
            Assert.NotNull(consensus);
            Assert.NotNull(chain);
            Assert.NotNull(chainState);
            Assert.NotNull(blockStoreManager);
            Assert.NotNull(mempoolManager);
            Assert.NotNull(connectionManager);
        }