Skip to content

Commit

Permalink
Revert "Merge pull request #493 from input-output-hk/abailly-iohk/fix…
Browse files Browse the repository at this point in the history
…-direct-chain-flakiness"

This reverts commit 97a5650, reversing
changes made to b0ebec9.
  • Loading branch information
ch1bo authored and v0d1ch committed Sep 28, 2022
1 parent cc2ec63 commit 1f53d06
Show file tree
Hide file tree
Showing 11 changed files with 21,356 additions and 29,611 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ changes.
#### Fixed

- Prevent transactions from being resubmitted for application over and over [#485](https://github.com/input-output-hk/hydra-poc/issues/485)
- Fix flakiness in tests involving the Cardano chain [#492](https://github.com/input-output-hk/hydra-poc/issues/492)

## [0.7.0] - 2022-08-23

Expand Down
4 changes: 0 additions & 4 deletions hydra-cardano-api/src/Cardano/Api/UTxO.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ newtype UTxO' out = UTxO
instance Traversable UTxO' where
traverse fn (UTxO m) = UTxO <$> traverse fn m

-- | Checks some `UTxO` is contained in some other `UTxO`.
contains :: Eq out => UTxO' out -> UTxO' out -> Bool
contains (UTxO m) (UTxO m') = m' `Map.isSubmapOf` m

-- | Create a 'UTxO' from a list of 'TxIn' and 'out' pairs.
fromPairs :: [(TxIn, out)] -> UTxO' out
fromPairs = UTxO . Map.fromList
Expand Down
24 changes: 3 additions & 21 deletions hydra-cluster/test/Test/DirectChainSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module Test.DirectChainSpec where
import Hydra.Prelude
import Test.Hydra.Prelude

import Cardano.Api.UTxO (contains)
import CardanoClient (
QueryPoint (QueryTip),
buildAddress,
Expand All @@ -21,7 +20,6 @@ import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as B8
import Hydra.Cardano.Api (
ChainPoint (..),
UTxO,
lovelaceToValue,
txOutValue,
unsafeDeserialiseFromRawBytesBase16,
Expand Down Expand Up @@ -104,15 +102,14 @@ spec = around showLogsOnFailure $ do
withIOManager $ \iocp -> do
seedFromFaucet_ node aliceCardanoVk 100_000_000 Fuel
hydraScriptsTxId <- publishHydraScriptsAs node Faucet
withDirectChain (contramap (FromDirectChain "alice") tracer) defaultNetworkId iocp nodeSocket aliceKeys alice cardanoKeys Nothing hydraScriptsTxId (putMVar alicesCallback) $ \Chain{postTx, getUTxO} -> do
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
waitUntilHasUTxO getUTxO aliceUTxO
postTx $ CommitTx alice aliceUTxO

alicesCallback `observesInTime` OnCommitTx alice aliceUTxO
Expand Down Expand Up @@ -159,7 +156,7 @@ spec = around showLogsOnFailure $ do
withIOManager $ \iocp -> do
seedFromFaucet_ node aliceCardanoVk 100_000_000 Fuel
hydraScriptsTxId <- publishHydraScriptsAs node Faucet
withDirectChain (contramap (FromDirectChain "alice") tracer) defaultNetworkId iocp nodeSocket aliceKeys alice cardanoKeys Nothing hydraScriptsTxId (putMVar alicesCallback) $ \Chain{postTx, getUTxO} -> do
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 @@ -175,7 +172,6 @@ spec = around showLogsOnFailure $ do
_ -> False

aliceUTxO <- seedFromFaucet node aliceCardanoVk 1_000_000 Normal
waitUntilHasUTxO getUTxO aliceUTxO
postTx $ CommitTx alice aliceUTxO
alicesCallback `observesInTime` OnCommitTx alice aliceUTxO

Expand Down Expand Up @@ -204,12 +200,11 @@ spec = around showLogsOnFailure $ do
withIOManager $ \iocp -> do
seedFromFaucet_ node aliceCardanoVk 100_000_000 Fuel
hydraScriptsTxId <- publishHydraScriptsAs node Faucet
withDirectChain (contramap (FromDirectChain "alice") tracer) defaultNetworkId iocp nodeSocket aliceKeys alice cardanoKeys Nothing hydraScriptsTxId (putMVar alicesCallback) $ \Chain{postTx, getUTxO} -> do
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
waitUntilHasUTxO getUTxO someUTxO
postTx $ CommitTx alice someUTxO
alicesCallback `observesInTime` OnCommitTx alice someUTxO

Expand Down Expand Up @@ -309,19 +304,6 @@ spec = around showLogsOnFailure $ do
(removeTrailingNewline (encodeUtf8 hydraScriptsTxIdStr))
failAfter 5 $ void $ queryScriptRegistry networkId nodeSocket hydraScriptsTxId

waitUntilHasUTxO :: IO UTxO -> UTxO -> IO ()
waitUntilHasUTxO getUTxO utxo = go 10
where
go :: Int -> IO ()
go 0 = do
knownUTxO <- getUTxO
failure $ "Timeout waiting for UTxO to appear in wallet.\n Expected " <> show utxo <> "\n Got " <> show knownUTxO
go n = do
knownUTxO <- getUTxO
unless (knownUTxO `contains` utxo) $ do
threadDelay 1
go (n - 1)

data TestClusterLog
= FromNode NodeLog
| FromDirectChain Text DirectChainLog
Expand Down
96 changes: 65 additions & 31 deletions hydra-node/golden/Event SimpleTx.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,91 @@
"samples": [
{
"chainEvent": {
"contents": "1864-04-28T23:16:21.931579670592Z",
"tag": "Tick"
"contents": {
"contestationPeriod": 2592000,
"parties": [],
"tag": "OnInitTx"
},
"tag": "Observation"
},
"tag": "OnChainEvent"
},
{
"clientInput": {
"tag": "Abort"
},
"tag": "ClientEvent"
},
{
"postChainTx": {
"tag": "CollectComTx",
"utxo": [
"confirmedSnapshot": {
"signatures": {
"multiSignature": [
"8bbd3a3952143162d6e0802ee851e4f7524c2e9218e354b6684397d8461be506ef99fab7ac19098bcbbd3417926418504d65dc276fca139b4e91e886eef9300e",
"414397fb545cf1a26ad70f98ba09c0c762a387b592b68e32685ac2a047d5ecc15ded6e6c56be83835c6afdb507e337aa5f02aae561ee1ec03114319c3f416f03",
"a8e63123ce9066a8e254b1414f1271c2fefcfbe14e697d29d9e99b42db79a758ae217362023e399d7a8763a4e2a5f9afac88f10452e5e52f52c758c1f47c7c00",
"1cb1fc09b7d3312f8cd0dc2b229b2edc865ba0332aa6258dddfe3c87ab523f708f3fb13bd62faf141c62e35d8ec890c10bb29ddac8d25666877e298e40524508",
"51c0c7670e124a74193eb386233631df49a480dfda4d4e1c89b89e7e619c9f96a3ffe910568cde02dd700ffb6e9f0ad2eefccf239deb972d0b23cea2f8a5fa08",
"b639fea4088d622cfb16fa307134ed99f5ed911268a5726e32f392555f6eecedf7be0d412bde3c1a45df1b87dee36ff9c2f16f4c7246eef625b05fd2add18c03"
]
},
"snapshot": {
"confirmedTransactions": [],
"snapshotNumber": 16,
"utxo": [
-30,
-25,
-19,
-12,
-1,
3,
16
]
},
"tag": "ConfirmedSnapshot"
},
"tag": "ContestTx"
},
"postTxError": {
"headUTxO": [
-30,
-29,
-27,
-22,
-24,
-18,
-13,
-8,
-3,
-1,
1,
6,
14,
16,
23
0,
2,
8,
24
],
"input": "nL\u000e𰅲aEX𪏨\u0016Z",
"tag": "CannotSpendInput",
"walletUTxO": [
-3,
-2,
5,
13,
23,
26
]
},
"postTxError": {
"tag": "NoPaymentInput"
},
"tag": "PostTxError"
},
{
"message": {
"peer": {
"hostname": "0.0.118.152",
"port": 22295
},
"tag": "Disconnected"
},
"tag": "NetworkEvent",
"ttl": 18
},
{
"clientInput": {
"tag": "Close"
"tag": "Fanout"
},
"tag": "ClientEvent"
},
{
"chainEvent": {
"contents": "1864-04-18T07:18:47.523454077472Z",
"tag": "Tick"
"clientInput": {
"tag": "Abort"
},
"tag": "OnChainEvent"
"tag": "ClientEvent"
}
],
"seed": -732045436
"seed": 589608564
}
Loading

0 comments on commit 1f53d06

Please sign in to comment.