{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}

module Test.Cardano.Ledger.Shelley.RulesTests (
  chainExamples,
  multisigExamples,
) where

import Cardano.Ledger.BaseTypes (Network (..))
import Cardano.Ledger.Coin (Coin (..))
import Cardano.Ledger.Core (hashScript)
import Cardano.Ledger.Credential (pattern ScriptHashObj)
import Cardano.Ledger.Keys (asWitness, hashKey)
import Cardano.Ledger.Shelley (ShelleyEra)
import Cardano.Ledger.Shelley.Rules (ShelleyUtxowPredFailure (..))
import Cardano.Ledger.Shelley.TxBody (RewardAccount (..), Withdrawals (..))
import Data.Either (isRight)
import qualified Data.Map.Strict as Map
import qualified Data.Set as Set
import Test.Cardano.Ledger.Core.KeyPair (vKey)
import Test.Cardano.Ledger.Shelley.Examples (testCHAINExample)
import qualified Test.Cardano.Ledger.Shelley.Examples.Cast as Cast
import Test.Cardano.Ledger.Shelley.Examples.EmptyBlock (exEmptyBlock)
import Test.Cardano.Ledger.Shelley.Examples.GenesisDelegation (genesisDelegExample)
import Test.Cardano.Ledger.Shelley.Examples.Mir (mirExample)
import Test.Cardano.Ledger.Shelley.Examples.MirTransfer (testMIRTransfer)
import Test.Cardano.Ledger.Shelley.Examples.NetworkID (testPoolNetworkId)
import Test.Cardano.Ledger.Shelley.Examples.PoolLifetime (poolLifetimeExample)
import Test.Cardano.Ledger.Shelley.Examples.PoolReReg (poolReRegExample)
import Test.Cardano.Ledger.Shelley.Examples.TwoPools (twoPoolsExample)
import Test.Cardano.Ledger.Shelley.Examples.Updates (updatesExample)
import Test.Cardano.Ledger.Shelley.MultiSigExamples (
  aliceAndBob,
  aliceAndBobOrCarl,
  aliceAndBobOrCarlAndDaria,
  aliceAndBobOrCarlOrDaria,
  aliceOnly,
  aliceOrBob,
  applyTxWithScript,
  bobOnly,
 )
import Test.Cardano.Ledger.Shelley.Serialisation.EraIndepGenerators ()
import Test.Cardano.Ledger.Shelley.Serialisation.Generators ()
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.HUnit (Assertion, assertBool, testCase, (@?=))

chainExamples :: TestTree
chainExamples :: TestTree
chainExamples =
  TestName -> [TestTree] -> TestTree
testGroup
    TestName
"CHAIN examples"
    [ TestName -> Assertion -> TestTree
testCase TestName
"empty block" (Assertion -> TestTree) -> Assertion -> TestTree
forall a b. (a -> b) -> a -> b
$ HasCallStack => CHAINExample ShelleyEra -> Assertion
CHAINExample ShelleyEra -> Assertion
testCHAINExample CHAINExample ShelleyEra
forall era.
(EraSegWits era, EraGov era, EraStake era, EraCertState era,
 ProtVerAtMost era 4, ProtVerAtMost era 6,
 Default (StashedAVVMAddresses era)) =>
CHAINExample era
exEmptyBlock
    , TestTree
poolLifetimeExample
    , TestTree
twoPoolsExample
    , TestTree
poolReRegExample
    , TestTree
updatesExample
    , TestTree
genesisDelegExample
    , TestTree
mirExample
    , TestTree
testMIRTransfer
    , TestTree
testPoolNetworkId
    ]

multisigExamples :: TestTree
multisigExamples :: TestTree
multisigExamples =
  TestName -> [TestTree] -> TestTree
testGroup
    TestName
"MultiSig Examples"
    [ TestName -> Assertion -> TestTree
testCase TestName
"Alice uses SingleSig script" Assertion
testAliceSignsAlone
    , TestName -> Assertion -> TestTree
testCase TestName
"FAIL: Alice doesn't sign in multi-sig" Assertion
testAliceDoesntSign
    , TestName -> Assertion -> TestTree
testCase TestName
"Everybody signs in multi-sig" Assertion
testEverybodySigns
    , TestName -> Assertion -> TestTree
testCase TestName
"Alice || Bob, Alice signs" Assertion
testAliceOrBob
    , TestName -> Assertion -> TestTree
testCase TestName
"Alice || Bob, Bob signs" Assertion
testAliceOrBob'
    , TestName -> Assertion -> TestTree
testCase TestName
"Alice && Bob, both sign" Assertion
testAliceAndBob
    , TestName -> Assertion -> TestTree
testCase TestName
"FAIL: Alice && Bob, Alice signs" Assertion
testAliceAndBob'
    , TestName -> Assertion -> TestTree
testCase TestName
"FAIL: Alice && Bob, Bob signs" Assertion
testAliceAndBob''
    , TestName -> Assertion -> TestTree
testCase TestName
"Alice && Bob || Carl, Alice && Bob sign" Assertion
testAliceAndBobOrCarl
    , TestName -> Assertion -> TestTree
testCase TestName
"Alice && Bob || Carl, Carl signs" Assertion
testAliceAndBobOrCarl'
    , TestName -> Assertion -> TestTree
testCase TestName
"Alice && Bob || Carl && Daria, Alice && Bob sign" Assertion
testAliceAndBobOrCarlAndDaria
    , TestName -> Assertion -> TestTree
testCase TestName
"Alice && Bob || Carl && Daria, Carl && Daria sign" Assertion
testAliceAndBobOrCarlAndDaria'
    , TestName -> Assertion -> TestTree
testCase TestName
"Alice && Bob || Carl || Daria, Alice && Bob sign" Assertion
testAliceAndBobOrCarlOrDaria
    , TestName -> Assertion -> TestTree
testCase TestName
"Alice && Bob || Carl || Daria, Carl signs" Assertion
testAliceAndBobOrCarlOrDaria'
    , TestName -> Assertion -> TestTree
testCase TestName
"Alice && Bob || Carl || Daria, Daria signs" Assertion
testAliceAndBobOrCarlOrDaria''
    , TestName -> Assertion -> TestTree
testCase TestName
"two scripts: Alice Or Bob / alice And Bob Or Carl" Assertion
testTwoScripts
    , TestName -> Assertion -> TestTree
testCase TestName
"FAIL: two scripts: Alice Or Bob / alice And Bob Or Carl" Assertion
testTwoScripts'
    , TestName -> Assertion -> TestTree
testCase TestName
"script and Key: Alice And Bob and alicePay" Assertion
testScriptAndSKey
    , TestName -> Assertion -> TestTree
testCase TestName
"FAIL: script and Key: Alice And Bob and alicePay" Assertion
testScriptAndSKey'
    , TestName -> Assertion -> TestTree
testCase TestName
"script and Key: Alice Or Bob and alicePay, only Alice" Assertion
testScriptAndSKey''
    , TestName -> Assertion -> TestTree
testCase
        TestName
"script and Key: Alice And Bob Or Carl and alicePay, Alice and Carl sign"
        Assertion
testScriptAndSKey'''
    , TestName -> Assertion -> TestTree
testCase TestName
"withdraw from script locked account, same script" Assertion
testRwdAliceSignsAlone
    , TestName -> Assertion -> TestTree
testCase TestName
"FAIL: withdraw from script locked account" Assertion
testRwdAliceSignsAlone'
    , TestName -> Assertion -> TestTree
testCase TestName
"withdraw from script locked account, different script" Assertion
testRwdAliceSignsAlone''
    , TestName -> Assertion -> TestTree
testCase
        TestName
"FAIL: withdraw from script locked account, signed, missing script"
        Assertion
testRwdAliceSignsAlone'''
    ]

testAliceSignsAlone :: Assertion
testAliceSignsAlone :: Assertion
testAliceSignsAlone =
  HasCallStack => TestName -> Bool -> Assertion
TestName -> Bool -> Assertion
assertBool TestName
s (Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> Bool
forall a b. Either a b -> Bool
isRight Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt')
  where
    utxoSt' :: Either
  (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
  (UTxOState ShelleyEra)
utxoSt' =
      [(MultiSig ShelleyEra, Coin)]
-> [MultiSig ShelleyEra]
-> Withdrawals
-> Coin
-> [KeyPair 'Witness]
-> Either
     (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
     (UTxOState ShelleyEra)
applyTxWithScript
        [(NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceOnly, Integer -> Coin
Coin Integer
11000)]
        [NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceOnly]
        (Map RewardAccount Coin -> Withdrawals
Withdrawals Map RewardAccount Coin
forall k a. Map k a
Map.empty)
        (Integer -> Coin
Coin Integer
0)
        [KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.alicePay]
    s :: TestName
s = TestName
"problem: " TestName -> TestName -> TestName
forall a. [a] -> [a] -> [a]
++ Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> TestName
forall a. Show a => a -> TestName
show Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt'

testAliceDoesntSign :: Assertion
testAliceDoesntSign :: Assertion
testAliceDoesntSign =
  Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt' Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> Either
     (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
     (UTxOState ShelleyEra)
-> Assertion
forall a. (Eq a, Show a, HasCallStack) => a -> a -> Assertion
@?= (NonEmpty (ShelleyUtxowPredFailure ShelleyEra)
-> Either
     (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
     (UTxOState ShelleyEra)
forall a b. a -> Either a b
Left (NonEmpty (ShelleyUtxowPredFailure ShelleyEra)
 -> Either
      (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
      (UTxOState ShelleyEra))
-> (Set ScriptHash
    -> NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
-> Set ScriptHash
-> Either
     (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
     (UTxOState ShelleyEra)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShelleyUtxowPredFailure ShelleyEra
-> NonEmpty (ShelleyUtxowPredFailure ShelleyEra)
forall a. a -> NonEmpty a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ShelleyUtxowPredFailure ShelleyEra
 -> NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
-> (Set ScriptHash -> ShelleyUtxowPredFailure ShelleyEra)
-> Set ScriptHash
-> NonEmpty (ShelleyUtxowPredFailure ShelleyEra)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Set ScriptHash -> ShelleyUtxowPredFailure ShelleyEra
forall era. Set ScriptHash -> ShelleyUtxowPredFailure era
ScriptWitnessNotValidatingUTXOW) Set ScriptHash
wits
  where
    utxoSt' :: Either
  (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
  (UTxOState ShelleyEra)
utxoSt' =
      [(MultiSig ShelleyEra, Coin)]
-> [MultiSig ShelleyEra]
-> Withdrawals
-> Coin
-> [KeyPair 'Witness]
-> Either
     (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
     (UTxOState ShelleyEra)
applyTxWithScript
        [(NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceOnly, Integer -> Coin
Coin Integer
11000)]
        [NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceOnly]
        (Map RewardAccount Coin -> Withdrawals
Withdrawals Map RewardAccount Coin
forall k a. Map k a
Map.empty)
        (Integer -> Coin
Coin Integer
0)
        [KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.bobPay, KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.carlPay, KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.dariaPay]
    wits :: Set ScriptHash
wits = ScriptHash -> Set ScriptHash
forall a. a -> Set a
Set.singleton (ScriptHash -> Set ScriptHash) -> ScriptHash -> Set ScriptHash
forall a b. (a -> b) -> a -> b
$ forall era. EraScript era => Script era -> ScriptHash
hashScript @ShelleyEra Script ShelleyEra
NativeScript ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceOnly

testEverybodySigns :: Assertion
testEverybodySigns :: Assertion
testEverybodySigns =
  HasCallStack => TestName -> Bool -> Assertion
TestName -> Bool -> Assertion
assertBool TestName
s (Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> Bool
forall a b. Either a b -> Bool
isRight Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt')
  where
    utxoSt' :: Either
  (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
  (UTxOState ShelleyEra)
utxoSt' =
      [(MultiSig ShelleyEra, Coin)]
-> [MultiSig ShelleyEra]
-> Withdrawals
-> Coin
-> [KeyPair 'Witness]
-> Either
     (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
     (UTxOState ShelleyEra)
applyTxWithScript
        [(NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceOnly, Integer -> Coin
Coin Integer
11000)]
        [NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceOnly]
        (Map RewardAccount Coin -> Withdrawals
Withdrawals Map RewardAccount Coin
forall k a. Map k a
Map.empty)
        (Integer -> Coin
Coin Integer
0)
        [ KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.alicePay
        , KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.bobPay
        , KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.carlPay
        , KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.dariaPay
        ]
    s :: TestName
s = TestName
"problem: " TestName -> TestName -> TestName
forall a. [a] -> [a] -> [a]
++ Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> TestName
forall a. Show a => a -> TestName
show Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt'

testAliceOrBob :: Assertion
testAliceOrBob :: Assertion
testAliceOrBob =
  HasCallStack => TestName -> Bool -> Assertion
TestName -> Bool -> Assertion
assertBool TestName
s (Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> Bool
forall a b. Either a b -> Bool
isRight Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt')
  where
    utxoSt' :: Either
  (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
  (UTxOState ShelleyEra)
utxoSt' =
      [(MultiSig ShelleyEra, Coin)]
-> [MultiSig ShelleyEra]
-> Withdrawals
-> Coin
-> [KeyPair 'Witness]
-> Either
     (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
     (UTxOState ShelleyEra)
applyTxWithScript
        [(NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceOrBob, Integer -> Coin
Coin Integer
11000)]
        [NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceOrBob]
        (Map RewardAccount Coin -> Withdrawals
Withdrawals Map RewardAccount Coin
forall k a. Map k a
Map.empty)
        (Integer -> Coin
Coin Integer
0)
        [KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.alicePay]
    s :: TestName
s = TestName
"problem: " TestName -> TestName -> TestName
forall a. [a] -> [a] -> [a]
++ Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> TestName
forall a. Show a => a -> TestName
show Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt'

testAliceOrBob' :: Assertion
testAliceOrBob' :: Assertion
testAliceOrBob' =
  HasCallStack => TestName -> Bool -> Assertion
TestName -> Bool -> Assertion
assertBool TestName
s (Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> Bool
forall a b. Either a b -> Bool
isRight Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt')
  where
    utxoSt' :: Either
  (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
  (UTxOState ShelleyEra)
utxoSt' =
      [(MultiSig ShelleyEra, Coin)]
-> [MultiSig ShelleyEra]
-> Withdrawals
-> Coin
-> [KeyPair 'Witness]
-> Either
     (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
     (UTxOState ShelleyEra)
applyTxWithScript
        [(NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceOrBob, Integer -> Coin
Coin Integer
11000)]
        [NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceOrBob]
        (Map RewardAccount Coin -> Withdrawals
Withdrawals Map RewardAccount Coin
forall k a. Map k a
Map.empty)
        (Integer -> Coin
Coin Integer
0)
        [KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.bobPay]
    s :: TestName
s = TestName
"problem: " TestName -> TestName -> TestName
forall a. [a] -> [a] -> [a]
++ Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> TestName
forall a. Show a => a -> TestName
show Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt'

testAliceAndBob :: Assertion
testAliceAndBob :: Assertion
testAliceAndBob =
  HasCallStack => TestName -> Bool -> Assertion
TestName -> Bool -> Assertion
assertBool TestName
s (Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> Bool
forall a b. Either a b -> Bool
isRight Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt')
  where
    utxoSt' :: Either
  (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
  (UTxOState ShelleyEra)
utxoSt' =
      [(MultiSig ShelleyEra, Coin)]
-> [MultiSig ShelleyEra]
-> Withdrawals
-> Coin
-> [KeyPair 'Witness]
-> Either
     (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
     (UTxOState ShelleyEra)
applyTxWithScript
        [(NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBob, Integer -> Coin
Coin Integer
11000)]
        [NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBob]
        (Map RewardAccount Coin -> Withdrawals
Withdrawals Map RewardAccount Coin
forall k a. Map k a
Map.empty)
        (Integer -> Coin
Coin Integer
0)
        [KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.alicePay, KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.bobPay]
    s :: TestName
s = TestName
"problem: " TestName -> TestName -> TestName
forall a. [a] -> [a] -> [a]
++ Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> TestName
forall a. Show a => a -> TestName
show Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt'

testAliceAndBob' :: Assertion
testAliceAndBob' :: Assertion
testAliceAndBob' =
  Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt' Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> Either
     (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
     (UTxOState ShelleyEra)
-> Assertion
forall a. (Eq a, Show a, HasCallStack) => a -> a -> Assertion
@?= (NonEmpty (ShelleyUtxowPredFailure ShelleyEra)
-> Either
     (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
     (UTxOState ShelleyEra)
forall a b. a -> Either a b
Left (NonEmpty (ShelleyUtxowPredFailure ShelleyEra)
 -> Either
      (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
      (UTxOState ShelleyEra))
-> (Set ScriptHash
    -> NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
-> Set ScriptHash
-> Either
     (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
     (UTxOState ShelleyEra)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShelleyUtxowPredFailure ShelleyEra
-> NonEmpty (ShelleyUtxowPredFailure ShelleyEra)
forall a. a -> NonEmpty a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ShelleyUtxowPredFailure ShelleyEra
 -> NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
-> (Set ScriptHash -> ShelleyUtxowPredFailure ShelleyEra)
-> Set ScriptHash
-> NonEmpty (ShelleyUtxowPredFailure ShelleyEra)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Set ScriptHash -> ShelleyUtxowPredFailure ShelleyEra
forall era. Set ScriptHash -> ShelleyUtxowPredFailure era
ScriptWitnessNotValidatingUTXOW) Set ScriptHash
wits
  where
    utxoSt' :: Either
  (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
  (UTxOState ShelleyEra)
utxoSt' =
      [(MultiSig ShelleyEra, Coin)]
-> [MultiSig ShelleyEra]
-> Withdrawals
-> Coin
-> [KeyPair 'Witness]
-> Either
     (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
     (UTxOState ShelleyEra)
applyTxWithScript
        [(NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBob, Integer -> Coin
Coin Integer
11000)]
        [NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBob]
        (Map RewardAccount Coin -> Withdrawals
Withdrawals Map RewardAccount Coin
forall k a. Map k a
Map.empty)
        (Integer -> Coin
Coin Integer
0)
        [KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.alicePay]
    wits :: Set ScriptHash
wits = ScriptHash -> Set ScriptHash
forall a. a -> Set a
Set.singleton (ScriptHash -> Set ScriptHash) -> ScriptHash -> Set ScriptHash
forall a b. (a -> b) -> a -> b
$ forall era. EraScript era => Script era -> ScriptHash
hashScript @ShelleyEra Script ShelleyEra
NativeScript ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBob

testAliceAndBob'' :: Assertion
testAliceAndBob'' :: Assertion
testAliceAndBob'' =
  Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt' Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> Either
     (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
     (UTxOState ShelleyEra)
-> Assertion
forall a. (Eq a, Show a, HasCallStack) => a -> a -> Assertion
@?= (NonEmpty (ShelleyUtxowPredFailure ShelleyEra)
-> Either
     (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
     (UTxOState ShelleyEra)
forall a b. a -> Either a b
Left (NonEmpty (ShelleyUtxowPredFailure ShelleyEra)
 -> Either
      (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
      (UTxOState ShelleyEra))
-> (Set ScriptHash
    -> NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
-> Set ScriptHash
-> Either
     (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
     (UTxOState ShelleyEra)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShelleyUtxowPredFailure ShelleyEra
-> NonEmpty (ShelleyUtxowPredFailure ShelleyEra)
forall a. a -> NonEmpty a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ShelleyUtxowPredFailure ShelleyEra
 -> NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
-> (Set ScriptHash -> ShelleyUtxowPredFailure ShelleyEra)
-> Set ScriptHash
-> NonEmpty (ShelleyUtxowPredFailure ShelleyEra)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Set ScriptHash -> ShelleyUtxowPredFailure ShelleyEra
forall era. Set ScriptHash -> ShelleyUtxowPredFailure era
ScriptWitnessNotValidatingUTXOW) Set ScriptHash
wits
  where
    utxoSt' :: Either
  (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
  (UTxOState ShelleyEra)
utxoSt' =
      [(MultiSig ShelleyEra, Coin)]
-> [MultiSig ShelleyEra]
-> Withdrawals
-> Coin
-> [KeyPair 'Witness]
-> Either
     (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
     (UTxOState ShelleyEra)
applyTxWithScript
        [(NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBob, Integer -> Coin
Coin Integer
11000)]
        [NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBob]
        (Map RewardAccount Coin -> Withdrawals
Withdrawals Map RewardAccount Coin
forall k a. Map k a
Map.empty)
        (Integer -> Coin
Coin Integer
0)
        [KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.bobPay]
    wits :: Set ScriptHash
wits = ScriptHash -> Set ScriptHash
forall a. a -> Set a
Set.singleton (ScriptHash -> Set ScriptHash) -> ScriptHash -> Set ScriptHash
forall a b. (a -> b) -> a -> b
$ forall era. EraScript era => Script era -> ScriptHash
hashScript @ShelleyEra Script ShelleyEra
NativeScript ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBob

testAliceAndBobOrCarl :: Assertion
testAliceAndBobOrCarl :: Assertion
testAliceAndBobOrCarl =
  HasCallStack => TestName -> Bool -> Assertion
TestName -> Bool -> Assertion
assertBool TestName
s (Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> Bool
forall a b. Either a b -> Bool
isRight Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt')
  where
    utxoSt' :: Either
  (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
  (UTxOState ShelleyEra)
utxoSt' =
      [(MultiSig ShelleyEra, Coin)]
-> [MultiSig ShelleyEra]
-> Withdrawals
-> Coin
-> [KeyPair 'Witness]
-> Either
     (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
     (UTxOState ShelleyEra)
applyTxWithScript
        [(NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBobOrCarl, Integer -> Coin
Coin Integer
11000)]
        [NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBobOrCarl]
        (Map RewardAccount Coin -> Withdrawals
Withdrawals Map RewardAccount Coin
forall k a. Map k a
Map.empty)
        (Integer -> Coin
Coin Integer
0)
        [KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.alicePay, KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.bobPay]
    s :: TestName
s = TestName
"problem: " TestName -> TestName -> TestName
forall a. [a] -> [a] -> [a]
++ Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> TestName
forall a. Show a => a -> TestName
show Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt'

testAliceAndBobOrCarl' :: Assertion
testAliceAndBobOrCarl' :: Assertion
testAliceAndBobOrCarl' =
  HasCallStack => TestName -> Bool -> Assertion
TestName -> Bool -> Assertion
assertBool TestName
s (Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> Bool
forall a b. Either a b -> Bool
isRight Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt')
  where
    utxoSt' :: Either
  (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
  (UTxOState ShelleyEra)
utxoSt' =
      [(MultiSig ShelleyEra, Coin)]
-> [MultiSig ShelleyEra]
-> Withdrawals
-> Coin
-> [KeyPair 'Witness]
-> Either
     (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
     (UTxOState ShelleyEra)
applyTxWithScript
        [(NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBobOrCarl, Integer -> Coin
Coin Integer
11000)]
        [NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBobOrCarl]
        (Map RewardAccount Coin -> Withdrawals
Withdrawals Map RewardAccount Coin
forall k a. Map k a
Map.empty)
        (Integer -> Coin
Coin Integer
0)
        [KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.carlPay]
    s :: TestName
s = TestName
"problem: " TestName -> TestName -> TestName
forall a. [a] -> [a] -> [a]
++ Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> TestName
forall a. Show a => a -> TestName
show Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt'

testAliceAndBobOrCarlAndDaria :: Assertion
testAliceAndBobOrCarlAndDaria :: Assertion
testAliceAndBobOrCarlAndDaria =
  HasCallStack => TestName -> Bool -> Assertion
TestName -> Bool -> Assertion
assertBool TestName
s (Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> Bool
forall a b. Either a b -> Bool
isRight Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt')
  where
    utxoSt' :: Either
  (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
  (UTxOState ShelleyEra)
utxoSt' =
      [(MultiSig ShelleyEra, Coin)]
-> [MultiSig ShelleyEra]
-> Withdrawals
-> Coin
-> [KeyPair 'Witness]
-> Either
     (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
     (UTxOState ShelleyEra)
applyTxWithScript
        [(NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBobOrCarlAndDaria, Integer -> Coin
Coin Integer
11000)]
        [NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBobOrCarlAndDaria]
        (Map RewardAccount Coin -> Withdrawals
Withdrawals Map RewardAccount Coin
forall k a. Map k a
Map.empty)
        (Integer -> Coin
Coin Integer
0)
        [KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.alicePay, KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.bobPay]
    s :: TestName
s = TestName
"problem: " TestName -> TestName -> TestName
forall a. [a] -> [a] -> [a]
++ Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> TestName
forall a. Show a => a -> TestName
show Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt'

testAliceAndBobOrCarlAndDaria' :: Assertion
testAliceAndBobOrCarlAndDaria' :: Assertion
testAliceAndBobOrCarlAndDaria' =
  HasCallStack => TestName -> Bool -> Assertion
TestName -> Bool -> Assertion
assertBool TestName
s (Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> Bool
forall a b. Either a b -> Bool
isRight Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt')
  where
    utxoSt' :: Either
  (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
  (UTxOState ShelleyEra)
utxoSt' =
      [(MultiSig ShelleyEra, Coin)]
-> [MultiSig ShelleyEra]
-> Withdrawals
-> Coin
-> [KeyPair 'Witness]
-> Either
     (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
     (UTxOState ShelleyEra)
applyTxWithScript
        [(NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBobOrCarlAndDaria, Integer -> Coin
Coin Integer
11000)]
        [NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBobOrCarlAndDaria]
        (Map RewardAccount Coin -> Withdrawals
Withdrawals Map RewardAccount Coin
forall k a. Map k a
Map.empty)
        (Integer -> Coin
Coin Integer
0)
        [KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.carlPay, KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.dariaPay]
    s :: TestName
s = TestName
"problem: " TestName -> TestName -> TestName
forall a. [a] -> [a] -> [a]
++ Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> TestName
forall a. Show a => a -> TestName
show Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt'

testAliceAndBobOrCarlOrDaria :: Assertion
testAliceAndBobOrCarlOrDaria :: Assertion
testAliceAndBobOrCarlOrDaria =
  HasCallStack => TestName -> Bool -> Assertion
TestName -> Bool -> Assertion
assertBool TestName
s (Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> Bool
forall a b. Either a b -> Bool
isRight Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt')
  where
    utxoSt' :: Either
  (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
  (UTxOState ShelleyEra)
utxoSt' =
      [(MultiSig ShelleyEra, Coin)]
-> [MultiSig ShelleyEra]
-> Withdrawals
-> Coin
-> [KeyPair 'Witness]
-> Either
     (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
     (UTxOState ShelleyEra)
applyTxWithScript
        [(NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBobOrCarlOrDaria, Integer -> Coin
Coin Integer
11000)]
        [NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBobOrCarlOrDaria]
        (Map RewardAccount Coin -> Withdrawals
Withdrawals Map RewardAccount Coin
forall k a. Map k a
Map.empty)
        (Integer -> Coin
Coin Integer
0)
        [KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.alicePay, KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.bobPay]
    s :: TestName
s = TestName
"problem: " TestName -> TestName -> TestName
forall a. [a] -> [a] -> [a]
++ Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> TestName
forall a. Show a => a -> TestName
show Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt'

testAliceAndBobOrCarlOrDaria' :: Assertion
testAliceAndBobOrCarlOrDaria' :: Assertion
testAliceAndBobOrCarlOrDaria' =
  HasCallStack => TestName -> Bool -> Assertion
TestName -> Bool -> Assertion
assertBool TestName
s (Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> Bool
forall a b. Either a b -> Bool
isRight Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt')
  where
    utxoSt' :: Either
  (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
  (UTxOState ShelleyEra)
utxoSt' =
      [(MultiSig ShelleyEra, Coin)]
-> [MultiSig ShelleyEra]
-> Withdrawals
-> Coin
-> [KeyPair 'Witness]
-> Either
     (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
     (UTxOState ShelleyEra)
applyTxWithScript
        [(NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBobOrCarlOrDaria, Integer -> Coin
Coin Integer
11000)]
        [NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBobOrCarlOrDaria]
        (Map RewardAccount Coin -> Withdrawals
Withdrawals Map RewardAccount Coin
forall k a. Map k a
Map.empty)
        (Integer -> Coin
Coin Integer
0)
        [KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.carlPay]
    s :: TestName
s = TestName
"problem: " TestName -> TestName -> TestName
forall a. [a] -> [a] -> [a]
++ Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> TestName
forall a. Show a => a -> TestName
show Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt'

testAliceAndBobOrCarlOrDaria'' :: Assertion
testAliceAndBobOrCarlOrDaria'' :: Assertion
testAliceAndBobOrCarlOrDaria'' =
  HasCallStack => TestName -> Bool -> Assertion
TestName -> Bool -> Assertion
assertBool TestName
s (Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> Bool
forall a b. Either a b -> Bool
isRight Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt')
  where
    utxoSt' :: Either
  (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
  (UTxOState ShelleyEra)
utxoSt' =
      [(MultiSig ShelleyEra, Coin)]
-> [MultiSig ShelleyEra]
-> Withdrawals
-> Coin
-> [KeyPair 'Witness]
-> Either
     (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
     (UTxOState ShelleyEra)
applyTxWithScript
        [(NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBobOrCarlOrDaria, Integer -> Coin
Coin Integer
11000)]
        [NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBobOrCarlOrDaria]
        (Map RewardAccount Coin -> Withdrawals
Withdrawals Map RewardAccount Coin
forall k a. Map k a
Map.empty)
        (Integer -> Coin
Coin Integer
0)
        [KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.dariaPay]
    s :: TestName
s = TestName
"problem: " TestName -> TestName -> TestName
forall a. [a] -> [a] -> [a]
++ Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> TestName
forall a. Show a => a -> TestName
show Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt'

-- multiple script-locked outputs

testTwoScripts :: Assertion
testTwoScripts :: Assertion
testTwoScripts =
  HasCallStack => TestName -> Bool -> Assertion
TestName -> Bool -> Assertion
assertBool TestName
s (Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> Bool
forall a b. Either a b -> Bool
isRight Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt')
  where
    utxoSt' :: Either
  (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
  (UTxOState ShelleyEra)
utxoSt' =
      [(MultiSig ShelleyEra, Coin)]
-> [MultiSig ShelleyEra]
-> Withdrawals
-> Coin
-> [KeyPair 'Witness]
-> Either
     (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
     (UTxOState ShelleyEra)
applyTxWithScript
        [ (NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceOrBob, Integer -> Coin
Coin Integer
10000)
        , (NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBobOrCarl, Integer -> Coin
Coin Integer
1000)
        ]
        [ NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceOrBob
        , NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBobOrCarl
        ]
        (Map RewardAccount Coin -> Withdrawals
Withdrawals Map RewardAccount Coin
forall k a. Map k a
Map.empty)
        (Integer -> Coin
Coin Integer
0)
        [KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.bobPay, KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.carlPay]
    s :: TestName
s = TestName
"problem: " TestName -> TestName -> TestName
forall a. [a] -> [a] -> [a]
++ Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> TestName
forall a. Show a => a -> TestName
show Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt'

testTwoScripts' :: Assertion
testTwoScripts' :: Assertion
testTwoScripts' =
  Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt' Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> Either
     (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
     (UTxOState ShelleyEra)
-> Assertion
forall a. (Eq a, Show a, HasCallStack) => a -> a -> Assertion
@?= (NonEmpty (ShelleyUtxowPredFailure ShelleyEra)
-> Either
     (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
     (UTxOState ShelleyEra)
forall a b. a -> Either a b
Left (NonEmpty (ShelleyUtxowPredFailure ShelleyEra)
 -> Either
      (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
      (UTxOState ShelleyEra))
-> (Set ScriptHash
    -> NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
-> Set ScriptHash
-> Either
     (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
     (UTxOState ShelleyEra)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShelleyUtxowPredFailure ShelleyEra
-> NonEmpty (ShelleyUtxowPredFailure ShelleyEra)
forall a. a -> NonEmpty a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ShelleyUtxowPredFailure ShelleyEra
 -> NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
-> (Set ScriptHash -> ShelleyUtxowPredFailure ShelleyEra)
-> Set ScriptHash
-> NonEmpty (ShelleyUtxowPredFailure ShelleyEra)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Set ScriptHash -> ShelleyUtxowPredFailure ShelleyEra
forall era. Set ScriptHash -> ShelleyUtxowPredFailure era
ScriptWitnessNotValidatingUTXOW) Set ScriptHash
wits
  where
    utxoSt' :: Either
  (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
  (UTxOState ShelleyEra)
utxoSt' =
      [(MultiSig ShelleyEra, Coin)]
-> [MultiSig ShelleyEra]
-> Withdrawals
-> Coin
-> [KeyPair 'Witness]
-> Either
     (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
     (UTxOState ShelleyEra)
applyTxWithScript
        [ (NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBob, Integer -> Coin
Coin Integer
10000)
        , (NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBobOrCarl, Integer -> Coin
Coin Integer
1000)
        ]
        [ NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBob
        , NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBobOrCarl
        ]
        (Map RewardAccount Coin -> Withdrawals
Withdrawals Map RewardAccount Coin
forall k a. Map k a
Map.empty)
        (Integer -> Coin
Coin Integer
0)
        [KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.bobPay, KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.carlPay]
    wits :: Set ScriptHash
wits = ScriptHash -> Set ScriptHash
forall a. a -> Set a
Set.singleton (ScriptHash -> Set ScriptHash) -> ScriptHash -> Set ScriptHash
forall a b. (a -> b) -> a -> b
$ forall era. EraScript era => Script era -> ScriptHash
hashScript @ShelleyEra Script ShelleyEra
NativeScript ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBob

-- script and skey locked

testScriptAndSKey :: Assertion
testScriptAndSKey :: Assertion
testScriptAndSKey =
  HasCallStack => TestName -> Bool -> Assertion
TestName -> Bool -> Assertion
assertBool TestName
s (Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> Bool
forall a b. Either a b -> Bool
isRight Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt')
  where
    utxoSt' :: Either
  (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
  (UTxOState ShelleyEra)
utxoSt' =
      [(MultiSig ShelleyEra, Coin)]
-> [MultiSig ShelleyEra]
-> Withdrawals
-> Coin
-> [KeyPair 'Witness]
-> Either
     (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
     (UTxOState ShelleyEra)
applyTxWithScript
        [(NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBob, Integer -> Coin
Coin Integer
10000)]
        [NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBob]
        (Map RewardAccount Coin -> Withdrawals
Withdrawals Map RewardAccount Coin
forall k a. Map k a
Map.empty)
        (Integer -> Coin
Coin Integer
1000)
        [KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.alicePay, KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.bobPay]
    s :: TestName
s = TestName
"problem: " TestName -> TestName -> TestName
forall a. [a] -> [a] -> [a]
++ Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> TestName
forall a. Show a => a -> TestName
show Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt'

testScriptAndSKey' :: Assertion
testScriptAndSKey' :: Assertion
testScriptAndSKey' =
  Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt' Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> Either
     (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
     (UTxOState ShelleyEra)
-> Assertion
forall a. (Eq a, Show a, HasCallStack) => a -> a -> Assertion
@?= (NonEmpty (ShelleyUtxowPredFailure ShelleyEra)
-> Either
     (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
     (UTxOState ShelleyEra)
forall a b. a -> Either a b
Left (NonEmpty (ShelleyUtxowPredFailure ShelleyEra)
 -> Either
      (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
      (UTxOState ShelleyEra))
-> (Set (KeyHash 'Witness)
    -> NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
-> Set (KeyHash 'Witness)
-> Either
     (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
     (UTxOState ShelleyEra)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShelleyUtxowPredFailure ShelleyEra
-> NonEmpty (ShelleyUtxowPredFailure ShelleyEra)
forall a. a -> NonEmpty a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ShelleyUtxowPredFailure ShelleyEra
 -> NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
-> (Set (KeyHash 'Witness) -> ShelleyUtxowPredFailure ShelleyEra)
-> Set (KeyHash 'Witness)
-> NonEmpty (ShelleyUtxowPredFailure ShelleyEra)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Set (KeyHash 'Witness) -> ShelleyUtxowPredFailure ShelleyEra
forall era. Set (KeyHash 'Witness) -> ShelleyUtxowPredFailure era
MissingVKeyWitnessesUTXOW) Set (KeyHash 'Witness)
wits
  where
    utxoSt' :: Either
  (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
  (UTxOState ShelleyEra)
utxoSt' =
      [(MultiSig ShelleyEra, Coin)]
-> [MultiSig ShelleyEra]
-> Withdrawals
-> Coin
-> [KeyPair 'Witness]
-> Either
     (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
     (UTxOState ShelleyEra)
applyTxWithScript
        [(NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceOrBob, Integer -> Coin
Coin Integer
10000)]
        [NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceOrBob]
        (Map RewardAccount Coin -> Withdrawals
Withdrawals Map RewardAccount Coin
forall k a. Map k a
Map.empty)
        (Integer -> Coin
Coin Integer
1000)
        [KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.bobPay]
    wits :: Set (KeyHash 'Witness)
wits = KeyHash 'Witness -> Set (KeyHash 'Witness)
forall a. a -> Set a
Set.singleton (KeyHash 'Witness -> Set (KeyHash 'Witness))
-> KeyHash 'Witness -> Set (KeyHash 'Witness)
forall a b. (a -> b) -> a -> b
$ KeyHash 'Payment -> KeyHash 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness (KeyHash 'Payment -> KeyHash 'Witness)
-> KeyHash 'Payment -> KeyHash 'Witness
forall a b. (a -> b) -> a -> b
$ VKey 'Payment -> KeyHash 'Payment
forall (kd :: KeyRole). VKey kd -> KeyHash kd
hashKey (VKey 'Payment -> KeyHash 'Payment)
-> VKey 'Payment -> KeyHash 'Payment
forall a b. (a -> b) -> a -> b
$ KeyPair 'Payment -> VKey 'Payment
forall (kd :: KeyRole). KeyPair kd -> VKey kd
vKey KeyPair 'Payment
Cast.alicePay

testScriptAndSKey'' :: Assertion
testScriptAndSKey'' :: Assertion
testScriptAndSKey'' =
  HasCallStack => TestName -> Bool -> Assertion
TestName -> Bool -> Assertion
assertBool TestName
s (Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> Bool
forall a b. Either a b -> Bool
isRight Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt')
  where
    utxoSt' :: Either
  (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
  (UTxOState ShelleyEra)
utxoSt' =
      [(MultiSig ShelleyEra, Coin)]
-> [MultiSig ShelleyEra]
-> Withdrawals
-> Coin
-> [KeyPair 'Witness]
-> Either
     (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
     (UTxOState ShelleyEra)
applyTxWithScript
        [(NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceOrBob, Integer -> Coin
Coin Integer
10000)]
        [NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceOrBob]
        (Map RewardAccount Coin -> Withdrawals
Withdrawals Map RewardAccount Coin
forall k a. Map k a
Map.empty)
        (Integer -> Coin
Coin Integer
1000)
        [KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.alicePay]
    s :: TestName
s = TestName
"problem: " TestName -> TestName -> TestName
forall a. [a] -> [a] -> [a]
++ Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> TestName
forall a. Show a => a -> TestName
show Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt'

testScriptAndSKey''' :: Assertion
testScriptAndSKey''' :: Assertion
testScriptAndSKey''' =
  HasCallStack => TestName -> Bool -> Assertion
TestName -> Bool -> Assertion
assertBool TestName
s (Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> Bool
forall a b. Either a b -> Bool
isRight Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt')
  where
    utxoSt' :: Either
  (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
  (UTxOState ShelleyEra)
utxoSt' =
      [(MultiSig ShelleyEra, Coin)]
-> [MultiSig ShelleyEra]
-> Withdrawals
-> Coin
-> [KeyPair 'Witness]
-> Either
     (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
     (UTxOState ShelleyEra)
applyTxWithScript
        [(NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBobOrCarl, Integer -> Coin
Coin Integer
10000)]
        [NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBobOrCarl]
        (Map RewardAccount Coin -> Withdrawals
Withdrawals Map RewardAccount Coin
forall k a. Map k a
Map.empty)
        (Integer -> Coin
Coin Integer
1000)
        [KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.alicePay, KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.carlPay]
    s :: TestName
s = TestName
"problem: " TestName -> TestName -> TestName
forall a. [a] -> [a] -> [a]
++ Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> TestName
forall a. Show a => a -> TestName
show Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt'

-- Withdrawals

testRwdAliceSignsAlone :: Assertion
testRwdAliceSignsAlone :: Assertion
testRwdAliceSignsAlone =
  HasCallStack => TestName -> Bool -> Assertion
TestName -> Bool -> Assertion
assertBool TestName
s (Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> Bool
forall a b. Either a b -> Bool
isRight Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt')
  where
    utxoSt' :: Either
  (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
  (UTxOState ShelleyEra)
utxoSt' =
      [(MultiSig ShelleyEra, Coin)]
-> [MultiSig ShelleyEra]
-> Withdrawals
-> Coin
-> [KeyPair 'Witness]
-> Either
     (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
     (UTxOState ShelleyEra)
applyTxWithScript
        [(NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceOnly, Integer -> Coin
Coin Integer
11000)]
        [NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceOnly]
        ( Map RewardAccount Coin -> Withdrawals
Withdrawals (Map RewardAccount Coin -> Withdrawals)
-> Map RewardAccount Coin -> Withdrawals
forall a b. (a -> b) -> a -> b
$
            RewardAccount -> Coin -> Map RewardAccount Coin
forall k a. k -> a -> Map k a
Map.singleton
              ( Network -> Credential 'Staking -> RewardAccount
RewardAccount
                  Network
Testnet
                  (ScriptHash -> Credential 'Staking
forall (kr :: KeyRole). ScriptHash -> Credential kr
ScriptHashObj (ScriptHash -> Credential 'Staking)
-> ScriptHash -> Credential 'Staking
forall a b. (a -> b) -> a -> b
$ forall era. EraScript era => Script era -> ScriptHash
hashScript @ShelleyEra Script ShelleyEra
NativeScript ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceOnly)
              )
              (Integer -> Coin
Coin Integer
1000)
        )
        (Integer -> Coin
Coin Integer
0)
        [KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.alicePay]
    s :: TestName
s = TestName
"problem: " TestName -> TestName -> TestName
forall a. [a] -> [a] -> [a]
++ Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> TestName
forall a. Show a => a -> TestName
show Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt'

testRwdAliceSignsAlone' :: Assertion
testRwdAliceSignsAlone' :: Assertion
testRwdAliceSignsAlone' =
  Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt' Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> Either
     (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
     (UTxOState ShelleyEra)
-> Assertion
forall a. (Eq a, Show a, HasCallStack) => a -> a -> Assertion
@?= (NonEmpty (ShelleyUtxowPredFailure ShelleyEra)
-> Either
     (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
     (UTxOState ShelleyEra)
forall a b. a -> Either a b
Left (NonEmpty (ShelleyUtxowPredFailure ShelleyEra)
 -> Either
      (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
      (UTxOState ShelleyEra))
-> (Set ScriptHash
    -> NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
-> Set ScriptHash
-> Either
     (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
     (UTxOState ShelleyEra)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShelleyUtxowPredFailure ShelleyEra
-> NonEmpty (ShelleyUtxowPredFailure ShelleyEra)
forall a. a -> NonEmpty a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ShelleyUtxowPredFailure ShelleyEra
 -> NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
-> (Set ScriptHash -> ShelleyUtxowPredFailure ShelleyEra)
-> Set ScriptHash
-> NonEmpty (ShelleyUtxowPredFailure ShelleyEra)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Set ScriptHash -> ShelleyUtxowPredFailure ShelleyEra
forall era. Set ScriptHash -> ShelleyUtxowPredFailure era
ScriptWitnessNotValidatingUTXOW) Set ScriptHash
wits
  where
    utxoSt' :: Either
  (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
  (UTxOState ShelleyEra)
utxoSt' =
      [(MultiSig ShelleyEra, Coin)]
-> [MultiSig ShelleyEra]
-> Withdrawals
-> Coin
-> [KeyPair 'Witness]
-> Either
     (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
     (UTxOState ShelleyEra)
applyTxWithScript
        [(NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceOnly, Integer -> Coin
Coin Integer
11000)]
        [NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceOnly, NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
bobOnly]
        ( Map RewardAccount Coin -> Withdrawals
Withdrawals (Map RewardAccount Coin -> Withdrawals)
-> Map RewardAccount Coin -> Withdrawals
forall a b. (a -> b) -> a -> b
$
            RewardAccount -> Coin -> Map RewardAccount Coin
forall k a. k -> a -> Map k a
Map.singleton
              ( Network -> Credential 'Staking -> RewardAccount
RewardAccount
                  Network
Testnet
                  ( ScriptHash -> Credential 'Staking
forall (kr :: KeyRole). ScriptHash -> Credential kr
ScriptHashObj (ScriptHash -> Credential 'Staking)
-> ScriptHash -> Credential 'Staking
forall a b. (a -> b) -> a -> b
$
                      forall era. EraScript era => Script era -> ScriptHash
hashScript @ShelleyEra Script ShelleyEra
NativeScript ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
bobOnly
                  )
              )
              (Integer -> Coin
Coin Integer
1000)
        )
        (Integer -> Coin
Coin Integer
0)
        [KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.alicePay]
    wits :: Set ScriptHash
wits = ScriptHash -> Set ScriptHash
forall a. a -> Set a
Set.singleton (ScriptHash -> Set ScriptHash) -> ScriptHash -> Set ScriptHash
forall a b. (a -> b) -> a -> b
$ forall era. EraScript era => Script era -> ScriptHash
hashScript @ShelleyEra Script ShelleyEra
NativeScript ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
bobOnly

testRwdAliceSignsAlone'' :: Assertion
testRwdAliceSignsAlone'' :: Assertion
testRwdAliceSignsAlone'' =
  HasCallStack => TestName -> Bool -> Assertion
TestName -> Bool -> Assertion
assertBool TestName
s (Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> Bool
forall a b. Either a b -> Bool
isRight Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt')
  where
    utxoSt' :: Either
  (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
  (UTxOState ShelleyEra)
utxoSt' =
      [(MultiSig ShelleyEra, Coin)]
-> [MultiSig ShelleyEra]
-> Withdrawals
-> Coin
-> [KeyPair 'Witness]
-> Either
     (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
     (UTxOState ShelleyEra)
applyTxWithScript
        [(NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceOnly, Integer -> Coin
Coin Integer
11000)]
        [NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceOnly, NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
bobOnly]
        ( Map RewardAccount Coin -> Withdrawals
Withdrawals (Map RewardAccount Coin -> Withdrawals)
-> Map RewardAccount Coin -> Withdrawals
forall a b. (a -> b) -> a -> b
$
            RewardAccount -> Coin -> Map RewardAccount Coin
forall k a. k -> a -> Map k a
Map.singleton
              ( Network -> Credential 'Staking -> RewardAccount
RewardAccount
                  Network
Testnet
                  ( ScriptHash -> Credential 'Staking
forall (kr :: KeyRole). ScriptHash -> Credential kr
ScriptHashObj (ScriptHash -> Credential 'Staking)
-> ScriptHash -> Credential 'Staking
forall a b. (a -> b) -> a -> b
$
                      forall era. EraScript era => Script era -> ScriptHash
hashScript @ShelleyEra Script ShelleyEra
NativeScript ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
bobOnly
                  )
              )
              (Integer -> Coin
Coin Integer
1000)
        )
        (Integer -> Coin
Coin Integer
0)
        [KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.alicePay, KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.bobPay]
    s :: TestName
s = TestName
"problem: " TestName -> TestName -> TestName
forall a. [a] -> [a] -> [a]
++ Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> TestName
forall a. Show a => a -> TestName
show Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt'

testRwdAliceSignsAlone''' :: Assertion
testRwdAliceSignsAlone''' :: Assertion
testRwdAliceSignsAlone''' =
  Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
utxoSt' Either
  (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
  (UTxOState ShelleyEra)
-> Either
     (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
     (UTxOState ShelleyEra)
-> Assertion
forall a. (Eq a, Show a, HasCallStack) => a -> a -> Assertion
@?= (NonEmpty (ShelleyUtxowPredFailure ShelleyEra)
-> Either
     (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
     (UTxOState ShelleyEra)
forall a b. a -> Either a b
Left (NonEmpty (ShelleyUtxowPredFailure ShelleyEra)
 -> Either
      (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
      (UTxOState ShelleyEra))
-> (Set ScriptHash
    -> NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
-> Set ScriptHash
-> Either
     (NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
     (UTxOState ShelleyEra)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShelleyUtxowPredFailure ShelleyEra
-> NonEmpty (ShelleyUtxowPredFailure ShelleyEra)
forall a. a -> NonEmpty a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ShelleyUtxowPredFailure ShelleyEra
 -> NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
-> (Set ScriptHash -> ShelleyUtxowPredFailure ShelleyEra)
-> Set ScriptHash
-> NonEmpty (ShelleyUtxowPredFailure ShelleyEra)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Set ScriptHash -> ShelleyUtxowPredFailure ShelleyEra
forall era. Set ScriptHash -> ShelleyUtxowPredFailure era
MissingScriptWitnessesUTXOW) Set ScriptHash
wits
  where
    utxoSt' :: Either
  (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
  (UTxOState ShelleyEra)
utxoSt' =
      [(MultiSig ShelleyEra, Coin)]
-> [MultiSig ShelleyEra]
-> Withdrawals
-> Coin
-> [KeyPair 'Witness]
-> Either
     (NonEmpty (PredicateFailure (ShelleyUTXOW ShelleyEra)))
     (UTxOState ShelleyEra)
applyTxWithScript
        [(NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceOnly, Integer -> Coin
Coin Integer
11000)]
        [NativeScript ShelleyEra
MultiSig ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceOnly]
        ( Map RewardAccount Coin -> Withdrawals
Withdrawals (Map RewardAccount Coin -> Withdrawals)
-> Map RewardAccount Coin -> Withdrawals
forall a b. (a -> b) -> a -> b
$
            RewardAccount -> Coin -> Map RewardAccount Coin
forall k a. k -> a -> Map k a
Map.singleton
              (Network -> Credential 'Staking -> RewardAccount
RewardAccount Network
Testnet (ScriptHash -> Credential 'Staking
forall (kr :: KeyRole). ScriptHash -> Credential kr
ScriptHashObj (ScriptHash -> Credential 'Staking)
-> ScriptHash -> Credential 'Staking
forall a b. (a -> b) -> a -> b
$ forall era. EraScript era => Script era -> ScriptHash
hashScript @ShelleyEra Script ShelleyEra
NativeScript ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
bobOnly))
              (Integer -> Coin
Coin Integer
1000)
        )
        (Integer -> Coin
Coin Integer
0)
        [KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.alicePay, KeyPair 'Payment -> KeyPair 'Witness
forall (a :: KeyRole -> *) (r :: KeyRole).
HasKeyRole a =>
a r -> a 'Witness
asWitness KeyPair 'Payment
Cast.bobPay]
    wits :: Set ScriptHash
wits = ScriptHash -> Set ScriptHash
forall a. a -> Set a
Set.singleton (ScriptHash -> Set ScriptHash) -> ScriptHash -> Set ScriptHash
forall a b. (a -> b) -> a -> b
$ forall era. EraScript era => Script era -> ScriptHash
hashScript @ShelleyEra Script ShelleyEra
NativeScript ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
bobOnly