@@ -11,60 +11,65 @@ where
11
11
12
12
import Cardano.Ledger.Coin (Coin (.. ))
13
13
import Cardano.Ledger.Alonzo (AlonzoEra )
14
- import Cardano.Ledger.Mary.Value (AssetName (.. ), PolicyID (.. ), Value (.. ))
15
- import Cardano.Ledger.ShelleyMA.Timelocks (Timelock (.. ))
16
- import qualified Data.ByteString.Char8 as BS
14
+ import Cardano.Ledger.Mary.Value (Value (.. ))
17
15
import Data.Char (chr )
18
16
import qualified Data.Map.Strict as Map
19
- import qualified Data.Sequence.Strict as StrictSeq
20
- import Shelley.Spec.Ledger.Slot (SlotNo (.. ))
21
- import Shelley.Spec.Ledger.Tx (hashScript )
22
17
import Test.Cardano.Ledger.EraBuffet (StandardCrypto )
23
18
import Test.Tasty (TestTree , testGroup )
24
19
import Test.Tasty.HUnit (testCase , (@?=) )
25
- import Test.Cardano.Ledger.Mary.Golden
26
20
import Cardano.Ledger.Alonzo.Rules.Utxo (utxoEntrySize )
21
+ import Test.Shelley.Spec.Ledger.Examples.Cast (aliceAddr , bobAddr , carlAddr )
22
+ import Cardano.Ledger.Alonzo.Data (hashData , Data (.. ))
23
+ import Language.PlutusTx (Data (.. ))
24
+ import Cardano.Ledger.Alonzo.TxBody (TxOut (.. ))
25
+ import Test.Cardano.Ledger.Mary.Golden
26
+ ( pid1 ,
27
+ pid2 ,
28
+ pid3 ,
29
+ smallName ,
30
+ smallestName ,
31
+ minUTxO ,
32
+ largestName )
33
+ import Shelley.Spec.Ledger.BaseTypes (StrictMaybe (.. ))
27
34
28
35
-- | ada cost of storing a word8 of data as a UTxO entry, assuming no change to minUTxOValue
29
- adaPerUTxOWordLocal :: Coin
30
- adaPerUTxOWordLocal = Coin $ quot minUTxOValueShelleyMA utxoEntrySizeWithoutValLocal
36
+ adaPerUTxOWordLocal :: Integer
37
+ adaPerUTxOWordLocal = quot minUTxOValueShelleyMA utxoEntrySizeWithoutValLocal
31
38
where
32
39
utxoEntrySizeWithoutValLocal = 29
33
- minUTxOValueShelleyMA = 1000000
40
+ Coin minUTxOValueShelleyMA = minUTxO
34
41
35
- calcMinUTxO :: TxOut era -> Coin
42
+ calcMinUTxO :: TxOut ( AlonzoEra StandardCrypto ) -> Coin
36
43
calcMinUTxO tout = Coin (utxoEntrySize tout * adaPerUTxOWordLocal)
37
44
45
+ -- | (heapWords of a DataHash) * adaPerUTxOWordLocal is 344820
38
46
goldenUTxOEntryMinAda :: TestTree
39
47
goldenUTxOEntryMinAda =
40
48
testGroup
41
49
" golden tests - UTxOEntryMinAda"
42
- [ testCase " one policy, one (smallest) name, no datum hash" $
43
- scaledMinDeposit
44
- ( Value 1407406 $
50
+ [ testCase " one policy, one (smallest) name, yes datum hash" $
51
+ calcMinUTxO
52
+ (TxOut carlAddr ( Value 1407406 $
45
53
Map. singleton pid1 (Map. fromList [(smallestName, 1 )])
46
- )
47
- minUTxO
48
- @?= Coin 1407406 ,
49
- testCase " one policy, one (smallest) name, yes datum hash" $
50
- scaledMinDeposit
51
- ( Value 1407406 $
54
+ ) (SJust $ hashData @ (AlonzoEra StandardCrypto ) (Data (List [] ))) )
55
+ @?= Coin 1655136 ,
56
+ testCase " one policy, one (smallest) name, no datum hash" $
57
+ calcMinUTxO
58
+ (TxOut bobAddr ( Value 1407406 $
52
59
Map. singleton pid1 (Map. fromList [(smallestName, 1 )])
53
- )
54
- minUTxO
55
- @?= Coin 1407406 ,
60
+ ) SNothing )
61
+ @?= Coin 1310316 ,
56
62
testCase " one policy, one (small) name" $
57
- scaledMinDeposit
58
- ( Value 1444443 $
63
+ calcMinUTxO
64
+ (TxOut aliceAddr ( Value 1444443 $
59
65
Map. singleton
60
66
pid1
61
67
(Map. fromList [(smallName ' 1' , 1 )])
62
- )
63
- minUTxO
64
- @?= Coin 1444443 ,
65
- testCase " one policy, three (small) name" $
66
- scaledMinDeposit
67
- ( Value 1555554 $
68
+ ) SNothing )
69
+ @?= Coin 1344798 ,
70
+ testCase " one policy, three (small) names" $
71
+ calcMinUTxO
72
+ (TxOut aliceAddr ( Value 1555554 $
68
73
Map. singleton
69
74
pid1
70
75
( Map. fromList
@@ -73,21 +78,19 @@ goldenUTxOEntryMinAda =
73
78
(smallName ' 3' , 1 )
74
79
]
75
80
)
76
- )
77
- minUTxO
78
- @?= Coin 1555554 ,
81
+ ) SNothing )
82
+ @?= Coin 1448244 ,
79
83
testCase " one policy, one (largest) name" $
80
- scaledMinDeposit
81
- ( Value 1555554 $
84
+ calcMinUTxO
85
+ (TxOut carlAddr ( Value 1555554 $
82
86
Map. singleton
83
87
pid1
84
88
(Map. fromList [(largestName ' a' , 1 )])
85
- )
86
- minUTxO
87
- @?= Coin 1555554 ,
88
- testCase " one policy, three (largest) name" $
89
- scaledMinDeposit
90
- ( Value 1962961 $
89
+ ) SNothing )
90
+ @?= Coin 1448244 ,
91
+ testCase " one policy, three (largest) name, with hash" $
92
+ calcMinUTxO
93
+ (TxOut carlAddr ( Value 1962961 $
91
94
Map. singleton
92
95
pid1
93
96
( Map. fromList
@@ -96,12 +99,24 @@ goldenUTxOEntryMinAda =
96
99
(largestName ' c' , 1 )
97
100
]
98
101
)
99
- )
100
- minUTxO
101
- @?= Coin 1962961 ,
102
+ ) (SJust $ hashData @ (AlonzoEra StandardCrypto ) (Data (Constr 0 [(Constr 0 [] )]))) )
103
+ @?= Coin 2172366 ,
102
104
testCase " two policies, one (smallest) name" $
103
- scaledMinDeposit
104
- ( Value 1592591 $
105
+ calcMinUTxO
106
+ (TxOut aliceAddr ( Value 1592591 $
107
+ Map. fromList
108
+ [ ( pid1,
109
+ (Map. fromList [(smallestName, 1 )])
110
+ ),
111
+ ( pid2,
112
+ (Map. fromList [(smallestName, 1 )])
113
+ )
114
+ ]
115
+ ) SNothing )
116
+ @?= Coin 1482726 ,
117
+ testCase " two policies, one (smallest) name, with hash" $
118
+ calcMinUTxO
119
+ (TxOut aliceAddr ( Value 1592591 $
105
120
Map. fromList
106
121
[ ( pid1,
107
122
(Map. fromList [(smallestName, 1 )])
@@ -110,12 +125,11 @@ goldenUTxOEntryMinAda =
110
125
(Map. fromList [(smallestName, 1 )])
111
126
)
112
127
]
113
- )
114
- minUTxO
115
- @?= Coin 1592591 ,
128
+ ) (SJust $ hashData @ (AlonzoEra StandardCrypto ) (Data (Constr 0 [] ))) )
129
+ @?= Coin 1827546 ,
116
130
testCase " two policies, two (small) names" $
117
- scaledMinDeposit
118
- ( Value 1629628 $
131
+ calcMinUTxO
132
+ (TxOut bobAddr ( Value 1629628 $
119
133
Map. fromList
120
134
[ ( pid1,
121
135
(Map. fromList [(smallName ' 1' , 1 )])
@@ -124,12 +138,11 @@ goldenUTxOEntryMinAda =
124
138
(Map. fromList [(smallName ' 2' , 1 )])
125
139
)
126
140
]
127
- )
128
- minUTxO
129
- @?= Coin 1629628 ,
141
+ ) SNothing )
142
+ @?= Coin 1517208 ,
130
143
testCase " three policies, ninety-six (small) names" $
131
- scaledMinDeposit
132
- ( Value 7407400 $
144
+ calcMinUTxO
145
+ (TxOut aliceAddr ( Value 7407400 $
133
146
Map. fromList
134
147
[ ( pid1,
135
148
(Map. fromList $ map ((,1 ) . smallName . chr) [32 .. 63 ])
@@ -141,7 +154,6 @@ goldenUTxOEntryMinAda =
141
154
(Map. fromList $ map ((,1 ) . smallName . chr) [96 .. 127 ])
142
155
)
143
156
]
144
- )
145
- minUTxO
146
- @?= Coin 7407400
157
+ ) SNothing )
158
+ @?= Coin 6896400
147
159
]
0 commit comments