Skip to content

Commit

Permalink
Fix flaky spec by seeding from faucet before the scenario starts
Browse files Browse the repository at this point in the history
We dont understnad the reason why, but the chain was getting in synch just too slow
making the commit to fail due to missing inputs
  • Loading branch information
ffakenz committed Sep 30, 2022
1 parent c053387 commit 1976e17
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions hydra-cluster/test/Test/DirectChainSpec.hs
Expand Up @@ -103,14 +103,16 @@ spec = around showLogsOnFailure $ do
withIOManager $ \iocp -> do
seedFromFaucet_ node aliceCardanoVk 100_000_000 Fuel (contramap FromFaucet tracer)
hydraScriptsTxId <- publishHydraScriptsAs node Faucet

let aliceCommitment = 66_000_000
aliceUTxO <- seedFromFaucet node aliceCardanoVk aliceCommitment Normal (contramap FromFaucet tracer)

withDirectChain (contramap (FromDirectChain "alice") tracer) defaultNetworkId iocp nodeSocket aliceKeys alice cardanoKeys Nothing hydraScriptsTxId (putMVar alicesCallback) $ \Chain{postTx} -> do
withDirectChain nullTracer defaultNetworkId iocp nodeSocket bobKeys bob cardanoKeys Nothing hydraScriptsTxId (putMVar bobsCallback) $ \_ -> do
postTx $ InitTx $ HeadParameters cperiod [alice, bob, carol]
alicesCallback `observesInTime` OnInitTx cperiod [alice, bob, carol]
bobsCallback `observesInTime` OnInitTx cperiod [alice, bob, carol]

let aliceCommitment = 66_000_000
aliceUTxO <- seedFromFaucet node aliceCardanoVk aliceCommitment Normal (contramap FromFaucet tracer)
postTx $ CommitTx alice aliceUTxO

alicesCallback `observesInTime` OnCommitTx alice aliceUTxO
Expand Down Expand Up @@ -157,6 +159,9 @@ spec = around showLogsOnFailure $ do
withIOManager $ \iocp -> do
seedFromFaucet_ node aliceCardanoVk 100_000_000 Fuel (contramap FromFaucet tracer)
hydraScriptsTxId <- publishHydraScriptsAs node Faucet

aliceUTxO <- seedFromFaucet node aliceCardanoVk 1_000_000 Normal (contramap FromFaucet tracer)

withDirectChain (contramap (FromDirectChain "alice") tracer) defaultNetworkId iocp nodeSocket aliceKeys alice cardanoKeys Nothing hydraScriptsTxId (putMVar alicesCallback) $ \Chain{postTx} -> do
postTx $ InitTx $ HeadParameters cperiod [alice]
alicesCallback `observesInTime` OnInitTx cperiod [alice]
Expand All @@ -172,7 +177,6 @@ spec = around showLogsOnFailure $ do
(CannotSpendInput{} :: PostTxError Tx) -> True
_ -> False

aliceUTxO <- seedFromFaucet node aliceCardanoVk 1_000_000 Normal (contramap FromFaucet tracer)
postTx $ CommitTx alice aliceUTxO
alicesCallback `observesInTime` OnCommitTx alice aliceUTxO

Expand Down Expand Up @@ -201,11 +205,13 @@ spec = around showLogsOnFailure $ do
withIOManager $ \iocp -> do
seedFromFaucet_ node aliceCardanoVk 100_000_000 Fuel (contramap FromFaucet tracer)
hydraScriptsTxId <- publishHydraScriptsAs node Faucet

someUTxO <- seedFromFaucet node aliceCardanoVk 1_000_000 Normal (contramap FromFaucet tracer)

withDirectChain (contramap (FromDirectChain "alice") tracer) defaultNetworkId iocp nodeSocket aliceKeys alice cardanoKeys Nothing hydraScriptsTxId (putMVar alicesCallback) $ \Chain{postTx} -> do
postTx $ InitTx $ HeadParameters cperiod [alice]
alicesCallback `observesInTime` OnInitTx cperiod [alice]

someUTxO <- seedFromFaucet node aliceCardanoVk 1_000_000 Normal (contramap FromFaucet tracer)
postTx $ CommitTx alice someUTxO
alicesCallback `observesInTime` OnCommitTx alice someUTxO

Expand Down

0 comments on commit 1976e17

Please sign in to comment.