{-# 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 qualified Test.Cardano.Ledger.Shelley.Examples.Cast as Cast
import Test.Cardano.Ledger.Shelley.Examples.Chain (testCHAINExample)
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 =
String -> [TestTree] -> TestTree
forall a. HasCallStack => String -> [SpecWith a] -> SpecWith a
testGroup
String
"CHAIN examples"
[ HasCallStack => String -> Expectation -> TestTree
String -> Expectation -> TestTree
testCase String
"empty block" (Expectation -> TestTree) -> Expectation -> TestTree
forall a b. (a -> b) -> a -> b
$ HasCallStack => CHAINExample ShelleyEra -> Expectation
CHAINExample ShelleyEra -> Expectation
testCHAINExample CHAINExample ShelleyEra
forall era.
(EraBlockBody era, EraGov era, EraStake era, EraCertState era,
AtMostEra "Mary" era, AtMostEra "Alonzo" era,
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 =
String -> [TestTree] -> TestTree
forall a. HasCallStack => String -> [SpecWith a] -> SpecWith a
testGroup
String
"MultiSig Examples"
[ HasCallStack => String -> Expectation -> TestTree
String -> Expectation -> TestTree
testCase String
"Alice uses SingleSig script" Expectation
testAliceSignsAlone
, HasCallStack => String -> Expectation -> TestTree
String -> Expectation -> TestTree
testCase String
"FAIL: Alice doesn't sign in multi-sig" Expectation
testAliceDoesntSign
, HasCallStack => String -> Expectation -> TestTree
String -> Expectation -> TestTree
testCase String
"Everybody signs in multi-sig" Expectation
testEverybodySigns
, HasCallStack => String -> Expectation -> TestTree
String -> Expectation -> TestTree
testCase String
"Alice || Bob, Alice signs" Expectation
testAliceOrBob
, HasCallStack => String -> Expectation -> TestTree
String -> Expectation -> TestTree
testCase String
"Alice || Bob, Bob signs" Expectation
testAliceOrBob'
, HasCallStack => String -> Expectation -> TestTree
String -> Expectation -> TestTree
testCase String
"Alice && Bob, both sign" Expectation
testAliceAndBob
, HasCallStack => String -> Expectation -> TestTree
String -> Expectation -> TestTree
testCase String
"FAIL: Alice && Bob, Alice signs" Expectation
testAliceAndBob'
, HasCallStack => String -> Expectation -> TestTree
String -> Expectation -> TestTree
testCase String
"FAIL: Alice && Bob, Bob signs" Expectation
testAliceAndBob''
, HasCallStack => String -> Expectation -> TestTree
String -> Expectation -> TestTree
testCase String
"Alice && Bob || Carl, Alice && Bob sign" Expectation
testAliceAndBobOrCarl
, HasCallStack => String -> Expectation -> TestTree
String -> Expectation -> TestTree
testCase String
"Alice && Bob || Carl, Carl signs" Expectation
testAliceAndBobOrCarl'
, HasCallStack => String -> Expectation -> TestTree
String -> Expectation -> TestTree
testCase String
"Alice && Bob || Carl && Daria, Alice && Bob sign" Expectation
testAliceAndBobOrCarlAndDaria
, HasCallStack => String -> Expectation -> TestTree
String -> Expectation -> TestTree
testCase String
"Alice && Bob || Carl && Daria, Carl && Daria sign" Expectation
testAliceAndBobOrCarlAndDaria'
, HasCallStack => String -> Expectation -> TestTree
String -> Expectation -> TestTree
testCase String
"Alice && Bob || Carl || Daria, Alice && Bob sign" Expectation
testAliceAndBobOrCarlOrDaria
, HasCallStack => String -> Expectation -> TestTree
String -> Expectation -> TestTree
testCase String
"Alice && Bob || Carl || Daria, Carl signs" Expectation
testAliceAndBobOrCarlOrDaria'
, HasCallStack => String -> Expectation -> TestTree
String -> Expectation -> TestTree
testCase String
"Alice && Bob || Carl || Daria, Daria signs" Expectation
testAliceAndBobOrCarlOrDaria''
, HasCallStack => String -> Expectation -> TestTree
String -> Expectation -> TestTree
testCase String
"two scripts: Alice Or Bob / alice And Bob Or Carl" Expectation
testTwoScripts
, HasCallStack => String -> Expectation -> TestTree
String -> Expectation -> TestTree
testCase String
"FAIL: two scripts: Alice Or Bob / alice And Bob Or Carl" Expectation
testTwoScripts'
, HasCallStack => String -> Expectation -> TestTree
String -> Expectation -> TestTree
testCase String
"script and Key: Alice And Bob and alicePay" Expectation
testScriptAndSKey
, HasCallStack => String -> Expectation -> TestTree
String -> Expectation -> TestTree
testCase String
"FAIL: script and Key: Alice And Bob and alicePay" Expectation
testScriptAndSKey'
, HasCallStack => String -> Expectation -> TestTree
String -> Expectation -> TestTree
testCase String
"script and Key: Alice Or Bob and alicePay, only Alice" Expectation
testScriptAndSKey''
, HasCallStack => String -> Expectation -> TestTree
String -> Expectation -> TestTree
testCase
String
"script and Key: Alice And Bob Or Carl and alicePay, Alice and Carl sign"
Expectation
testScriptAndSKey'''
, HasCallStack => String -> Expectation -> TestTree
String -> Expectation -> TestTree
testCase String
"withdraw from script locked account, same script" Expectation
testRwdAliceSignsAlone
, HasCallStack => String -> Expectation -> TestTree
String -> Expectation -> TestTree
testCase String
"FAIL: withdraw from script locked account" Expectation
testRwdAliceSignsAlone'
, HasCallStack => String -> Expectation -> TestTree
String -> Expectation -> TestTree
testCase String
"withdraw from script locked account, different script" Expectation
testRwdAliceSignsAlone''
, HasCallStack => String -> Expectation -> TestTree
String -> Expectation -> TestTree
testCase
String
"FAIL: withdraw from script locked account, signed, missing script"
Expectation
testRwdAliceSignsAlone'''
]
testAliceSignsAlone :: Assertion
testAliceSignsAlone :: Expectation
testAliceSignsAlone =
HasCallStack => String -> Bool -> Expectation
String -> Bool -> Expectation
assertBool String
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 :: String
s = String
"problem: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> String
forall a. Show a => a -> String
show Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
utxoSt'
testAliceDoesntSign :: Assertion
testAliceDoesntSign :: Expectation
testAliceDoesntSign =
Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
utxoSt' Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> Expectation
forall a. (HasCallStack, Show a, Eq a) => a -> a -> Expectation
@?= (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 NativeScript ShelleyEra
Script ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceOnly
testEverybodySigns :: Assertion
testEverybodySigns :: Expectation
testEverybodySigns =
HasCallStack => String -> Bool -> Expectation
String -> Bool -> Expectation
assertBool String
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 :: String
s = String
"problem: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> String
forall a. Show a => a -> String
show Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
utxoSt'
testAliceOrBob :: Assertion
testAliceOrBob :: Expectation
testAliceOrBob =
HasCallStack => String -> Bool -> Expectation
String -> Bool -> Expectation
assertBool String
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 :: String
s = String
"problem: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> String
forall a. Show a => a -> String
show Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
utxoSt'
testAliceOrBob' :: Assertion
testAliceOrBob' :: Expectation
testAliceOrBob' =
HasCallStack => String -> Bool -> Expectation
String -> Bool -> Expectation
assertBool String
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 :: String
s = String
"problem: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> String
forall a. Show a => a -> String
show Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
utxoSt'
testAliceAndBob :: Assertion
testAliceAndBob :: Expectation
testAliceAndBob =
HasCallStack => String -> Bool -> Expectation
String -> Bool -> Expectation
assertBool String
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 :: String
s = String
"problem: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> String
forall a. Show a => a -> String
show Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
utxoSt'
testAliceAndBob' :: Assertion
testAliceAndBob' :: Expectation
testAliceAndBob' =
Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
utxoSt' Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> Expectation
forall a. (HasCallStack, Show a, Eq a) => a -> a -> Expectation
@?= (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 NativeScript ShelleyEra
Script ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBob
testAliceAndBob'' :: Assertion
testAliceAndBob'' :: Expectation
testAliceAndBob'' =
Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
utxoSt' Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> Expectation
forall a. (HasCallStack, Show a, Eq a) => a -> a -> Expectation
@?= (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 NativeScript ShelleyEra
Script ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBob
testAliceAndBobOrCarl :: Assertion
testAliceAndBobOrCarl :: Expectation
testAliceAndBobOrCarl =
HasCallStack => String -> Bool -> Expectation
String -> Bool -> Expectation
assertBool String
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 :: String
s = String
"problem: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> String
forall a. Show a => a -> String
show Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
utxoSt'
testAliceAndBobOrCarl' :: Assertion
testAliceAndBobOrCarl' :: Expectation
testAliceAndBobOrCarl' =
HasCallStack => String -> Bool -> Expectation
String -> Bool -> Expectation
assertBool String
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 :: String
s = String
"problem: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> String
forall a. Show a => a -> String
show Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
utxoSt'
testAliceAndBobOrCarlAndDaria :: Assertion
testAliceAndBobOrCarlAndDaria :: Expectation
testAliceAndBobOrCarlAndDaria =
HasCallStack => String -> Bool -> Expectation
String -> Bool -> Expectation
assertBool String
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 :: String
s = String
"problem: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> String
forall a. Show a => a -> String
show Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
utxoSt'
testAliceAndBobOrCarlAndDaria' :: Assertion
testAliceAndBobOrCarlAndDaria' :: Expectation
testAliceAndBobOrCarlAndDaria' =
HasCallStack => String -> Bool -> Expectation
String -> Bool -> Expectation
assertBool String
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 :: String
s = String
"problem: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> String
forall a. Show a => a -> String
show Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
utxoSt'
testAliceAndBobOrCarlOrDaria :: Assertion
testAliceAndBobOrCarlOrDaria :: Expectation
testAliceAndBobOrCarlOrDaria =
HasCallStack => String -> Bool -> Expectation
String -> Bool -> Expectation
assertBool String
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 :: String
s = String
"problem: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> String
forall a. Show a => a -> String
show Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
utxoSt'
testAliceAndBobOrCarlOrDaria' :: Assertion
testAliceAndBobOrCarlOrDaria' :: Expectation
testAliceAndBobOrCarlOrDaria' =
HasCallStack => String -> Bool -> Expectation
String -> Bool -> Expectation
assertBool String
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 :: String
s = String
"problem: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> String
forall a. Show a => a -> String
show Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
utxoSt'
testAliceAndBobOrCarlOrDaria'' :: Assertion
testAliceAndBobOrCarlOrDaria'' :: Expectation
testAliceAndBobOrCarlOrDaria'' =
HasCallStack => String -> Bool -> Expectation
String -> Bool -> Expectation
assertBool String
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 :: String
s = String
"problem: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> String
forall a. Show a => a -> String
show Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
utxoSt'
testTwoScripts :: Assertion
testTwoScripts :: Expectation
testTwoScripts =
HasCallStack => String -> Bool -> Expectation
String -> Bool -> Expectation
assertBool String
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 :: String
s = String
"problem: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> String
forall a. Show a => a -> String
show Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
utxoSt'
testTwoScripts' :: Assertion
testTwoScripts' :: Expectation
testTwoScripts' =
Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
utxoSt' Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> Expectation
forall a. (HasCallStack, Show a, Eq a) => a -> a -> Expectation
@?= (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 NativeScript ShelleyEra
Script ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
aliceAndBob
testScriptAndSKey :: Assertion
testScriptAndSKey :: Expectation
testScriptAndSKey =
HasCallStack => String -> Bool -> Expectation
String -> Bool -> Expectation
assertBool String
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 :: String
s = String
"problem: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> String
forall a. Show a => a -> String
show Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
utxoSt'
testScriptAndSKey' :: Assertion
testScriptAndSKey' :: Expectation
testScriptAndSKey' =
Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
utxoSt' Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> Expectation
forall a. (HasCallStack, Show a, Eq a) => a -> a -> Expectation
@?= (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'' :: Expectation
testScriptAndSKey'' =
HasCallStack => String -> Bool -> Expectation
String -> Bool -> Expectation
assertBool String
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 :: String
s = String
"problem: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> String
forall a. Show a => a -> String
show Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
utxoSt'
testScriptAndSKey''' :: Assertion
testScriptAndSKey''' :: Expectation
testScriptAndSKey''' =
HasCallStack => String -> Bool -> Expectation
String -> Bool -> Expectation
assertBool String
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 :: String
s = String
"problem: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> String
forall a. Show a => a -> String
show Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
utxoSt'
testRwdAliceSignsAlone :: Assertion
testRwdAliceSignsAlone :: Expectation
testRwdAliceSignsAlone =
HasCallStack => String -> Bool -> Expectation
String -> Bool -> Expectation
assertBool String
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 NativeScript ShelleyEra
Script 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 :: String
s = String
"problem: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> String
forall a. Show a => a -> String
show Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
utxoSt'
testRwdAliceSignsAlone' :: Assertion
testRwdAliceSignsAlone' :: Expectation
testRwdAliceSignsAlone' =
Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
utxoSt' Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> Expectation
forall a. (HasCallStack, Show a, Eq a) => a -> a -> Expectation
@?= (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 NativeScript ShelleyEra
Script 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 NativeScript ShelleyEra
Script ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
bobOnly
testRwdAliceSignsAlone'' :: Assertion
testRwdAliceSignsAlone'' :: Expectation
testRwdAliceSignsAlone'' =
HasCallStack => String -> Bool -> Expectation
String -> Bool -> Expectation
assertBool String
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 NativeScript ShelleyEra
Script 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 :: String
s = String
"problem: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> String
forall a. Show a => a -> String
show Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
utxoSt'
testRwdAliceSignsAlone''' :: Assertion
testRwdAliceSignsAlone''' :: Expectation
testRwdAliceSignsAlone''' =
Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
utxoSt' Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> Either
(NonEmpty (ShelleyUtxowPredFailure ShelleyEra))
(UTxOState ShelleyEra)
-> Expectation
forall a. (HasCallStack, Show a, Eq a) => a -> a -> Expectation
@?= (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 NativeScript ShelleyEra
Script 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 NativeScript ShelleyEra
Script ShelleyEra
forall era. ShelleyEraScript era => NativeScript era
bobOnly