@@ -27,6 +27,7 @@ import (
27
27
"github.com/blinklabs-io/gouroboros/ledger/common"
28
28
"github.com/blinklabs-io/gouroboros/ledger/mary"
29
29
"github.com/blinklabs-io/gouroboros/ledger/shelley"
30
+ "github.com/utxorpc/go-codegen/utxorpc/v1alpha/cardano"
30
31
)
31
32
32
33
func TestAlonzoProtocolParamsUpdate (t * testing.T ) {
@@ -181,3 +182,118 @@ func TestAlonzoProtocolParamsUpdateFromGenesis(t *testing.T) {
181
182
}
182
183
}
183
184
}
185
+
186
+ func TestAlonzoUtxorpc (t * testing.T ) {
187
+ inputParams := alonzo.AlonzoProtocolParameters {
188
+ MaryProtocolParameters : mary.MaryProtocolParameters {
189
+ AllegraProtocolParameters : allegra.AllegraProtocolParameters {
190
+ ShelleyProtocolParameters : shelley.ShelleyProtocolParameters {
191
+ MaxTxSize : 16384 ,
192
+ MinFeeA : 500 ,
193
+ MinFeeB : 2 ,
194
+ MaxBlockBodySize : 65536 ,
195
+ MaxBlockHeaderSize : 1024 ,
196
+ KeyDeposit : 2000 ,
197
+ PoolDeposit : 500000 ,
198
+ MaxEpoch : 2160 ,
199
+ NOpt : 100 ,
200
+ A0 : & cbor.Rat {Rat : big .NewRat (1 , 2 )},
201
+ Rho : & cbor.Rat {Rat : big .NewRat (3 , 4 )},
202
+ Tau : & cbor.Rat {Rat : big .NewRat (5 , 6 )},
203
+ ProtocolMajor : 8 ,
204
+ ProtocolMinor : 0 ,
205
+ },
206
+ },
207
+ },
208
+ AdaPerUtxoByte : 44 ,
209
+ MinPoolCost : 340000000 ,
210
+ MaxValueSize : 1024 ,
211
+ CollateralPercentage : 150 ,
212
+ MaxCollateralInputs : 5 ,
213
+ ExecutionCosts : common.ExUnitPrice {
214
+ MemPrice : & cbor.Rat {Rat : big .NewRat (1 , 2 )},
215
+ StepPrice : & cbor.Rat {Rat : big .NewRat (2 , 3 )},
216
+ },
217
+ MaxTxExUnits : common.ExUnit {
218
+ Mem : 1000000 ,
219
+ Steps : 200000 ,
220
+ },
221
+ MaxBlockExUnits : common.ExUnit {
222
+ Mem : 5000000 ,
223
+ Steps : 1000000 ,
224
+ },
225
+ CostModels : map [uint ][]int64 {
226
+ 1 : {100 , 200 , 300 },
227
+ 2 : {400 , 500 , 600 },
228
+ 3 : {700 , 800 , 900 },
229
+ },
230
+ }
231
+
232
+ expectedUtxorpc := & cardano.PParams {
233
+ CoinsPerUtxoByte : 44 ,
234
+ MaxTxSize : 16384 ,
235
+ MinFeeCoefficient : 500 ,
236
+ MinFeeConstant : 2 ,
237
+ MaxBlockBodySize : 65536 ,
238
+ MaxBlockHeaderSize : 1024 ,
239
+ StakeKeyDeposit : 2000 ,
240
+ PoolDeposit : 500000 ,
241
+ PoolRetirementEpochBound : 2160 ,
242
+ DesiredNumberOfPools : 100 ,
243
+ PoolInfluence : & cardano.RationalNumber {
244
+ Numerator : int32 (1 ),
245
+ Denominator : uint32 (2 ),
246
+ },
247
+ MonetaryExpansion : & cardano.RationalNumber {
248
+ Numerator : int32 (3 ),
249
+ Denominator : uint32 (4 ),
250
+ },
251
+ TreasuryExpansion : & cardano.RationalNumber {
252
+ Numerator : int32 (5 ),
253
+ Denominator : uint32 (6 ),
254
+ },
255
+ MinPoolCost : 340000000 ,
256
+ ProtocolVersion : & cardano.ProtocolVersion {
257
+ Major : 8 ,
258
+ Minor : 0 ,
259
+ },
260
+ MaxValueSize : 1024 ,
261
+ CollateralPercentage : 150 ,
262
+ MaxCollateralInputs : 5 ,
263
+ CostModels : & cardano.CostModels {
264
+ PlutusV1 : & cardano.CostModel {
265
+ Values : []int64 {100 , 200 , 300 },
266
+ },
267
+ PlutusV2 : & cardano.CostModel {
268
+ Values : []int64 {400 , 500 , 600 },
269
+ },
270
+ PlutusV3 : & cardano.CostModel {
271
+ Values : []int64 {700 , 800 , 900 },
272
+ },
273
+ },
274
+ Prices : & cardano.ExPrices {
275
+ Memory : & cardano.RationalNumber {
276
+ Numerator : int32 (1 ),
277
+ Denominator : uint32 (2 ),
278
+ },
279
+ Steps : & cardano.RationalNumber {
280
+ Numerator : int32 (2 ),
281
+ Denominator : uint32 (3 ),
282
+ },
283
+ },
284
+ MaxExecutionUnitsPerTransaction : & cardano.ExUnits {
285
+ Memory : 1000000 ,
286
+ Steps : 200000 ,
287
+ },
288
+ MaxExecutionUnitsPerBlock : & cardano.ExUnits {
289
+ Memory : 5000000 ,
290
+ Steps : 1000000 ,
291
+ },
292
+ }
293
+
294
+ result := inputParams .Utxorpc ()
295
+
296
+ if ! reflect .DeepEqual (result , expectedUtxorpc ) {
297
+ t .Fatalf ("Utxorpc() test failed for Alonzo:\n Expected: %#v\n Got: %#v" , expectedUtxorpc , result )
298
+ }
299
+ }
0 commit comments