From cd6ec4fff4cc7a0f8d7be76c9d94dda444df5a0a Mon Sep 17 00:00:00 2001 From: Sasha Bogicevic Date: Wed, 13 Mar 2024 09:23:47 +0100 Subject: [PATCH] Rebase fixes --- hydra-node/src/Hydra/HeadLogic.hs | 6 ++-- .../test/Hydra/HeadLogicSnapshotSpec.hs | 6 ++-- hydra-node/test/Hydra/HeadLogicSpec.hs | 36 +++++++++---------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/hydra-node/src/Hydra/HeadLogic.hs b/hydra-node/src/Hydra/HeadLogic.hs index c59b94dbd88..92280d6f57a 100644 --- a/hydra-node/src/Hydra/HeadLogic.hs +++ b/hydra-node/src/Hydra/HeadLogic.hs @@ -897,12 +897,12 @@ update env ledger st ev = case (st, ev) of -- another party likely opened the head before us and it's okay to ignore. (Open{}, ChainInput PostTxError{postChainTx = CollectComTx{}}) -> noop - (Open OpenState{headId, coordinatedHeadState, currentSlot}, ClientEvent Decommit{decommitTx}) -> do + (Open OpenState{headId, coordinatedHeadState, currentSlot}, ClientInput Decommit{decommitTx}) -> do onOpenClientDecommit env headId ledger currentSlot coordinatedHeadState decommitTx - (Open openState, NetworkEvent ttl _ (ReqDec{transaction})) -> + (Open openState, NetworkInput ttl _ (ReqDec{transaction})) -> onOpenNetworkReqDec env ttl openState transaction ( Open OpenState{headId = ourHeadId} - , OnChainEvent Observation{observedTx = OnDecrementTx{headId}} + , ChainInput Observation{observedTx = OnDecrementTx{headId}} ) -- TODO: What happens if observed decrement tx get's rolled back? | ourHeadId == headId -> diff --git a/hydra-node/test/Hydra/HeadLogicSnapshotSpec.hs b/hydra-node/test/Hydra/HeadLogicSnapshotSpec.hs index 3158ae63248..3de946ea754 100644 --- a/hydra-node/test/Hydra/HeadLogicSnapshotSpec.hs +++ b/hydra-node/test/Hydra/HeadLogicSnapshotSpec.hs @@ -116,7 +116,7 @@ spec = do let bobEnv = envFor bobSk it "sends ReqSn when leader and there are seen transactions" $ do - headState <- runEvents bobEnv simpleLedger (inOpenState threeParties) $ do + headState <- runHeadLogic bobEnv simpleLedger (inOpenState threeParties) $ do step (NetworkInput defaultTTL alice $ ReqSn 1 [] Nothing) step (NetworkInput defaultTTL carol $ ReqTx $ aValidTx 1) step (ackFrom carolSk carol) @@ -127,7 +127,7 @@ spec = do `hasEffectSatisfying` sendReqSn it "does NOT send ReqSn when we are the leader but there are NO seen transactions" $ do - headState <- runEvents bobEnv simpleLedger (inOpenState threeParties) $ do + headState <- runHeadLogic bobEnv simpleLedger (inOpenState threeParties) $ do step (NetworkInput defaultTTL alice $ ReqSn 1 [] Nothing) step (ackFrom carolSk carol) step (ackFrom aliceSk alice) @@ -156,7 +156,7 @@ spec = do everybodyAcknowleged `hasNoEffectSatisfying` sendReqSn it "updates seenSnapshot state when sending ReqSn" $ do - headState <- runEvents bobEnv simpleLedger (inOpenState threeParties) $ do + headState <- runHeadLogic bobEnv simpleLedger (inOpenState threeParties) $ do step (NetworkInput defaultTTL alice $ ReqSn 1 [] Nothing) step (NetworkInput defaultTTL carol $ ReqTx $ aValidTx 1) step (ackFrom carolSk carol) diff --git a/hydra-node/test/Hydra/HeadLogicSpec.hs b/hydra-node/test/Hydra/HeadLogicSpec.hs index d0bfe532c65..1203c79a7a9 100644 --- a/hydra-node/test/Hydra/HeadLogicSpec.hs +++ b/hydra-node/test/Hydra/HeadLogicSpec.hs @@ -119,7 +119,7 @@ spec = let reqSn = NetworkInput defaultTTL alice $ ReqSn 1 [] Nothing snapshot1 = Snapshot testHeadId 1 mempty [] mempty ackFrom sk vk = NetworkInput defaultTTL vk $ AckSn (sign sk snapshot1) 1 - snapshotInProgress <- runEvents bobEnv ledger (inOpenState threeParties) $ do + snapshotInProgress <- runHeadLogic bobEnv ledger (inOpenState threeParties) $ do step reqSn step (ackFrom carolSk carol) step (ackFrom aliceSk alice) @@ -137,7 +137,7 @@ spec = it "observes DecommitRequested and ReqDec in an Open state" $ let decommitTx = SimpleTx 1 mempty (utxoRef 1) reqDec = ReqDec{transaction = decommitTx, decommitRequester = alice} - event = NetworkEvent defaultTTL alice reqDec + event = NetworkInput defaultTTL alice reqDec st = inOpenState threeParties outcome = update aliceEnv ledger st event in outcome @@ -150,7 +150,7 @@ spec = it "ignores ReqDec when not in Open state" $ monadicIO $ do let reqDec = ReqDec{transaction = SimpleTx 1 mempty (utxoRef 1), decommitRequester = alice} - let event = NetworkEvent defaultTTL alice reqDec + let event = NetworkInput defaultTTL alice reqDec st <- pickBlind $ oneof $ pure <$> [inInitialState threeParties, inIdleState, inClosedState threeParties] pure $ update aliceEnv ledger st event @@ -161,11 +161,11 @@ spec = decommitTx2 = SimpleTx 2 mempty (utxoRef 2) reqDec1 = ReqDec{transaction = decommitTx1, decommitRequester = alice} reqDec2 = ReqDec{transaction = decommitTx2, decommitRequester = bob} - reqDecEvent1 = NetworkEvent defaultTTL alice reqDec1 - reqDecEvent2 = NetworkEvent defaultTTL bob reqDec2 + reqDecEvent1 = NetworkInput defaultTTL alice reqDec1 + reqDecEvent2 = NetworkInput defaultTTL bob reqDec2 s0 = inOpenState threeParties - s1 <- runEvents aliceEnv ledger s0 $ do + s1 <- runHeadLogic aliceEnv ledger s0 $ do step reqDecEvent1 getState @@ -179,14 +179,14 @@ spec = it "updates decommitTx on valid ReqDec" $ do let decommitTx' = SimpleTx 1 mempty (utxoRef 1) let reqDec = ReqDec{transaction = decommitTx', decommitRequester = alice} - reqDecEvent = NetworkEvent defaultTTL alice reqDec + reqDecEvent = NetworkInput defaultTTL alice reqDec s0 = inOpenState threeParties s0 `shouldSatisfy` \case (Open OpenState{coordinatedHeadState = CoordinatedHeadState{decommitTx}}) -> decommitTx == Nothing _ -> False - s1 <- runEvents aliceEnv ledger s0 $ do + s1 <- runHeadLogic aliceEnv ledger s0 $ do step reqDecEvent getState @@ -195,7 +195,7 @@ spec = _ -> False -- running the 'ReqDec' again should not alter the recorded state - s2 <- runEvents aliceEnv ledger s1 $ do + s2 <- runHeadLogic aliceEnv ledger s1 $ do step reqDecEvent getState @@ -211,7 +211,7 @@ spec = (Open OpenState{coordinatedHeadState = CoordinatedHeadState{decommitTx}}) -> decommitTx == Nothing _ -> False - let reqDecEvent = NetworkEvent defaultTTL alice ReqDec{transaction = decommitTx', decommitRequester = alice} + let reqDecEvent = NetworkInput defaultTTL alice ReqDec{transaction = decommitTx', decommitRequester = alice} let reqSn = ReqSn{snapshotNumber = 1, transactionIds = [], decommitTx = Just decommitTx'} let s1 = update aliceEnv ledger s0 reqDecEvent @@ -337,7 +337,7 @@ spec = it "waits if we receive a snapshot with transaction not applicable on previous snapshot" $ do let reqTx42 = NetworkInput defaultTTL alice $ ReqTx (SimpleTx 42 mempty (utxoRef 1)) reqTx1 = NetworkInput defaultTTL alice $ ReqTx (SimpleTx 1 (utxoRef 1) (utxoRef 2)) - event = NetworkInput defaultTTL alice $ ReqSn 1 [1] Nothing + input = NetworkInput defaultTTL alice $ ReqSn 1 [1] Nothing s0 = inOpenState threeParties s2 <- runHeadLogic bobEnv ledger s0 $ do @@ -365,7 +365,7 @@ spec = -- snapshot collection. it "rejects if we receive a too far future snapshot" $ do - let event = NetworkInput defaultTTL bob $ ReqSn 2 [] Nothing + let input = NetworkInput defaultTTL bob $ ReqSn 2 [] Nothing st = inOpenState threeParties update bobEnv ledger st input `shouldBe` Error (RequireFailed $ ReqSnNumberInvalid 2 0) @@ -383,14 +383,14 @@ spec = it "acks signed snapshot from the constant leader" $ do let leader = alice snapshot = testSnapshot 1 mempty [] - event = NetworkInput defaultTTL leader $ ReqSn (number snapshot) [] Nothing + input = NetworkInput defaultTTL leader $ ReqSn (number snapshot) [] Nothing sig = sign bobSk snapshot st = inOpenState threeParties ack = AckSn sig (number snapshot) update bobEnv ledger st input `hasEffect` NetworkEffect ack it "does not ack snapshots from non-leaders" $ do - let event = NetworkInput defaultTTL notTheLeader $ ReqSn 1 [] Nothing + let input = NetworkInput defaultTTL notTheLeader $ ReqSn 1 [] Nothing notTheLeader = bob st = inOpenState threeParties update bobEnv ledger st input `shouldSatisfy` \case @@ -398,7 +398,7 @@ spec = _ -> False it "rejects too-old snapshots" $ do - let event = NetworkInput defaultTTL theLeader $ ReqSn 2 [] Nothing + let input = NetworkInput defaultTTL theLeader $ ReqSn 2 [] Nothing theLeader = alice snapshot = testSnapshot 2 mempty [] st = @@ -407,7 +407,7 @@ spec = update bobEnv ledger st input `shouldBe` Error (RequireFailed $ ReqSnNumberInvalid 2 0) it "rejects too-old snapshots when collecting signatures" $ do - let event = NetworkInput defaultTTL theLeader $ ReqSn 2 [] Nothing + let input = NetworkInput defaultTTL theLeader $ ReqSn 2 [] Nothing theLeader = alice snapshot = testSnapshot 2 mempty [] st = @@ -419,7 +419,7 @@ spec = update bobEnv ledger st input `shouldBe` Error (RequireFailed $ ReqSnNumberInvalid 2 3) it "rejects too-new snapshots from the leader" $ do - let event = NetworkInput defaultTTL theLeader $ ReqSn 3 [] Nothing + let input = NetworkInput defaultTTL theLeader $ ReqSn 3 [] Nothing theLeader = carol st = inOpenState threeParties update bobEnv ledger st input `shouldBe` Error (RequireFailed $ ReqSnNumberInvalid 3 0) @@ -600,7 +600,7 @@ spec = st <- run $ - runEvents bobEnv ledger st0 $ do + runHeadLogic bobEnv ledger st0 $ do step (NetworkInput defaultTTL alice $ ReqSn 1 [] Nothing) getState