feat: open payto links on the pay form, and take the checkout over D-Bus out

An app could have nostrod pay an order: it called Pay of
net.catcrafts.Nostro1.Checkout on the system bus, and nostrod paid from
an account the user had chosen, after a dialog of its own. On 2026-11-22
the owner decided that a link takes its place. The app registers for
payto links (RFC 8905), so that an app or a website can hand one to the
desktop, and shows a link as its pay form filled in.

The link:

- The app's desktop entry takes the scheme (Exec=nostro-app %u,
  MimeType=x-scheme-handler/payto), and nostro-app takes an argument
  that is no option as a link: it overwrites it in argv and hands it to
  App::Open once the app has started.
- ReadPaymentLink (Nostro.App:Forms) reads payto://iban/<IBAN> with the
  options amount, receiver-name and message, and refuses a link rather
  than guess at it, in a sentence of the app's own with nothing of the
  link in it. Among what it refuses: an IBAN whose check digits do not
  hold, one of the three options given twice, instruction, a comma in
  the amount, and a name or a message with a code point that is Unshown,
  or Blank and no plain space.
- A link that is read waits until the accounts are read and
  DefaultCheckoutAccount has answered or failed, with a line on the
  accounts' page. Then App::TakeLink fills in the pay form, which says
  in a banner that a link filled it in, and with more than one account
  opens it under the choice of accounts that the form's From row has. A
  link pays nothing: the form's button sends, and polkit's dialog
  confirms as for any payment (design rule 12, and 14, which is new).
- Unshown and Blank are the two tables the worker's Shown() works from.
  They move into Nostro:Utils, where the app's reader asks them too.
  The move is within the library. The reader holds a link's name to
  those two and to no more of Shown(): a name with an & is read, and
  the dialog shows it with a + as it does any name.

The checkout:

- nostrod serves one interface under one bus name. Gone are
  net.catcrafts.Nostro1.Checkout with its XML and its activation file,
  the polkit action Checkout, the module Nostro.Checkout with
  --product=checkout, and the worker's record of orders. That changes
  the published contract after a release, 0.0.0, and design rule 10
  records it as the owner's decision.
- DefaultCheckoutAccount and SetDefaultCheckoutAccount keep their names
  and signatures. The account they keep is where a link's pay form
  starts: nostrod's dialog for choosing it says "have pay links start
  from", the app's setting reads "Pay links start from", and `nostro
  checkout account` prints "pay links start from".
- The D-Bus policy still lets nostrod own the old name: the nostrod of
  0.0.0 asks for it when it starts, and the system files can be newer
  than the Flatpak it runs from. install.sh removes the old name's
  activation file. A user's checkouts.cdb is read by nothing any more,
  and is left where it is.
- The Arch package stops installing the checkout's two files, and its
  pkgrel goes up to 2. Where makepkg -si finds a package of the version
  already built it installs that one again, which would bring the
  activation file back. The guide now says that pkgrel goes up with a
  change to what the package installs.
- Bus::Interface goes too: the worker called it in two places, to tell
  a call to the checkout from one to the main interface.

The review's own files follow. gate0 loses the build of
--product=checkout, and the three lens sections that named the checkout
no longer do, and ask about a link.

The README has "Pay links" in place of "Checkout for apps", and
AGENTS.consumer.md says what the app reads of a link. Its line on
lib/json.hpp no longer gives a release: the file is of none, and the
guide names its commit. The pay form and the accounts' page change only
by a banner each, shown while a link is in play, which
docs/screenshots/take.sh never has: the README's pictures stand.

Tests: ShouldValidateForms reads and refuses links and fills the form
from one. ShouldDriveTheApp opens links against a real nostrod on the
fake bus: before the accounts are known, with no account, with one and
with several, with the accounts known and the system bus gone, for a
second user whose first connection pays their own accounts only, one
that cannot be read, one whose name has an &, and through polkit's
dialog to the payment. It now counts nostrod's answers to hold that the
account pay links start from is read again once a connection is
removed: the check it had there passed without that.
ShouldHandleMoneyAndText holds the two tables at the ends of their
ranges. ShouldServeEveryUser holds that nostrod serves no checkout, that
the bus's policy lets an older nostrod own the old name, and the account
pay links start from. ShouldRunCommands holds the CLI's wording.

The review's gate0 passes at this commit: the version check, 17 tests,
the builds of the CLI, the library, nostrod, the fake system, the app
and its --debug-api build, and five lint runs that report nothing.
tests/coverage.sh reports lines, functions and regions at 100.00%.

Looked at on 2026-11-22 on the made-up system (run fake), on a desktop
(KWin at a scale of 1.85). At 420x760, at --scale 3 --size 360x760 and
at 1100x720 in the light look: a link's pay form under the choice of
accounts, the form after a tap beside that choice, and the accounts'
page while a link waits, its line above the rows that stand in for the
accounts (--bank-delay 10000). At 420x760: that line above what the
page says when the accounts cannot be read (--polkit deny) and above
the accounts themselves (--polkit slow, the link opened in the running
app), the settings' row and page for the account pay links start from,
the sheet for a link that cannot be read, and with --empty the sheet
for no account.
This commit is contained in:
Jorijn van der Graaf 2026-11-22 13:35:51 +01:00
commit b43ab124a6
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
42 changed files with 1234 additions and 994 deletions

View file

@ -3,9 +3,9 @@
// nostrod on a fake system bus (tests/Support/FakeBus.inc) in front of a fake bunq (tests/Support/FakeBunq.inc): the
// daemon and its workers are this executable again (nostrod's main is compiled in), every call goes through
// Nostro::Client or Nostro::Checkout, and the bus plays each user by the uid it gives a connection. Users kept apart, a
// uid handed to a new user, every polkit answer and what the dialog is told, calls that wait on each other or do not,
// checkouts and their retries, workers that die, idle exits, and how each error reaches the client.
// Nostro::Client, and the bus plays each user by the uid it gives a connection. Users kept apart, a uid handed to a new
// user, every polkit answer and what the dialog is told, calls that wait on each other or do not, the account pay
// links start from, workers that die, idle exits, and how each error reaches the client.
#include "../../lib/json.hpp"
#include <poll.h>
@ -22,7 +22,6 @@
import std;
import Nostro;
import Nostro.Checkout;
import Crafter.Network;
#define main NostrodMain
@ -46,6 +45,7 @@ namespace {
constexpr std::uint32_t aliceUid = 4242;
constexpr std::uint32_t bobUid = 4343;
constexpr std::string_view name = "net.catcrafts.Nostro1";
// The second name nostrod had until 2026-11-22, for a checkout over D-Bus that is gone.
constexpr std::string_view checkoutName = "net.catcrafts.Nostro1.Checkout";
const std::string aliceMain = "NL23BUNQ2025123456";
const std::string aliceOther = "NL46BUNQ2025111111";
@ -76,8 +76,6 @@ namespace {
call();
} catch(const DaemonError& e) {
return Failure{e.name, e.what()};
} catch(const Checkout::Error& e) {
return Failure{e.name, e.what()};
} catch(const std::exception& e) {
return Failure{"exception", e.what()};
}
@ -203,22 +201,25 @@ namespace {
return served;
}
// The published contract: packaging/dbus/net.catcrafts.Nostro1.xml and net.catcrafts.Nostro1.Checkout.xml are the
// interfaces nostrod serves, each under its own name alone, and the polkit policy declares every action nostrod asks
// about and no other, each owned by the user nostrod runs as, with a dialog that uses no detail nostrod does not set,
// and each but seeing asking for the user's password as it is shipped.
// The published contract: packaging/dbus/net.catcrafts.Nostro1.xml is the interface nostrod serves, under the one
// name it has, and the polkit policy declares every action nostrod asks about and no other, each owned by the user
// nostrod runs as, with a dialog that uses no detail nostrod does not set, and each but seeing asking for the
// user's password as it is shipped.
void Contract(Fake::Bus& bus) {
const std::string served = Introspect(bus, name);
Check(Interface(served, name) == Interface(Slurp("packaging/dbus/net.catcrafts.Nostro1.xml"), name), std::format("packaging/dbus/net.catcrafts.Nostro1.xml is the interface nostrod serves, which is:\n{}", served));
const std::string checkout = Introspect(bus, checkoutName);
Check(Interface(checkout, checkoutName) == Interface(Slurp("packaging/dbus/net.catcrafts.Nostro1.Checkout.xml"), checkoutName), std::format("packaging/dbus/net.catcrafts.Nostro1.Checkout.xml is the checkout nostrod serves, which is:\n{}", checkout));
// An app allowed to talk to the checkout's name reaches nothing else through it.
Check(Interface(served, checkoutName).empty() && Interface(checkout, name).empty(), "each name serves its own interface alone");
Check(!Raw(bus, checkoutName, name, "Connectors", true, [](sd_bus_message*) {}).empty(), "the checkout's name answers no other method");
const std::string payHere = Raw(bus, name, checkoutName, "Pay", true, [](sd_bus_message* call) {
// nostrod has no checkout: the interface that paid an app's order is gone, with its name. What a shop wants
// paid reaches the user as a link, which only the app shows, and only as a form.
const auto order = [](sd_bus_message* call) {
sd_bus_message_append(call, "ssxssa{sv}", shopIban.c_str(), "Shop", std::int64_t{100}, "EUR", "1", 0u);
});
Check(!payHere.empty(), "and the other name pays no checkout");
};
Check(Interface(served, checkoutName).empty() && !fs::exists("packaging/dbus/net.catcrafts.Nostro1.Checkout.xml"), "nostrod serves no checkout, and none is published");
Equal(Raw(bus, checkoutName, checkoutName, "Pay", true, order), std::string(SD_BUS_ERROR_SERVICE_UNKNOWN), "nobody owns the name a checkout had");
Check(!Raw(bus, name, checkoutName, "Pay", true, order).empty() && !Raw(bus, name, name, "Pay", true, order).empty(), "and nostrod's own name pays no order");
// The bus's policy still lets nostrod own that name: the nostrod of 0.0.0 asks for it when it starts, and the
// system files may be newer than the Flatpak it runs from. It lets nobody call it.
const std::string busPolicy = Slurp("packaging/system/net.catcrafts.Nostro1.conf");
Check(busPolicy.contains(std::format("<allow own=\"{}\"/>", checkoutName)) && !busPolicy.contains(std::format("send_destination=\"{}\"", checkoutName)), "the bus's policy lets an older nostrod own the name it had, and lets nobody call it");
const std::string policy = Slurp("packaging/system/net.catcrafts.Nostro1.policy");
std::vector<std::string> declared;
@ -235,7 +236,7 @@ namespace {
Check(action.substr(key).starts_with("$(summary)"), std::format("{} shows only details nostrod sets", declared.back()));
}
}
const std::vector<std::string> asked = {std::string(Bus::actionView), std::string(Bus::actionChange), std::string(Bus::actionPay), std::string(Bus::actionUnfreezeCard), std::string(Bus::actionBlockCard), std::string(Bus::actionConnectors), std::string(Bus::actionCheckout)};
const std::vector<std::string> asked = {std::string(Bus::actionView), std::string(Bus::actionChange), std::string(Bus::actionPay), std::string(Bus::actionUnfreezeCard), std::string(Bus::actionBlockCard), std::string(Bus::actionConnectors)};
Check(std::ranges::is_permutation(declared, asked), "the policy declares the actions nostrod asks about, and no other");
}
@ -458,7 +459,7 @@ namespace {
{"answering a request", [&alice] { alice.RespondToRequest(aliceMain, 1, true); }, "see your incoming requests for money"},
{"answering a draft", [&alice] { alice.RespondToDraftPayment(aliceMain, 1, false); }, "see your draft payments"},
{"a card's status", [&alice] { alice.SetCardStatus(1, "LOST"); }, "see your cards"},
{"the account that pays at checkout", [&alice] { alice.SetDefaultCheckoutAccount("Nope"); }, accounts},
{"the account pay links start from", [&alice] { alice.SetDefaultCheckoutAccount("Nope"); }, accounts},
{"removing a connector", [&alice] { alice.RemoveConnector("Nobody"); }, "see your bank connectors"},
{"the transactions of an account nobody has", [&alice] { alice.Transactions("Nope", {}); }, "see your transactions"},
{"a listing of one", [&alice] { alice.Requests("Nope"); }, "see your requests for money"},
@ -602,216 +603,26 @@ namespace {
Equal(unknown, std::string(), "a query key nostrod does not know");
}
// A stand-in for nostrod's checkout, for answers nostrod never gives, chosen by the order's reference: "extra", a
// result the client does not know; "shape", an answer of another shape; "odd", an error of another name; "bare", an
// error without a message; anything else, no answer at all. A plain object rather than a vtable, whose answers sd-bus would hold to its signature.
class FakeCheckout {
public:
FakeCheckout() {
sd_bus_open_system(&bus);
sd_bus_add_object(bus, nullptr, "/net/catcrafts/Nostro1", OnCall, nullptr);
sd_bus_request_name(bus, "net.catcrafts.Nostro1.Checkout", 0);
thread = std::thread([this] {
while(!stop) {
while(sd_bus_process(bus, nullptr) > 0) {
}
sd_bus_wait(bus, 20000);
}
});
}
FakeCheckout(const FakeCheckout&) = delete;
FakeCheckout& operator=(const FakeCheckout&) = delete;
~FakeCheckout() {
stop = true;
thread.join();
sd_bus_flush_close_unref(bus);
}
private:
static std::int32_t OnCall(sd_bus_message* call, void*, sd_bus_error*) {
if(!sd_bus_message_is_method_call(call, "net.catcrafts.Nostro1.Checkout", "Pay")) {
return 0;
}
sd_bus_message_skip(call, "ssxs");
// sd-bus hands strings out as C strings.
// lint-disable-next-line no-char-pointer
const char* reference = nullptr;
sd_bus_message_read_basic(call, 's', &reference);
const std::string_view kind(reference);
if(kind == "extra") {
return sd_bus_reply_method_return(call, "ta{sv}", std::uint64_t{7}, 2u, "colour", "s", "blue", "repeated", "b", 1);
}
if(kind == "shape") {
return sd_bus_reply_method_return(call, "s", "nonsense");
}
if(kind == "odd") {
return sd_bus_reply_method_errorf(call, "org.example.Odd", "an error of another name");
}
if(kind == "bare") {
const sd_bus_error bare = {"org.example.Bare", nullptr, 0};
return sd_bus_reply_method_error(call, &bare);
}
return 1;
}
sd_bus* bus = nullptr;
std::thread thread;
std::atomic<bool> stop{false};
};
// Nostro.Checkout's own side: with no nostro on the bus, and against a stand-in for nostrod's checkout.
void CheckoutClient(Fake::Bus& bus) {
Checkout::Order order{.payeeIban = shopIban, .payeeName = "Shop", .amount = 1250, .reference = "1"};
const Failure missing = FailureOf([&order] { Checkout::Pay(order); });
Check(missing.name == SD_BUS_ERROR_SERVICE_UNKNOWN && missing.message.contains("nostro is not installed"), std::format("a checkout without nostro: {}", missing.message));
Throws<std::invalid_argument>([] { Checkout::Pay({.payeeIban = "\xFF", .amount = 1, .reference = "1"}); }, "not UTF-8", "an order that is not UTF-8");
const auto pay = [&order](std::string_view reference, std::chrono::seconds timeout) {
order.reference = std::string(reference);
return Checkout::Pay(order, timeout);
};
{
const FakeCheckout stand;
Check(bus.WaitForName(checkoutName), "a stand-in for nostrod's checkout");
const Checkout::Paid extra = pay("extra", std::chrono::seconds(20));
Check(extra.paymentId == 7 && extra.repeated, "results the client does not know are skipped");
Throws<std::system_error>([&pay] { pay("shape", std::chrono::seconds(20)); }, "cannot read nostrod's answer", "an answer of another shape");
const Failure odd = FailureOf([&pay] { pay("odd", std::chrono::seconds(20)); });
Check(odd.name == "org.example.Odd" && odd.message == "an error of another name", "an error of another name, as it came");
const Failure bare = FailureOf([&pay] { pay("bare", std::chrono::seconds(20)); });
Check(bare.name == "org.example.Bare" && bare.message.empty(), "and one without a message");
const Failure late = FailureOf([&pay] { pay("silent", std::chrono::seconds(1)); });
Check(late.name == SD_BUS_ERROR_TIMEOUT && late.message.contains("the order may have been paid"), std::format("no answer in time: {}", late.message));
}
Check(bus.WaitForName(checkoutName, false), "and the stand-in gone");
}
// nostrod's side of a checkout: the account that pays, the prompt, the record that answers a retry, and every way an
// order is refused.
void Checkouts(Fake::Bus& bus, Fake::Bunq& bunq, const Bank& bank) {
// The account a pay link's form starts from in the app, which nostrod keeps for the user and pays nothing from by
// itself: none until one is chosen, never one that could pay no shop, chosen with the password that changing the
// connections takes, and no longer chosen once the account is gone.
void CheckoutAccount(Fake::Bus& bus, Fake::Bunq& bunq, const Bank& bank) {
Client alice = As(bus, aliceUid);
const auto pay = [&bus](const Checkout::Order& order) {
{
std::lock_guard lock(bus.mutex);
bus.clientUid = aliceUid;
}
return Checkout::Pay(order);
};
const auto checks = [&bus](std::string_view reference) {
std::lock_guard lock(bus.mutex);
return std::ranges::count_if(bus.checks, [reference](const Fake::PolkitCheck& check) { return check.details.contains("reference") && check.details.at("reference") == reference; });
};
const std::string payments = std::format("/user/{}/monetary-account/{}/payment", bank.alice, bank.aliceMainId);
const Checkout::Order order{.payeeIban = shopIban, .payeeName = "Shop", .amount = 1250, .reference = "order-1"};
Check(!alice.DefaultCheckoutAccount().has_value() && Summary(bus) == "see which account pays at checkout", "no account pays at checkout until one is chosen");
Throws<Checkout::NoCheckoutAccount>([&pay, &order] { pay(order); }, "no account is chosen to pay checkouts from", "a checkout before an account is chosen");
Check(!alice.DefaultCheckoutAccount().has_value() && Summary(bus) == "see which account pay links start from", "no account is the one pay links start from until one is chosen");
Throws<std::invalid_argument>([&alice] { alice.SetDefaultCheckoutAccount(carolIban); }, "is reached through OAuth, which pays only your own accounts", "an account that could pay no shop");
const Account chosen = alice.SetDefaultCheckoutAccount(aliceMain);
Check(chosen.iban == aliceMain && chosen.name == "Main", "an account chosen, and shown");
Check(bus.LastCheck().action == "net.catcrafts.Nostro1.Connectors" && Summary(bus) == std::format("let apps ask you to pay from {} (Main) at checkout", aliceMain), "choosing it is a change to the connections");
Equal(alice.DefaultCheckoutAccount().value_or(Account{}).iban, aliceMain, "the account checkouts pay from");
const std::size_t before = bunq.Count("POST", payments);
const Checkout::Paid paid = pay(order);
Check(paid.paymentId != 0 && !paid.repeated, "an order paid");
const Fake::PolkitCheck check = bus.LastCheck();
Equal(check.action, std::string("net.catcrafts.Nostro1.Checkout"), "paying at checkout is an action of its own");
Equal(check.details.at("summary"), std::format("pay €12.50 to {} (Shop) from {} (Main), as an app asks at checkout, reference order-1", shopIban, aliceMain), "the dialog shows the order, and the account that pays it");
Check(check.details.at("reference") == "order-1" && check.details.at("amount_minor") == "1250" && check.details.at("account_iban") == aliceMain && check.details.at("counterparty") == shopIban, "and gives polkit rules the details");
Equal(bunq.Count("POST", payments), before + 1, "one payment");
Check(check.action == "net.catcrafts.Nostro1.Connectors" && Summary(bus) == std::format("have pay links start from {} (Main)", aliceMain), "choosing it is a change to the connections, and the dialog says what is chosen");
Check(check.details.at("account_iban") == aliceMain && check.details.at("environment") == "production", "with the details a rule can test");
Equal(alice.DefaultCheckoutAccount().value_or(Account{}).iban, aliceMain, "the account pay links start from");
const Checkout::Paid again = pay(order);
Check(again.paymentId == paid.paymentId && again.repeated, "the same order again answers with its payment");
Check(checks("order-1") == 1 && bunq.Count("POST", payments) == before + 1, "without asking, or paying, again");
const auto refused = [&pay](Checkout::Order changed, std::string_view part, std::string_view what) {
const Failure failure = FailureOf([&pay, &changed] { pay(changed); });
Check(failure.name == Checkout::errorInvalidArgument && failure.message.contains(part), std::format("{}: {}", what, failure.message));
};
Checkout::Order changed = order;
changed.amount = 1300;
refused(changed, "reference order-1 to NL91ABNA0417164300 is an order of another amount than €13.00", "a reference paid for another amount");
// Which amount it was paid for is not said: whoever knows an order's payee and reference could ask for it.
const Failure other = FailureOf([&pay, &changed] { pay(changed); });
Check(!other.message.contains("12.50") && !other.message.contains("1250"), std::format("and not for which amount: {}", other.message));
changed = order;
changed.payeeIban = "shop@example.com";
refused(changed, "checkout pays an IBAN, and 'shop@example.com' is none", "a payee that is no IBAN");
changed.payeeIban = "NL00BUNQ0000000000";
refused(changed, "is not a valid IBAN", "an IBAN with a typo");
changed = order;
changed.amount = 0;
refused(changed, "more than zero", "nothing to pay");
changed = order;
changed.currency = "USD";
refused(changed, "unsupported currency 'USD'", "a currency nostro does not pay in");
changed = order;
changed.reference = "";
refused(changed, "an order needs a reference", "an order without a reference");
// bunq refusing it before doing anything: the order was not paid, and is paid when asked again.
Checkout::Order refusedOrder = order;
refusedOrder.reference = "order-2";
bunq.Fail(Fault{.method = "POST", .path = "/user/", .status = 400, .body = R"({"Error":[{"error_description":"Not enough money."}]})"});
const Failure poor = FailureOf([&pay, &refusedOrder] { pay(refusedOrder); });
Check(poor.name == Checkout::errorBank && poor.message.contains("bunq: Not enough money. (400)"), std::format("bunq's refusal: {}", poor.message));
// The app is told what the bank said, and not which call it said it to: that names the user and the account.
const auto namesNoAccount = [](const Failure& failure) {
return !failure.message.contains("/user/") && !failure.message.contains("monetary-account") && !failure.message.contains(aliceMain);
};
Check(namesNoAccount(poor), std::format("without the user or the account at the bank: {}", poor.message));
Check(!pay(refusedOrder).repeated, "and the order paid when asked again");
// bunq's answer lost: the order may have been paid, and is not paid again.
Checkout::Order lostOrder = order;
lostOrder.reference = "order-3";
bunq.Fail(Fault{.method = "POST", .path = "/user/", .status = 500, .body = R"({"Error":[{"error_description":"Hiccup."}]})"});
const Failure hiccup = FailureOf([&pay, &lostOrder] { pay(lostOrder); });
Check(hiccup.name == Checkout::errorBank && hiccup.message.contains("may have been carried out") && namesNoAccount(hiccup), std::format("an answer that may hide a payment, also without the account: {}", hiccup.message));
const Failure lost = FailureOf([&pay, &lostOrder] { pay(lostOrder); });
Check(lost.name == Checkout::errorFailed && lost.message.contains("order order-3 to NL91ABNA0417164300 may have been paid already") && !lost.message.contains(aliceMain), std::format("such an order asked again, without the account: {}", lost.message));
Checkout::Order unconfirmed = order;
unconfirmed.reference = "order-4";
SetPolkit(bus, Fake::Polkit::Dismiss, Bus::actionCheckout);
Throws<Checkout::Cancelled>([&pay, &unconfirmed] { pay(unconfirmed); }, "you did not authenticate", "an order the user did not confirm");
// Asked again while the user is still at the prompt: the second call waits for the first, and gets its answer.
SetPolkit(bus, Fake::Polkit::Slow, Bus::actionCheckout);
Checkout::Paid first;
std::thread paying([&pay, &unconfirmed, &first] { first = pay(unconfirmed); });
std::this_thread::sleep_for(std::chrono::milliseconds(300));
changed = unconfirmed;
changed.amount = 99;
refused(changed, "is an order of another amount than €0.99", "another amount while the order is being paid");
const Checkout::Paid waited = pay(unconfirmed);
paying.join();
Check(first.paymentId != 0 && waited.paymentId == first.paymentId && !first.repeated && waited.repeated, "a retry while the first call is at the prompt gets the first call's payment");
Equal(checks("order-4"), std::ptrdiff_t{2}, "and the user is asked once for it, after the dismissed dialog");
SetPolkit(bus, Fake::Polkit::Silent, Bus::actionCheckout);
Checkout::Order unanswered = order;
unanswered.reference = "order-5";
Failure gaveUp;
std::thread asking([&pay, &unanswered, &gaveUp] { gaveUp = FailureOf([&pay, &unanswered] { pay(unanswered); }); });
std::this_thread::sleep_for(std::chrono::milliseconds(300));
const Failure alsoGaveUp = FailureOf([&pay, &unanswered] { pay(unanswered); });
asking.join();
Check(gaveUp.name == SD_BUS_ERROR_ACCESS_DENIED && alsoGaveUp.name == gaveUp.name && alsoGaveUp.message == gaveUp.message, "and the first call's refusal, when it is refused");
SetPolkit(bus, Fake::Polkit::Allow);
// An account chosen and since closed pays no checkout.
// An account chosen and since closed is chosen no more.
const std::uint64_t brief = bunq.AddAccount(bank.alice, briefIban, "Brief", 1000);
Equal(alice.SetDefaultCheckoutAccount(briefIban).iban, briefIban, "an account opened since");
bunq.ChangeAccount(brief, json{{"status", "CANCELLED"}});
alice.Accounts();
Check(!alice.DefaultCheckoutAccount().has_value(), "a closed account pays at checkout no more");
Checkout::Order orphan = order;
orphan.reference = "order-6";
Throws<Checkout::NoCheckoutAccount>([&pay, &orphan] { pay(orphan); }, "or it is gone", "nor does a checkout pay from it");
Check(!alice.DefaultCheckoutAccount().has_value(), "a closed account is the one pay links start from no more");
alice.SetDefaultCheckoutAccount(aliceMain);
}
@ -872,7 +683,7 @@ namespace {
Fake::Limit(limited, RLIMIT_NPROC, processes);
bus.Disconnect(name);
Equal(Fake::Wait(limited), 0, "it ends with the bus");
Check(bus.WaitForName(name, false) && bus.WaitForName(checkoutName, false), "and lets go of its names");
Check(bus.WaitForName(name, false), "and lets go of its name");
}
void Idle(Fake::Bus& bus, const fs::path& state) {
@ -922,7 +733,6 @@ int main(int argc, char* argv[]) {
bunq.AddAccount(bunq.AddPerson("Dave", "key-dave"), daveIban, "Dave's", 100);
NotRunning(bus);
CheckoutClient(bus);
const pid_t nostrod = Fake::StartNostrod({"--state", state.string(), "--idle", "60", "--prompt-timeout", "2"});
Check(bus.WaitForName(name), "nostrod owns its name");
Contract(bus);
@ -933,12 +743,12 @@ int main(int argc, char* argv[]) {
Lookups(bus, bunq, nostrod);
Concurrency(bus, bunq, bank);
Errors(bus, bunq, bank, state);
Checkouts(bus, bunq, bank);
CheckoutAccount(bus, bunq, bank);
Workers(bus, nostrod);
Notes(bus, bunq);
bus.Disconnect(name);
Equal(Fake::Wait(nostrod), 0, "nostrod ends when the bus goes, after its workers");
Check(bus.WaitForName(name, false) && bus.WaitForName(checkoutName, false), "and lets go of its names");
Check(bus.WaitForName(name, false), "and lets go of its name");
SpawnFailure(bus, state);
Idle(bus, state);