From ece10f1095ee81946a69d94c60aaad7edccce730 Mon Sep 17 00:00:00 2001 From: shum Date: Thu, 22 Oct 2026 15:26:56 +0000 Subject: [PATCH] store: log a refused order's cancelled invoice --- .../src/StoreService/Web/Names/Orders.hs | 2 +- tests/Bots/StoreService/NamesSpendTests.hs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/simplex-store-service/src/StoreService/Web/Names/Orders.hs b/apps/simplex-store-service/src/StoreService/Web/Names/Orders.hs index aa82cb3834..5f288b4032 100644 --- a/apps/simplex-store-service/src/StoreService/Web/Names/Orders.hs +++ b/apps/simplex-store-service/src/StoreService/Web/Names/Orders.hs @@ -147,7 +147,7 @@ createAtProvider env@OrdersEnv {oeStore, oeConfig, oeNow} cfg providers waiters `E.catch` strandedBy provider piProviderRef >>= \case Left refusal -> do - logWarn (what <> ": the order lost to another, so invoice " <> piProviderRef <> " is cancelled at the provider") + logWarn (what <> ": the order was refused, so invoice " <> piProviderRef <> " is cancelled at the provider") (\a -> a {aAfter = cancelAtProvider provider piProviderRef}) <$> refused what refusal Right closed -> do row_ <- getInvoice oeStore invId diff --git a/tests/Bots/StoreService/NamesSpendTests.hs b/tests/Bots/StoreService/NamesSpendTests.hs index 522939fb01..6ff3e0b45f 100644 --- a/tests/Bots/StoreService/NamesSpendTests.hs +++ b/tests/Bots/StoreService/NamesSpendTests.hs @@ -9,7 +9,7 @@ import Bots.StoreService.FakeEthNode import Bots.StoreService.NamesContractsTests (reservedNamesCall) import Bots.StoreService.NamesOrdersTests (Ctx (..), Order (..), advance, aliceOrder, commitmentOf, field, fieldsOf, invoiceRegistration, keyB, orderTime, placeOrder, post, refusedWith, registrationById, registrationOf, settleNow, withOrdersVia, yearsDuration) import Bots.StoreService.NamesStoreTests (at, order, ownerA, placePaid, reg, t0, write) -import Bots.StoreService.WebTests (StubCall (..), StubState (..), jsonObject, rcv, sampleProviderInvoice, statusOf, stubCalls, webGet, webRequestBody) +import Bots.StoreService.WebTests (StubCall (..), capturingStderr, StubState (..), jsonObject, rcv, sampleProviderInvoice, statusOf, stubCalls, webGet, webRequestBody) import Control.Concurrent.Async (Async, async, cancel, concurrently, wait) import Control.Concurrent.MVar (newEmptyMVar, putMVar, takeMVar) import Control.Concurrent.STM (atomically, check) @@ -521,7 +521,10 @@ testWriteRefusedAtBalance = withSpendHook $ \hook ctx@Ctx {cOpenStore} -> do src <- sourceOf ctx "src" 6000 other <- cOpenStore onCreate hook $ credit other "src" 500 - answer <- spend ctx src (difference 6000) + answered <- newIORef Nothing + logs <- capturingStderr $ spend ctx src (difference 6000) >>= writeIORef answered . Just + logs `shouldSatisfy` T.isInfixOf "the order was refused, so invoice pref-1 is cancelled at the provider" + Just answer <- readIORef answered current <- balanceOf ctx src (fmap blAmount current, blHold =<< current) `shouldBe` (Just 6500, Nothing) answer `shouldBe` balanceChanged current