public void GetStakingInfo_StakingEnabled()
        {
            using (var dir = TestDirectory.Create())
            {
                IFullNode fullNode        = StratisBitcoinPosRunner.BuildStakingNode(dir.FolderName);
                var       fullNodeRunTask = fullNode.RunAsync();

                INodeLifetime nodeLifetime = fullNode.NodeService <INodeLifetime>();
                nodeLifetime.ApplicationStarted.WaitHandle.WaitOne();
                MiningRPCController controller = fullNode.Services.ServiceProvider.GetService <MiningRPCController>();

                Assert.NotNull(fullNode.NodeService <PosMinting>(true));

                GetStakingInfoModel info = controller.GetStakingInfo();

                Assert.NotNull(info);
                Assert.True(info.Enabled);
                Assert.False(info.Staking);

                nodeLifetime.StopApplication();
                nodeLifetime.ApplicationStopped.WaitHandle.WaitOne();
                fullNode.Dispose();

                Assert.False(fullNodeRunTask.IsFaulted);
            }
        }
예제 #2
0
        public void GetStakingInfo_StartStaking()
        {
            using (var dir = TestDirectory.Create())
            {
                IFullNode fullNode = StratisBitcoinPosRunner.BuildStakingNode(dir.FolderName, false);
                var       node     = fullNode as FullNode;

                var fullNodeRunTask = fullNode.RunAsync();

                INodeLifetime nodeLifetime = fullNode.NodeService <INodeLifetime>();
                nodeLifetime.ApplicationStarted.WaitHandle.WaitOne();
                MiningRPCController controller = fullNode.Services.ServiceProvider.GetService <MiningRPCController>();

                WalletManager walletManager = node.NodeService <IWalletManager>() as WalletManager;

                var password = "******";

                // create the wallet
                var mnemonic = walletManager.CreateWallet(password, "test");


                Assert.NotNull(fullNode.NodeService <PosMinting>(true));

                GetStakingInfoModel info = controller.GetStakingInfo();

                Assert.NotNull(info);
                Assert.False(info.Enabled);
                Assert.False(info.Staking);

                controller.StartStaking("test", "test");

                info = controller.GetStakingInfo();

                Assert.NotNull(info);
                Assert.True(info.Enabled);
                Assert.False(info.Staking);

                nodeLifetime.StopApplication();
                nodeLifetime.ApplicationStopped.WaitHandle.WaitOne();
                fullNode.Dispose();

                Assert.False(fullNodeRunTask.IsFaulted);
            }
        }
        public void GetStakingInfo_StartStaking()
        {
            IFullNode fullNode = StratisBitcoinPosRunner.BuildStakingNode(TestBase.CreateTestDir(this), false);
            var       node     = fullNode as FullNode;

            Task fullNodeRunTask = fullNode.RunAsync();

            var nodeLifetime = fullNode.NodeService <INodeLifetime>();

            nodeLifetime.ApplicationStarted.WaitHandle.WaitOne();
            var controller = fullNode.NodeController <StakingRpcController>();

            var walletManager = node.NodeService <IWalletManager>() as WalletManager;

            string password   = "******";
            string passphrase = "passphrase";

            // create the wallet
            walletManager.CreateWallet(password, "test", passphrase);

            Assert.NotNull(fullNode.NodeService <IPosMinting>(true));

            GetStakingInfoModel info = controller.GetStakingInfo();

            Assert.NotNull(info);
            Assert.False(info.Enabled);
            Assert.False(info.Staking);

            controller.StartStaking("test", "test");

            info = controller.GetStakingInfo();

            Assert.NotNull(info);
            Assert.True(info.Enabled);
            Assert.False(info.Staking);

            nodeLifetime.StopApplication();
            nodeLifetime.ApplicationStopped.WaitHandle.WaitOne();
            fullNode.Dispose();

            Assert.False(fullNodeRunTask.IsFaulted);
        }
        public void GetStakingInfo_StakingEnabled()
        {
            IFullNode fullNode        = StratisBitcoinPosRunner.BuildStakingNode(TestBase.CreateTestDir(this));
            Task      fullNodeRunTask = fullNode.RunAsync();

            var nodeLifetime = fullNode.NodeService <INodeLifetime>();

            nodeLifetime.ApplicationStarted.WaitHandle.WaitOne();
            var controller = fullNode.NodeController <StakingRpcController>();

            Assert.NotNull(fullNode.NodeService <IPosMinting>(true));

            GetStakingInfoModel info = controller.GetStakingInfo();

            Assert.NotNull(info);
            Assert.True(info.Enabled);
            Assert.False(info.Staking);

            nodeLifetime.StopApplication();
            nodeLifetime.ApplicationStopped.WaitHandle.WaitOne();
            fullNode.Dispose();

            Assert.False(fullNodeRunTask.IsFaulted);
        }