diff --git a/lib/integration/framework/Test/Integration/Framework/Logging.hs b/lib/integration/framework/Test/Integration/Framework/Logging.hs index ce40031854f..02e167e1f1c 100644 --- a/lib/integration/framework/Test/Integration/Framework/Logging.hs +++ b/lib/integration/framework/Test/Integration/Framework/Logging.hs @@ -89,6 +89,7 @@ data TestsLog | MsgCluster ClusterLog | MsgPoolGarbageCollectionEvent PoolGarbageCollectionEvent | MsgServerError SomeException + | MsgRewardWalletDelegationFailed Text deriving (Show) instance ToText TestsLog where @@ -120,6 +121,11 @@ instance ToText TestsLog where | isAsyncException (SomeException e) -> "Server thread cancelled: " <> T.pack (show e) | otherwise -> T.pack (show e) + MsgRewardWalletDelegationFailed msg -> + T.unlines + [ "Reward wallet delegation failed." + , "Details: " <> toText msg + ] instance HasPrivacyAnnotation TestsLog instance HasSeverityAnnotation TestsLog where @@ -132,6 +138,7 @@ instance HasSeverityAnnotation TestsLog where MsgServerError e | isAsyncException e -> Notice | otherwise -> Warning + MsgRewardWalletDelegationFailed{} -> Error withTracers :: DirOf "cluster" diff --git a/lib/integration/framework/Test/Integration/Framework/Setup.hs b/lib/integration/framework/Test/Integration/Framework/Setup.hs index 2c1dfefc08a..f7ef5d89453 100644 --- a/lib/integration/framework/Test/Integration/Framework/Setup.hs +++ b/lib/integration/framework/Test/Integration/Framework/Setup.hs @@ -123,6 +123,9 @@ import Cardano.Wallet.TokenMetadata.MockServer ( queryServerStatic , withMetadataServer ) +import Control.Concurrent + ( threadDelay + ) import Control.Lens ( view ) @@ -530,18 +533,29 @@ withContext testingCtx@TestingCtx{..} action = do ctx (Link.listStakePools arbitraryStake) Empty - -- Having 'runResourceT' /inside/ the loop ensures the wallets are - -- deleted as quickly as possible, not to deplete file descriptors or - -- resources for unnecessary restoration. - forM_ mnemonics $ \mw -> runResourceT $ do - w <- walletFromMnemonic ctx mw - _ <- - joinStakePool - @('Testnet 0) -- protocol magic doesn't matter - ctx - (SpecificPool pool) - (w, fixturePassphrase) - pure () + + -- We only delete the wallets together at the end of the loop by + -- using this /outer/ 'runResourceT'. While this may be taxing on + -- resources, it enables tx submission to ensure all txs make it into + -- the chain. + runResourceT $ do + forM_ mnemonics $ \mw -> do + w <- walletFromMnemonic ctx mw + (httpStatus, res) <- + joinStakePool + @('Testnet 0) -- protocol magic doesn't matter + ctx + (SpecificPool pool) + (w, fixturePassphrase) + liftIO $ case res of + Left err -> traceWith tr + $ MsgRewardWalletDelegationFailed + $ T.pack $ show (httpStatus, err) + Right _ -> return () + + -- Extra time to ensure the final txs make it into the chain + let second = 1_000_000 + liftIO $ threadDelay $ 10 * second bracketTracer' :: Tracer IO TestsLog -> Text -> IO a -> IO a bracketTracer' tr name = bracketTracer $ contramap (MsgBracket name) tr diff --git a/lib/local-cluster/lib/Cardano/Wallet/Faucet.hs b/lib/local-cluster/lib/Cardano/Wallet/Faucet.hs index 4782b065aac..b00708a3c78 100644 --- a/lib/local-cluster/lib/Cardano/Wallet/Faucet.hs +++ b/lib/local-cluster/lib/Cardano/Wallet/Faucet.hs @@ -322,7 +322,7 @@ preregKeyWallet tag = do rewardWalletMnemonicRange :: MnemonicRange rewardWalletMnemonicRange = - MnemonicRange 0 30 + MnemonicRange 0 25 -- As few as possible; the cardano-wallet integration tests need to call -- postWallet for each one at the beginning of the tests.