Skip to content

Commit

Permalink
Add waitForChange in latency bench
Browse files Browse the repository at this point in the history
In hope that this prevents the no_utxos_available we see after the
latency 2-fixture postTransaction step, a few txs into the 5 addr step.

The fixture wallets have a lot of funds. But if we are sending txs too
quickly, we might exhaust the availible utxo set.
  • Loading branch information
Anviking committed Jan 14, 2025
1 parent a5dc398 commit ce18f97
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/benchmarks/exe/latency-bench.hs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ import Cardano.Wallet.Unsafe
import Control.Applicative
( (<**>)
)
import Control.Concurrent
( threadDelay
)
import Control.Monad
( replicateM
, replicateM_
Expand Down Expand Up @@ -497,7 +500,13 @@ runScenario
-> BenchM ()
runScenario reporter scenario = lift . runResourceT $ do
let sceneOfClientMR :: String -> ClientM a -> BenchM ()
sceneOfClientMR = sceneOfClientM reporter
sceneOfClientMR = do sceneOfClientM reporter

-- | Decrease likelihood of failing with `no_utxos_available`
-- by calling this short delay after creating txs.
waitForChange :: BenchM ()
waitForChange = liftIO $ threadDelay 5_000_000

(wal1, wal2, walMA, maWalletToMigrate) <- scenario
let wal1Id = wal1 ^. #id
wal2Id = wal2 ^. #id
Expand All @@ -513,6 +522,7 @@ runScenario reporter scenario = lift . runResourceT $ do
txs <- request $ listAllTransactions wal1Id
sceneOfClientMR "getTransaction"
$ C.getTransaction wal1Id (ApiTxId $ txs !! 1 ^. #id) False
waitForChange

addrs <- request $ C.listAddresses wal2Id Nothing
let destination = addrs !! 1 ^. #id
Expand All @@ -530,6 +540,7 @@ runScenario reporter scenario = lift . runResourceT $ do
, timeToLive = Nothing
}
sceneOfClientMR "postTransactionFee" $ C.postTransactionFee wal1Id payload
waitForChange

let payloadTx =
PostTransactionOldData
Expand All @@ -540,6 +551,7 @@ runScenario reporter scenario = lift . runResourceT $ do
, timeToLive = Nothing
}
sceneOfClientMR "postTransaction" $ C.postTransaction wal1Id payloadTx
waitForChange

let payments =
replicate 5
Expand All @@ -558,6 +570,7 @@ runScenario reporter scenario = lift . runResourceT $ do
}
sceneOfClientMR "postTransactionTo5Addrs"
$ C.postTransaction wal1Id payloadTxTo5Addr
waitForChange

let
assetToSend = over _Unwrapped pick $ walMA ^. #assets . #total
Expand Down

0 comments on commit ce18f97

Please sign in to comment.