@@ -16,13 +16,15 @@ package conway_test
16
16
17
17
import (
18
18
"encoding/hex"
19
+ "math/big"
19
20
"reflect"
20
21
"strings"
21
22
"testing"
22
23
23
24
"github.com/blinklabs-io/gouroboros/cbor"
24
25
"github.com/blinklabs-io/gouroboros/ledger/common"
25
26
"github.com/blinklabs-io/gouroboros/ledger/conway"
27
+ "github.com/utxorpc/go-codegen/utxorpc/v1alpha/cardano"
26
28
)
27
29
28
30
func TestConwayProtocolParamsUpdate (t * testing.T ) {
@@ -118,3 +120,83 @@ func TestConwayProtocolParamsUpdateFromGenesis(t *testing.T) {
118
120
}
119
121
}
120
122
}
123
+ func TestUtxorpc (t * testing.T ) {
124
+ // Define test cases
125
+ testDefs := []struct {
126
+ startParams conway.ConwayProtocolParameters
127
+ expectedUtxorpc * cardano.PParams
128
+ }{
129
+ {
130
+ startParams : conway.ConwayProtocolParameters {
131
+ AdaPerUtxoByte : 44 ,
132
+ MaxTxSize : 16384 ,
133
+ MinFeeA : 500 ,
134
+ MinFeeB : 2 ,
135
+ MaxBlockBodySize : 65536 ,
136
+ MaxBlockHeaderSize : 1024 ,
137
+ KeyDeposit : 2000 ,
138
+ PoolDeposit : 500000 ,
139
+ MaxEpoch : 2160 ,
140
+ NOpt : 100 ,
141
+ A0 : & cbor.Rat {Rat : big .NewRat (1 , 2 )},
142
+ Rho : & cbor.Rat {Rat : big .NewRat (3 , 4 )},
143
+ Tau : & cbor.Rat {Rat : big .NewRat (5 , 6 )},
144
+ MinPoolCost : 340000000 ,
145
+ ProtocolVersion : common.ProtocolParametersProtocolVersion {Major : 8 , Minor : 0 },
146
+ MaxValueSize : 1024 ,
147
+ CollateralPercentage : 150 ,
148
+ MaxCollateralInputs : 5 ,
149
+ ExecutionCosts : common.ExUnitPrice {MemPrice : & cbor.Rat {Rat : big .NewRat (1 , 2 )}, StepPrice : & cbor.Rat {Rat : big .NewRat (2 , 3 )}},
150
+ MaxTxExUnits : common.ExUnit {Mem : 1000000 , Steps : 200000 },
151
+ MaxBlockExUnits : common.ExUnit {Mem : 5000000 , Steps : 1000000 },
152
+ CostModels : map [uint ][]int64 {
153
+ 1 : {100 , 200 , 300 },
154
+ 2 : {400 , 500 , 600 },
155
+ 3 : {700 , 800 , 900 },
156
+ },
157
+ },
158
+ expectedUtxorpc : & cardano.PParams {
159
+ CoinsPerUtxoByte : 44 ,
160
+ MaxTxSize : 16384 ,
161
+ MinFeeCoefficient : 500 ,
162
+ MinFeeConstant : 2 ,
163
+ MaxBlockBodySize : 65536 ,
164
+ MaxBlockHeaderSize : 1024 ,
165
+ StakeKeyDeposit : 2000 ,
166
+ PoolDeposit : 500000 ,
167
+ PoolRetirementEpochBound : 2160 ,
168
+ DesiredNumberOfPools : 100 ,
169
+ PoolInfluence : & cardano.RationalNumber {Numerator : int32 (1 ), Denominator : uint32 (2 )},
170
+ MonetaryExpansion : & cardano.RationalNumber {Numerator : int32 (3 ), Denominator : uint32 (4 )},
171
+ TreasuryExpansion : & cardano.RationalNumber {Numerator : int32 (5 ), Denominator : uint32 (6 )},
172
+ MinPoolCost : 340000000 ,
173
+ ProtocolVersion : & cardano.ProtocolVersion {
174
+ Major : 8 ,
175
+ Minor : 0 ,
176
+ },
177
+ MaxValueSize : 1024 ,
178
+ CollateralPercentage : 150 ,
179
+ MaxCollateralInputs : 5 ,
180
+ CostModels : & cardano.CostModels {
181
+ PlutusV1 : & cardano.CostModel {Values : []int64 {100 , 200 , 300 }},
182
+ PlutusV2 : & cardano.CostModel {Values : []int64 {400 , 500 , 600 }},
183
+ PlutusV3 : & cardano.CostModel {Values : []int64 {700 , 800 , 900 }},
184
+ },
185
+ Prices : & cardano.ExPrices {
186
+ Memory : & cardano.RationalNumber {Numerator : int32 (1 ), Denominator : uint32 (2 )},
187
+ Steps : & cardano.RationalNumber {Numerator : int32 (2 ), Denominator : uint32 (3 )},
188
+ },
189
+ MaxExecutionUnitsPerTransaction : & cardano.ExUnits {Memory : 1000000 , Steps : 200000 },
190
+ MaxExecutionUnitsPerBlock : & cardano.ExUnits {Memory : 5000000 , Steps : 1000000 },
191
+ },
192
+ },
193
+ }
194
+
195
+ for _ , testDef := range testDefs {
196
+ result := testDef .startParams .Utxorpc ()
197
+ // Compare the result with the expected value
198
+ if ! reflect .DeepEqual (result , testDef .expectedUtxorpc ) {
199
+ t .Fatalf ("Utxorpc() test failed:\n Expected: %#v\n Got: %#v" , testDef .expectedUtxorpc , result )
200
+ }
201
+ }
202
+ }
0 commit comments