/
Examples.hs
164 lines (155 loc) · 5.88 KB
/
Examples.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE TypeApplications #-}
-- | Examples of the application of the update rules.
module Ledger.Update.Examples where
import GHC.Exts (fromList)
import Data.Functor.Identity (runIdentity)
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.HUnit (testCase)
import Ledger.Core (BlockCount (BlockCount), Owner (Owner), Slot (Slot),
SlotCount (SlotCount), VKey (VKey), VKeyGenesis (VKeyGenesis), unBlockCount,
unOwner, unSlot, unSlotCount, unVKeyGenesis)
import Ledger.Update (ApName (ApName), ApVer (ApVer), FactorA (..), FactorB (..),
Metadata (Metadata), PParams (PParams), ProtVer (ProtVer), UPIEND,
UpId (UpId), _bkSgnCntT, _bkSlotsPerEpoch, _factorA, _factorB, _maxBkSz,
_maxHdrSz, _maxPropSz, _maxTxSz, _pvAlt, _pvMaj, _pvMin, _scriptVersion,
_upAdptThd, _upTtl)
import Control.State.Transition.Trace (checkTrace, (.-), (.->))
upiendExamples :: [TestTree]
upiendExamples =
[ testGroup "UPIEND"
[ testCase "Example 0" $
let
oldPParams =
PParams
{ _maxBkSz = 10000
, _maxHdrSz = 1000
, _maxTxSz = 500
, _maxPropSz = 10
, _bkSgnCntT = 0.7857142857142857
, _bkSlotsPerEpoch = SlotCount { unSlotCount = 10 }
, _upTtl = SlotCount { unSlotCount = 10 }
, _scriptVersion = 0
, _upAdptThd = 0.6
, _factorA = FactorA 1
, _factorB = FactorB 2
}
newPParams =
PParams
{ _maxBkSz = 9900
, _maxHdrSz = 1000
, _maxTxSz = 489
, _maxPropSz = 10
, _bkSgnCntT = 0.7857142857142857
, _bkSlotsPerEpoch = SlotCount { unSlotCount = 10 }
, _upTtl = SlotCount { unSlotCount = 2 }
, _scriptVersion = 0
, _upAdptThd = 0.0
, _factorA = FactorA 0
, _factorB = FactorB 0
}
in
checkTrace @UPIEND
runIdentity
( Slot { unSlot = 15 }
, [ ( VKeyGenesis { unVKeyGenesis = VKey Owner { unOwner = 0 } }
, VKey Owner { unOwner = 0 }
)
, ( VKeyGenesis { unVKeyGenesis = VKey Owner { unOwner = 1 } }
, VKey Owner { unOwner = 1 }
)
, ( VKeyGenesis { unVKeyGenesis = VKey Owner { unOwner = 2 } }
, VKey Owner { unOwner = 2 }
)
, ( VKeyGenesis { unVKeyGenesis = VKey Owner { unOwner = 3 } }
, VKey Owner { unOwner = 3 }
)
, ( VKeyGenesis { unVKeyGenesis = VKey Owner { unOwner = 4 } }
, VKey Owner { unOwner = 4 }
)
]
, BlockCount { unBlockCount = 2 }
, 5
) $
pure
( ( ProtVer { _pvMaj = 0 , _pvMin = 0 , _pvAlt = 0 }
, oldPParams
)
, []
, fromList []
, fromList
[ ( UpId 1
, ( ProtVer { _pvMaj = 1 , _pvMin = 0 , _pvAlt = 0 }
, newPParams
)
)
]
, fromList [ ( UpId 1 , ( ApName "" , ApVer 0 , Metadata ) ) ]
, fromList [ ( UpId 1 , Slot { unSlot = 5 } ) ]
, fromList
[ ( UpId 1
, VKeyGenesis { unVKeyGenesis = VKey Owner { unOwner = 1 } }
)
, ( UpId 1
, VKeyGenesis { unVKeyGenesis = VKey Owner { unOwner = 2 } }
)
, ( UpId 1
, VKeyGenesis { unVKeyGenesis = VKey Owner { unOwner = 3 } }
)
]
, fromList
[ ( ProtVer { _pvMaj = 1 , _pvMin = 0 , _pvAlt = 0 }
, VKeyGenesis { unVKeyGenesis = VKey Owner { unOwner = 1 } }
)
, ( ProtVer { _pvMaj = 1 , _pvMin = 0 , _pvAlt = 0 }
, VKeyGenesis { unVKeyGenesis = VKey Owner { unOwner = 3 } }
)
]
, fromList [ ( UpId 1 , Slot { unSlot = 2 } ) ]
)
.- (ProtVer { _pvMaj = 1 , _pvMin = 0 , _pvAlt = 0 }, VKey Owner { unOwner = 0 }) .->
( ( ProtVer { _pvMaj = 0 , _pvMin = 0 , _pvAlt = 0 }
, oldPParams
)
, [ ( Slot {unSlot = 15}
, ( ProtVer {_pvMaj = 1, _pvMin = 0, _pvAlt = 0}
, newPParams
)
)
]
, fromList []
, fromList
[ ( UpId 1
, ( ProtVer { _pvMaj = 1 , _pvMin = 0 , _pvAlt = 0 }
, newPParams
)
)
]
, fromList [ ( UpId 1 , ( ApName "" , ApVer 0 , Metadata ) ) ]
, fromList [ ( UpId 1 , Slot { unSlot = 5 } ) ]
, fromList
[ ( UpId 1
, VKeyGenesis { unVKeyGenesis = VKey Owner { unOwner = 1 } }
)
, ( UpId 1
, VKeyGenesis { unVKeyGenesis = VKey Owner { unOwner = 2 } }
)
, ( UpId 1
, VKeyGenesis { unVKeyGenesis = VKey Owner { unOwner = 3 } }
)
]
, fromList
[ ( ProtVer { _pvMaj = 1 , _pvMin = 0 , _pvAlt = 0 }
, VKeyGenesis { unVKeyGenesis = VKey Owner { unOwner = 0 } }
)
, ( ProtVer { _pvMaj = 1 , _pvMin = 0 , _pvAlt = 0 }
, VKeyGenesis { unVKeyGenesis = VKey Owner { unOwner = 1 } }
)
, ( ProtVer { _pvMaj = 1 , _pvMin = 0 , _pvAlt = 0 }
, VKeyGenesis { unVKeyGenesis = VKey Owner { unOwner = 3 } }
)
]
, fromList [ ( UpId 1 , Slot { unSlot = 2 } ) ]
)
]
]