From 28e865805bf47cbbe21b406c7add70090af84e27 Mon Sep 17 00:00:00 2001 From: shum Date: Thu, 22 Oct 2026 13:02:18 +0000 Subject: [PATCH] store: match insufficient funds in any case --- .../src/StoreService/Names/Sender.hs | 4 ++-- tests/Bots/StoreService/NamesSenderTests.hs | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/apps/simplex-store-service/src/StoreService/Names/Sender.hs b/apps/simplex-store-service/src/StoreService/Names/Sender.hs index fd6b2b62f0..da85f2ac4c 100644 --- a/apps/simplex-store-service/src/StoreService/Names/Sender.hs +++ b/apps/simplex-store-service/src/StoreService/Names/Sender.hs @@ -316,10 +316,10 @@ warnNonce Sender {snInFlight} nonce warning = do | ifLastWarning == Just warning -> pure False | otherwise -> True <$ writeTVar snInFlight (M.insert nonce tx {ifLastWarning = Just warning} inFlight) Nothing -> pure True - when changed $ (if underfundedMessage `T.isInfixOf` warning then logError else logWarn) message + when changed $ (if underfundedMessage `T.isInfixOf` T.toLower warning then logError else logWarn) message where message = "names sender: nonce " <> tshow nonce <> ": " <> warning --- | How geth, reth and erigon refuse a transaction whose key cannot pay gas × fee + value. +-- | How geth, reth and erigon refuse a transaction whose key cannot pay gas × fee + value, in lower case; anvil capitalizes it. underfundedMessage :: Text underfundedMessage = "insufficient funds" diff --git a/tests/Bots/StoreService/NamesSenderTests.hs b/tests/Bots/StoreService/NamesSenderTests.hs index f4f1f7634b..13cf34aad7 100644 --- a/tests/Bots/StoreService/NamesSenderTests.hs +++ b/tests/Bots/StoreService/NamesSenderTests.hs @@ -47,6 +47,7 @@ namesSenderTests = describe "StoreService names: sender" $ do it "hands a mined transaction whose receipt was pruned to its owner, signing nothing more" $ testPrunedReceipt g it "logs a round that fails on the store, and settles the transaction in the next round" $ testFailedRound g it "logs a send the node keeps refusing once per error, an underfunded key as an error" $ testRefusedSendLogged g + it "logs anvil's capitalized underfunded refusal as an error once" $ testCapitalizedUnderfundedLogged g it "refuses a transaction whose block needs more than the fee cap, saving nothing, and signs at most the cap" $ testFeeCapSubmit g it "clamps a replacement at the fee cap, and keeps rebroadcasting once a replacement would pass it" $ testFeeCapReplace g @@ -287,6 +288,22 @@ testRefusedSendLogged g = withSetup g $ \s@Setup {node} -> do linesWith "[" "names sender: rebroadcasting nonce 9" `shouldBe` 0 length <$> sentTransactions node `shouldReturn` 1 +testCapitalizedUnderfundedLogged :: TVar ChaChaDRG -> IO () +testCapitalizedUnderfundedLogged g = withSetup g $ \s@Setup {node} -> do + sender <- start s + -- a nonce no other spec reaches, as in testRefusedSendLogged + replicateM_ 13 $ useNextNonce node + logged <- capturingStderr $ do + setFault node "eth_sendRawTransaction" $ RpcError (-32003) "Insufficient funds for gas * price + value" Nothing + Right p <- submitTransaction sender (TxCommit r1) fakeController (commit 1) + ptNonce p `shouldBe` 13 + followTransactions sender + followTransactions sender + let linesWith :: T.Text -> T.Text -> Int + linesWith tag message = length $ filter (\l -> tag `T.isPrefixOf` l && message `T.isInfixOf` l) $ T.lines logged + linesWith "[ERROR" "names sender: nonce 13: not sent: ChainUnavailable \"eth_sendRawTransaction: error -32003: Insufficient funds" `shouldBe` 1 + linesWith "[" "names sender: nonce 13" `shouldBe` 1 + testFeeCapSubmit :: TVar ChaChaDRG -> IO () testFeeCapSubmit g = withSetup g $ \s@Setup {node, store} -> do sender <- start s