2019-01-04 16:42:35 +01:00
|
|
|
using System;
|
|
|
|
using System.Threading.Tasks;
|
2023-05-26 16:49:32 +02:00
|
|
|
using BTCPayServer.Client;
|
2020-05-23 21:13:18 +02:00
|
|
|
using BTCPayServer.Client.Models;
|
2019-01-04 16:42:35 +01:00
|
|
|
using BTCPayServer.Controllers;
|
2021-12-16 17:37:19 +01:00
|
|
|
using BTCPayServer.Data;
|
2019-01-04 16:42:35 +01:00
|
|
|
using BTCPayServer.Models.AppViewModels;
|
2023-03-17 03:56:32 +01:00
|
|
|
using BTCPayServer.Plugins.Crowdfund;
|
2022-07-18 20:51:53 +02:00
|
|
|
using BTCPayServer.Plugins.Crowdfund.Controllers;
|
|
|
|
using BTCPayServer.Plugins.Crowdfund.Models;
|
2019-01-04 16:42:35 +01:00
|
|
|
using BTCPayServer.Services.Apps;
|
|
|
|
using BTCPayServer.Services.Invoices;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using NBitcoin;
|
|
|
|
using NBitpayClient;
|
|
|
|
using Xunit;
|
|
|
|
using Xunit.Abstractions;
|
2019-02-19 08:01:28 +01:00
|
|
|
using static BTCPayServer.Tests.UnitTest1;
|
2019-01-04 16:42:35 +01:00
|
|
|
|
|
|
|
namespace BTCPayServer.Tests
|
|
|
|
{
|
2021-11-22 09:16:08 +01:00
|
|
|
public class CrowdfundTests : UnitTestBase
|
2019-01-04 16:42:35 +01:00
|
|
|
{
|
2021-11-22 09:16:08 +01:00
|
|
|
public CrowdfundTests(ITestOutputHelper helper) : base(helper)
|
2019-01-04 16:42:35 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-04-18 04:26:06 +02:00
|
|
|
[Fact(Timeout = LongRunningTestTimeout)]
|
2019-01-04 16:42:35 +01:00
|
|
|
[Trait("Integration", "Integration")]
|
2019-10-07 09:04:25 +02:00
|
|
|
public async Task CanCreateAndDeleteCrowdfundApp()
|
2019-01-04 16:42:35 +01:00
|
|
|
{
|
2022-01-14 09:50:29 +01:00
|
|
|
using var tester = CreateServerTester();
|
|
|
|
await tester.StartAsync();
|
|
|
|
var user = tester.NewAccount();
|
|
|
|
await user.GrantAccessAsync();
|
|
|
|
var user2 = tester.NewAccount();
|
|
|
|
await user2.GrantAccessAsync();
|
|
|
|
var apps = user.GetController<UIAppsController>();
|
|
|
|
var apps2 = user2.GetController<UIAppsController>();
|
2022-07-18 20:51:53 +02:00
|
|
|
var crowdfund = user.GetController<UICrowdfundController>();
|
2023-03-20 02:39:26 +01:00
|
|
|
var appType = CrowdfundAppType.AppType;
|
2023-03-17 03:56:32 +01:00
|
|
|
var vm = Assert.IsType<CreateAppViewModel>(Assert.IsType<ViewResult>(apps.CreateApp(user.StoreId, appType)).Model);
|
|
|
|
Assert.Equal(appType, vm.SelectedAppType);
|
2022-01-14 09:50:29 +01:00
|
|
|
Assert.Null(vm.AppName);
|
|
|
|
vm.AppName = "test";
|
2023-03-17 03:56:32 +01:00
|
|
|
var redirect = Assert.IsType<RedirectResult>(apps.CreateApp(user.StoreId, vm).Result);
|
|
|
|
Assert.EndsWith("/settings/crowdfund", redirect.Url);
|
2022-01-14 09:50:29 +01:00
|
|
|
var appList = Assert.IsType<ListAppsViewModel>(Assert.IsType<ViewResult>(apps.ListApps(user.StoreId).Result).Model);
|
|
|
|
var app = appList.Apps[0];
|
2022-07-18 20:51:53 +02:00
|
|
|
var appData = new AppData { Id = app.Id, StoreDataId = app.StoreId, Name = app.AppName, AppType = appType };
|
|
|
|
apps.HttpContext.SetAppData(appData);
|
|
|
|
crowdfund.HttpContext.SetAppData(appData);
|
2022-01-14 09:50:29 +01:00
|
|
|
var appList2 =
|
|
|
|
Assert.IsType<ListAppsViewModel>(Assert.IsType<ViewResult>(apps2.ListApps(user2.StoreId).Result).Model);
|
|
|
|
Assert.Single(appList.Apps);
|
|
|
|
Assert.Empty(appList2.Apps);
|
2023-09-11 02:59:17 +02:00
|
|
|
Assert.Equal("test", app.AppName);
|
|
|
|
Assert.Equal(apps.CreatedAppId, app.Id);
|
|
|
|
Assert.True(app.Role.ToPermissionSet(app.StoreId).Contains(Policies.CanModifyStoreSettings, app.StoreId));
|
|
|
|
Assert.Equal(user.StoreId, app.StoreId);
|
|
|
|
// Archive
|
|
|
|
redirect = Assert.IsType<RedirectResult>(apps.ToggleArchive(app.Id).Result);
|
|
|
|
Assert.EndsWith("/settings/crowdfund", redirect.Url);
|
|
|
|
appList = Assert.IsType<ListAppsViewModel>(Assert.IsType<ViewResult>(apps.ListApps(user.StoreId).Result).Model);
|
|
|
|
Assert.Empty(appList.Apps);
|
|
|
|
appList = Assert.IsType<ListAppsViewModel>(Assert.IsType<ViewResult>(apps.ListApps(user.StoreId, archived: true).Result).Model);
|
|
|
|
app = appList.Apps[0];
|
|
|
|
Assert.True(app.Archived);
|
|
|
|
Assert.IsType<NotFoundResult>(await crowdfund.ViewCrowdfund(app.Id));
|
|
|
|
// Unarchive
|
|
|
|
redirect = Assert.IsType<RedirectResult>(apps.ToggleArchive(app.Id).Result);
|
|
|
|
Assert.EndsWith("/settings/crowdfund", redirect.Url);
|
|
|
|
appList = Assert.IsType<ListAppsViewModel>(Assert.IsType<ViewResult>(apps.ListApps(user.StoreId).Result).Model);
|
|
|
|
app = appList.Apps[0];
|
|
|
|
Assert.False(app.Archived);
|
|
|
|
var crowdfundViewModel = await crowdfund.UpdateCrowdfund(app.Id).AssertViewModelAsync<UpdateCrowdfundViewModel>();
|
|
|
|
crowdfundViewModel.Enabled = true;
|
|
|
|
Assert.IsType<RedirectToActionResult>(crowdfund.UpdateCrowdfund(app.Id, crowdfundViewModel, "save").Result);
|
|
|
|
Assert.IsType<ViewResult>(await crowdfund.ViewCrowdfund(app.Id));
|
|
|
|
// Delete
|
|
|
|
Assert.IsType<NotFoundResult>(apps2.DeleteApp(app.Id));
|
|
|
|
Assert.IsType<ViewResult>(apps.DeleteApp(app.Id));
|
|
|
|
var redirectToAction = Assert.IsType<RedirectToActionResult>(apps.DeleteAppPost(app.Id).Result);
|
2023-03-17 03:56:32 +01:00
|
|
|
Assert.Equal(nameof(UIStoresController.Dashboard), redirectToAction.ActionName);
|
2022-06-20 06:34:25 +02:00
|
|
|
appList = await apps.ListApps(user.StoreId).AssertViewModelAsync<ListAppsViewModel>();
|
2022-01-14 09:50:29 +01:00
|
|
|
Assert.Empty(appList.Apps);
|
2019-01-04 16:42:35 +01:00
|
|
|
}
|
2020-06-28 10:55:27 +02:00
|
|
|
|
2021-04-18 04:26:06 +02:00
|
|
|
[Fact(Timeout = LongRunningTestTimeout)]
|
2019-01-04 16:42:35 +01:00
|
|
|
[Trait("Integration", "Integration")]
|
|
|
|
public async Task CanContributeOnlyWhenAllowed()
|
|
|
|
{
|
2022-01-14 09:50:29 +01:00
|
|
|
using var tester = CreateServerTester();
|
|
|
|
await tester.StartAsync();
|
|
|
|
var user = tester.NewAccount();
|
|
|
|
await user.GrantAccessAsync();
|
|
|
|
user.RegisterDerivationScheme("BTC");
|
|
|
|
var apps = user.GetController<UIAppsController>();
|
2022-07-18 20:51:53 +02:00
|
|
|
var crowdfund = user.GetController<UICrowdfundController>();
|
2022-06-20 06:34:25 +02:00
|
|
|
var vm = apps.CreateApp(user.StoreId).AssertViewModel<CreateAppViewModel>();
|
2023-03-20 02:39:26 +01:00
|
|
|
var appType = CrowdfundAppType.AppType;
|
2022-01-14 09:50:29 +01:00
|
|
|
vm.AppName = "test";
|
2022-06-28 07:05:02 +02:00
|
|
|
vm.SelectedAppType = appType;
|
2023-03-17 03:56:32 +01:00
|
|
|
var redirect = Assert.IsType<RedirectResult>(apps.CreateApp(user.StoreId, vm).Result);
|
|
|
|
Assert.EndsWith("/settings/crowdfund", redirect.Url);
|
2022-01-14 09:50:29 +01:00
|
|
|
var appList = Assert.IsType<ListAppsViewModel>(Assert.IsType<ViewResult>(apps.ListApps(user.StoreId).Result).Model);
|
|
|
|
var app = appList.Apps[0];
|
2022-07-18 20:51:53 +02:00
|
|
|
var appData = new AppData { Id = app.Id, StoreDataId = app.StoreId, Name = app.AppName, AppType = appType };
|
|
|
|
apps.HttpContext.SetAppData(appData);
|
|
|
|
crowdfund.HttpContext.SetAppData(appData);
|
2020-06-28 10:55:27 +02:00
|
|
|
|
2022-01-14 09:50:29 +01:00
|
|
|
//Scenario 1: Not Enabled - Not Allowed
|
2022-07-18 20:51:53 +02:00
|
|
|
var crowdfundViewModel = await crowdfund.UpdateCrowdfund(app.Id).AssertViewModelAsync<UpdateCrowdfundViewModel>();
|
2022-01-14 09:50:29 +01:00
|
|
|
crowdfundViewModel.TargetCurrency = "BTC";
|
|
|
|
crowdfundViewModel.Enabled = false;
|
|
|
|
crowdfundViewModel.EndDate = null;
|
2020-06-28 10:55:27 +02:00
|
|
|
|
2022-07-18 20:51:53 +02:00
|
|
|
Assert.IsType<RedirectToActionResult>(crowdfund.UpdateCrowdfund(app.Id, crowdfundViewModel, "save").Result);
|
2020-06-28 10:55:27 +02:00
|
|
|
|
2022-07-22 15:41:14 +02:00
|
|
|
var anonAppPubsController = tester.PayTester.GetController<UICrowdfundController>();
|
|
|
|
var crowdfundController = user.GetController<UICrowdfundController>();
|
2021-12-31 08:59:02 +01:00
|
|
|
|
2022-01-14 09:50:29 +01:00
|
|
|
Assert.IsType<NotFoundObjectResult>(await anonAppPubsController.ContributeToCrowdfund(app.Id, new ContributeToCrowdfund()
|
|
|
|
{
|
|
|
|
Amount = new decimal(0.01)
|
|
|
|
}, default));
|
2020-06-28 10:55:27 +02:00
|
|
|
|
2023-03-17 03:56:32 +01:00
|
|
|
Assert.IsType<NotFoundResult>(await anonAppPubsController.ViewCrowdfund(app.Id));
|
2020-06-28 10:55:27 +02:00
|
|
|
|
2022-01-14 09:50:29 +01:00
|
|
|
//Scenario 2: Not Enabled But Admin - Allowed
|
2022-07-22 15:41:14 +02:00
|
|
|
Assert.IsType<OkObjectResult>(await crowdfundController.ContributeToCrowdfund(app.Id, new ContributeToCrowdfund()
|
2022-01-14 09:50:29 +01:00
|
|
|
{
|
|
|
|
RedirectToCheckout = false,
|
|
|
|
Amount = new decimal(0.01)
|
|
|
|
}, default));
|
2023-03-17 03:56:32 +01:00
|
|
|
Assert.IsType<ViewResult>(await crowdfundController.ViewCrowdfund(app.Id));
|
|
|
|
Assert.IsType<NotFoundResult>(await anonAppPubsController.ViewCrowdfund(app.Id));
|
2020-06-28 10:55:27 +02:00
|
|
|
|
2022-01-14 09:50:29 +01:00
|
|
|
//Scenario 3: Enabled But Start Date > Now - Not Allowed
|
|
|
|
crowdfundViewModel.StartDate = DateTime.Today.AddDays(2);
|
|
|
|
crowdfundViewModel.Enabled = true;
|
2020-06-28 10:55:27 +02:00
|
|
|
|
2022-07-18 20:51:53 +02:00
|
|
|
Assert.IsType<RedirectToActionResult>(crowdfund.UpdateCrowdfund(app.Id, crowdfundViewModel, "save").Result);
|
2022-01-14 09:50:29 +01:00
|
|
|
Assert.IsType<NotFoundObjectResult>(await anonAppPubsController.ContributeToCrowdfund(app.Id, new ContributeToCrowdfund()
|
|
|
|
{
|
|
|
|
Amount = new decimal(0.01)
|
|
|
|
}, default));
|
2020-06-28 10:55:27 +02:00
|
|
|
|
2022-01-14 09:50:29 +01:00
|
|
|
//Scenario 4: Enabled But End Date < Now - Not Allowed
|
|
|
|
crowdfundViewModel.StartDate = DateTime.Today.AddDays(-2);
|
|
|
|
crowdfundViewModel.EndDate = DateTime.Today.AddDays(-1);
|
|
|
|
crowdfundViewModel.Enabled = true;
|
2020-06-28 10:55:27 +02:00
|
|
|
|
2022-07-18 20:51:53 +02:00
|
|
|
Assert.IsType<RedirectToActionResult>(crowdfund.UpdateCrowdfund(app.Id, crowdfundViewModel, "save").Result);
|
2022-01-14 09:50:29 +01:00
|
|
|
Assert.IsType<NotFoundObjectResult>(await anonAppPubsController.ContributeToCrowdfund(app.Id, new ContributeToCrowdfund()
|
|
|
|
{
|
|
|
|
Amount = new decimal(0.01)
|
|
|
|
}, default));
|
2020-06-28 10:55:27 +02:00
|
|
|
|
2022-01-14 09:50:29 +01:00
|
|
|
//Scenario 5: Enabled and within correct timeframe, however target is enforced and Amount is Over - Not Allowed
|
|
|
|
crowdfundViewModel.StartDate = DateTime.Today.AddDays(-2);
|
|
|
|
crowdfundViewModel.EndDate = DateTime.Today.AddDays(2);
|
|
|
|
crowdfundViewModel.Enabled = true;
|
|
|
|
crowdfundViewModel.TargetAmount = 1;
|
|
|
|
crowdfundViewModel.TargetCurrency = "BTC";
|
|
|
|
crowdfundViewModel.EnforceTargetAmount = true;
|
2022-07-18 20:51:53 +02:00
|
|
|
Assert.IsType<RedirectToActionResult>(crowdfund.UpdateCrowdfund(app.Id, crowdfundViewModel, "save").Result);
|
2022-01-14 09:50:29 +01:00
|
|
|
Assert.IsType<NotFoundObjectResult>(await anonAppPubsController.ContributeToCrowdfund(app.Id, new ContributeToCrowdfund()
|
|
|
|
{
|
|
|
|
Amount = new decimal(1.01)
|
|
|
|
}, default));
|
2020-06-28 10:55:27 +02:00
|
|
|
|
2022-01-14 09:50:29 +01:00
|
|
|
//Scenario 6: Allowed
|
|
|
|
Assert.IsType<OkObjectResult>(await anonAppPubsController.ContributeToCrowdfund(app.Id, new ContributeToCrowdfund()
|
|
|
|
{
|
|
|
|
Amount = new decimal(0.05)
|
|
|
|
}, default));
|
2019-01-04 16:42:35 +01:00
|
|
|
}
|
|
|
|
|
2021-04-18 04:26:06 +02:00
|
|
|
[Fact(Timeout = LongRunningTestTimeout)]
|
2019-01-04 16:42:35 +01:00
|
|
|
[Trait("Integration", "Integration")]
|
2019-10-07 09:04:25 +02:00
|
|
|
public async Task CanComputeCrowdfundModel()
|
2019-01-04 16:42:35 +01:00
|
|
|
{
|
2022-01-14 09:50:29 +01:00
|
|
|
using var tester = CreateServerTester();
|
|
|
|
await tester.StartAsync();
|
|
|
|
var user = tester.NewAccount();
|
|
|
|
await user.GrantAccessAsync();
|
|
|
|
user.RegisterDerivationScheme("BTC");
|
|
|
|
await user.SetNetworkFeeMode(NetworkFeeMode.Never);
|
|
|
|
var apps = user.GetController<UIAppsController>();
|
2022-07-18 20:51:53 +02:00
|
|
|
var crowdfund = user.GetController<UICrowdfundController>();
|
2022-01-14 09:50:29 +01:00
|
|
|
var vm = Assert.IsType<CreateAppViewModel>(Assert.IsType<ViewResult>(apps.CreateApp(user.StoreId)).Model);
|
2023-03-20 02:39:26 +01:00
|
|
|
var appType = CrowdfundAppType.AppType;
|
2022-01-14 09:50:29 +01:00
|
|
|
vm.AppName = "test";
|
2022-06-28 07:05:02 +02:00
|
|
|
vm.SelectedAppType = appType;
|
2023-03-17 03:56:32 +01:00
|
|
|
Assert.IsType<RedirectResult>(apps.CreateApp(user.StoreId, vm).Result);
|
2022-01-14 09:50:29 +01:00
|
|
|
var appList = Assert.IsType<ListAppsViewModel>(Assert.IsType<ViewResult>(apps.ListApps(user.StoreId).Result).Model);
|
|
|
|
var app = appList.Apps[0];
|
2022-07-18 20:51:53 +02:00
|
|
|
var appData = new AppData { Id = app.Id, StoreDataId = app.StoreId, Name = app.AppName, AppType = appType };
|
|
|
|
apps.HttpContext.SetAppData(appData);
|
|
|
|
crowdfund.HttpContext.SetAppData(appData);
|
2019-02-19 08:01:28 +01:00
|
|
|
|
2022-01-14 09:50:29 +01:00
|
|
|
TestLogs.LogInformation("We create an invoice with a hardcap");
|
2022-07-18 20:51:53 +02:00
|
|
|
var crowdfundViewModel = await crowdfund.UpdateCrowdfund(app.Id).AssertViewModelAsync<UpdateCrowdfundViewModel>();
|
2022-01-14 09:50:29 +01:00
|
|
|
crowdfundViewModel.Enabled = true;
|
|
|
|
crowdfundViewModel.EndDate = null;
|
|
|
|
crowdfundViewModel.TargetAmount = 100;
|
|
|
|
crowdfundViewModel.TargetCurrency = "BTC";
|
|
|
|
crowdfundViewModel.UseAllStoreInvoices = true;
|
|
|
|
crowdfundViewModel.EnforceTargetAmount = true;
|
2022-07-18 20:51:53 +02:00
|
|
|
Assert.IsType<RedirectToActionResult>(crowdfund.UpdateCrowdfund(app.Id, crowdfundViewModel, "save").Result);
|
2020-06-28 10:55:27 +02:00
|
|
|
|
2022-07-22 15:41:14 +02:00
|
|
|
var publicApps = user.GetController<UICrowdfundController>();
|
2019-01-04 16:42:35 +01:00
|
|
|
|
2022-01-14 09:50:29 +01:00
|
|
|
var model = Assert.IsType<ViewCrowdfundViewModel>(Assert
|
2023-03-17 03:56:32 +01:00
|
|
|
.IsType<ViewResult>(publicApps.ViewCrowdfund(app.Id).Result).Model);
|
2021-12-31 08:59:02 +01:00
|
|
|
|
2022-01-14 09:50:29 +01:00
|
|
|
Assert.Equal(crowdfundViewModel.TargetAmount, model.TargetAmount);
|
|
|
|
Assert.Equal(crowdfundViewModel.EndDate, model.EndDate);
|
|
|
|
Assert.Equal(crowdfundViewModel.StartDate, model.StartDate);
|
|
|
|
Assert.Equal(crowdfundViewModel.TargetCurrency, model.TargetCurrency);
|
|
|
|
Assert.Equal(0m, model.Info.CurrentAmount);
|
|
|
|
Assert.Equal(0m, model.Info.CurrentPendingAmount);
|
|
|
|
Assert.Equal(0m, model.Info.ProgressPercentage);
|
2021-12-31 08:59:02 +01:00
|
|
|
|
2022-01-14 09:50:29 +01:00
|
|
|
TestLogs.LogInformation("Unpaid invoices should show as pending contribution because it is hardcap");
|
|
|
|
TestLogs.LogInformation("Because UseAllStoreInvoices is true, we can manually create an invoice and it should show as contribution");
|
|
|
|
var invoice = await user.BitPay.CreateInvoiceAsync(new Invoice
|
|
|
|
{
|
|
|
|
Buyer = new Buyer() { email = "test@fwf.com" },
|
|
|
|
Price = 1m,
|
|
|
|
Currency = "BTC",
|
|
|
|
PosData = "posData",
|
|
|
|
ItemDesc = "Some description",
|
|
|
|
TransactionSpeed = "high",
|
|
|
|
FullNotifications = true
|
|
|
|
}, Facade.Merchant);
|
2021-12-31 08:59:02 +01:00
|
|
|
|
2022-01-14 09:50:29 +01:00
|
|
|
model = Assert.IsType<ViewCrowdfundViewModel>(Assert
|
2023-03-17 03:56:32 +01:00
|
|
|
.IsType<ViewResult>(publicApps.ViewCrowdfund(app.Id).Result).Model);
|
2020-06-28 10:55:27 +02:00
|
|
|
|
2022-01-14 09:50:29 +01:00
|
|
|
Assert.Equal(0m, model.Info.CurrentAmount);
|
|
|
|
Assert.Equal(1m, model.Info.CurrentPendingAmount);
|
|
|
|
Assert.Equal(0m, model.Info.ProgressPercentage);
|
|
|
|
Assert.Equal(1m, model.Info.PendingProgressPercentage);
|
2019-01-04 16:42:35 +01:00
|
|
|
|
2022-01-14 09:50:29 +01:00
|
|
|
TestLogs.LogInformation("Let's check current amount change once payment is confirmed");
|
|
|
|
var invoiceAddress = BitcoinAddress.Create(invoice.CryptoInfo[0].Address, tester.ExplorerNode.Network);
|
2023-03-17 03:56:32 +01:00
|
|
|
await tester.ExplorerNode.SendToAddressAsync(invoiceAddress, invoice.BtcDue);
|
|
|
|
await tester.ExplorerNode.GenerateAsync(1); // By default invoice confirmed at 1 block
|
2022-01-14 09:50:29 +01:00
|
|
|
TestUtils.Eventually(() =>
|
|
|
|
{
|
|
|
|
model = Assert.IsType<ViewCrowdfundViewModel>(Assert
|
2023-03-17 03:56:32 +01:00
|
|
|
.IsType<ViewResult>(publicApps.ViewCrowdfund(app.Id).Result).Model);
|
2022-01-14 09:50:29 +01:00
|
|
|
Assert.Equal(1m, model.Info.CurrentAmount);
|
|
|
|
Assert.Equal(0m, model.Info.CurrentPendingAmount);
|
|
|
|
});
|
2019-02-19 08:01:28 +01:00
|
|
|
|
2022-01-14 09:50:29 +01:00
|
|
|
TestLogs.LogInformation("Because UseAllStoreInvoices is true, let's make sure the invoice is tagged");
|
|
|
|
var invoiceEntity = tester.PayTester.InvoiceRepository.GetInvoice(invoice.Id).GetAwaiter().GetResult();
|
|
|
|
Assert.True(invoiceEntity.Version >= InvoiceEntity.InternalTagSupport_Version);
|
|
|
|
Assert.Contains(AppService.GetAppInternalTag(app.Id), invoiceEntity.InternalTags);
|
2019-02-19 04:59:12 +01:00
|
|
|
|
2022-01-14 09:50:29 +01:00
|
|
|
crowdfundViewModel.UseAllStoreInvoices = false;
|
2022-07-18 20:51:53 +02:00
|
|
|
Assert.IsType<RedirectToActionResult>(crowdfund.UpdateCrowdfund(app.Id, crowdfundViewModel, "save").Result);
|
2019-02-19 04:59:12 +01:00
|
|
|
|
2022-01-14 09:50:29 +01:00
|
|
|
TestLogs.LogInformation("Because UseAllStoreInvoices is false, let's make sure the invoice is not tagged");
|
|
|
|
invoice = await user.BitPay.CreateInvoiceAsync(new Invoice
|
|
|
|
{
|
|
|
|
Buyer = new Buyer { email = "test@fwf.com" },
|
|
|
|
Price = 1m,
|
|
|
|
Currency = "BTC",
|
|
|
|
PosData = "posData",
|
|
|
|
ItemDesc = "Some description",
|
|
|
|
TransactionSpeed = "high",
|
|
|
|
FullNotifications = true
|
|
|
|
}, Facade.Merchant);
|
|
|
|
invoiceEntity = tester.PayTester.InvoiceRepository.GetInvoice(invoice.Id).GetAwaiter().GetResult();
|
|
|
|
Assert.DoesNotContain(AppService.GetAppInternalTag(app.Id), invoiceEntity.InternalTags);
|
2019-02-19 08:01:28 +01:00
|
|
|
|
2022-01-14 09:50:29 +01:00
|
|
|
TestLogs.LogInformation("After turning setting a softcap, let's check that only actual payments are counted");
|
|
|
|
crowdfundViewModel.EnforceTargetAmount = false;
|
|
|
|
crowdfundViewModel.UseAllStoreInvoices = true;
|
2022-07-18 20:51:53 +02:00
|
|
|
Assert.IsType<RedirectToActionResult>(crowdfund.UpdateCrowdfund(app.Id, crowdfundViewModel, "save").Result);
|
2022-01-14 09:50:29 +01:00
|
|
|
invoice = await user.BitPay.CreateInvoiceAsync(new Invoice
|
|
|
|
{
|
|
|
|
Buyer = new Buyer { email = "test@fwf.com" },
|
|
|
|
Price = 1m,
|
|
|
|
Currency = "BTC",
|
|
|
|
PosData = "posData",
|
|
|
|
ItemDesc = "Some description",
|
|
|
|
TransactionSpeed = "high",
|
|
|
|
FullNotifications = true
|
|
|
|
}, Facade.Merchant);
|
|
|
|
Assert.Equal(0m, model.Info.CurrentPendingAmount);
|
|
|
|
invoiceAddress = BitcoinAddress.Create(invoice.CryptoInfo[0].Address, tester.ExplorerNode.Network);
|
|
|
|
await tester.ExplorerNode.SendToAddressAsync(invoiceAddress, Money.Coins(0.5m));
|
|
|
|
await tester.ExplorerNode.SendToAddressAsync(invoiceAddress, Money.Coins(0.2m));
|
|
|
|
TestUtils.Eventually(() =>
|
|
|
|
{
|
|
|
|
model = Assert.IsType<ViewCrowdfundViewModel>(Assert
|
2023-03-17 03:56:32 +01:00
|
|
|
.IsType<ViewResult>(publicApps.ViewCrowdfund(app.Id).Result).Model);
|
2022-01-14 09:50:29 +01:00
|
|
|
Assert.Equal(0.7m, model.Info.CurrentPendingAmount);
|
|
|
|
});
|
2019-01-04 16:42:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|