mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-11-04 12:57:45 +00:00
store: match insufficient funds in any case
This commit is contained in:
1 parent
64fb8d008a
commit
28e865805b
2 files changed
+19
-2
No files matched your search
@@ -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"
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user