Add sync state

This commit is contained in:
Dennis Reimann 2020-05-18 16:02:15 +02:00
parent e3b348b55c
commit 3b6dbe76c5
No known key found for this signature in database
GPG Key ID: 5009E1797F03F8D0
3 changed files with 10 additions and 7 deletions

View File

@ -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; }
}
}

View File

@ -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"));
}
}
}

View File

@ -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
{