From 3b6dbe76c562442f55fb57b92ef3870369b2b14c Mon Sep 17 00:00:00 2001 From: Dennis Reimann Date: Mon, 18 May 2020 16:02:15 +0200 Subject: [PATCH] Add sync state --- BTCPayServer.Client/Models/ServerInfoData.cs | 2 +- BTCPayServer.Tests/GreenfieldAPITests.cs | 10 +++++++--- .../Controllers/GreenField/ServerInfoController.cs | 5 ++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/BTCPayServer.Client/Models/ServerInfoData.cs b/BTCPayServer.Client/Models/ServerInfoData.cs index edd301ca3..382456efd 100644 --- a/BTCPayServer.Client/Models/ServerInfoData.cs +++ b/BTCPayServer.Client/Models/ServerInfoData.cs @@ -42,6 +42,6 @@ namespace BTCPayServer.Client.Models { public string CryptoCode { get; set; } public int BlockHeaders { get; set; } - public double Progress { get; set; } + public float Progress { get; set; } } } diff --git a/BTCPayServer.Tests/GreenfieldAPITests.cs b/BTCPayServer.Tests/GreenfieldAPITests.cs index 4b58513e9..511cbafd1 100644 --- a/BTCPayServer.Tests/GreenfieldAPITests.cs +++ b/BTCPayServer.Tests/GreenfieldAPITests.cs @@ -4,11 +4,8 @@ using System.Net.Http; using System.Threading.Tasks; using BTCPayServer.Client; using BTCPayServer.Client.Models; -using BTCPayServer.Controllers; using BTCPayServer.Services; using BTCPayServer.Tests.Logging; -using Microsoft.AspNet.SignalR.Client; -using Microsoft.AspNetCore.Mvc; using Xunit; using Xunit.Abstractions; using CreateApplicationUserRequest = BTCPayServer.Client.Models.CreateApplicationUserRequest; @@ -306,11 +303,18 @@ namespace BTCPayServer.Tests user.GrantAccess(); var clientBasic = await user.CreateClient(); var serverInfoData = await clientBasic.GetServerInfo(); + Assert.NotNull(serverInfoData); + Assert.NotNull(serverInfoData.Version); + Assert.NotNull(serverInfoData.Onion); Assert.NotNull(serverInfoData.Status); + Assert.True(serverInfoData.Status.FullySynched); Assert.Contains("BTC", serverInfoData.SupportedPaymentMethods); Assert.Contains("BTC_LightningLike", serverInfoData.SupportedPaymentMethods); + + Assert.NotNull(serverInfoData.Status.SyncStatus); + Assert.Single(serverInfoData.Status.SyncStatus.Select(s => s.CryptoCode == "BTC")); } } } diff --git a/BTCPayServer/Controllers/GreenField/ServerInfoController.cs b/BTCPayServer/Controllers/GreenField/ServerInfoController.cs index 255c7a480..b8de96b6d 100644 --- a/BTCPayServer/Controllers/GreenField/ServerInfoController.cs +++ b/BTCPayServer/Controllers/GreenField/ServerInfoController.cs @@ -51,9 +51,8 @@ namespace BTCPayServer.Controllers.GreenField .Select(summary => new ServerInfoSyncStatusData { CryptoCode = summary.Network.CryptoCode, - // TODO: Implement these fields - BlockHeaders = 0, - Progress = 0 + BlockHeaders = summary.Status.ChainHeight, + Progress = summary.Status.SyncHeight.GetValueOrDefault(0) / (float)summary.Status.ChainHeight }); ServerInfoStatusData status = new ServerInfoStatusData {