Skip to content

Commit 429968d

Browse files
authored
chore: make format golines (#942)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent 6d54ea3 commit 429968d

File tree

23 files changed

+490
-112
lines changed

23 files changed

+490
-112
lines changed

internal/test/ledger/ledger.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ func (ls MockLedgerState) UtxoById(
4646
return common.Utxo{}, errors.New("not found")
4747
}
4848

49-
func (ls MockLedgerState) StakeRegistration(stakingKey []byte) ([]common.StakeRegistrationCertificate, error) {
49+
func (ls MockLedgerState) StakeRegistration(
50+
stakingKey []byte,
51+
) ([]common.StakeRegistrationCertificate, error) {
5052
ret := []common.StakeRegistrationCertificate{}
5153
for _, cert := range ls.MockStakeRegistration {
5254
if string(cert.StakeRegistration.Credential) == string(stakingKey) {
@@ -56,10 +58,16 @@ func (ls MockLedgerState) StakeRegistration(stakingKey []byte) ([]common.StakeRe
5658
return ret, nil
5759
}
5860

59-
func (ls MockLedgerState) PoolRegistration(poolKeyHash []byte) ([]common.PoolRegistrationCertificate, error) {
61+
func (ls MockLedgerState) PoolRegistration(
62+
poolKeyHash []byte,
63+
) ([]common.PoolRegistrationCertificate, error) {
6064
ret := []common.PoolRegistrationCertificate{}
6165
for _, cert := range ls.MockPoolRegistration {
62-
if string(common.Blake2b224(cert.Operator).Bytes()) == string(poolKeyHash) {
66+
if string(
67+
common.Blake2b224(cert.Operator).Bytes(),
68+
) == string(
69+
poolKeyHash,
70+
) {
6371
ret = append(ret, cert)
6472
}
6573
}

ledger/alonzo/rules.go

Lines changed: 116 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ var UtxoValidationRules = []common.UtxoValidationRuleFunc{
4343
}
4444

4545
// UtxoValidateOutputTooBigUtxo ensures that transaction output values are not too large
46-
func UtxoValidateOutputTooBigUtxo(tx common.Transaction, slot uint64, _ common.LedgerState, pp common.ProtocolParameters) error {
46+
func UtxoValidateOutputTooBigUtxo(
47+
tx common.Transaction,
48+
slot uint64,
49+
_ common.LedgerState,
50+
pp common.ProtocolParameters,
51+
) error {
4752
tmpPparams, ok := pp.(*AlonzoProtocolParameters)
4853
if !ok {
4954
return errors.New("pparams are not expected type")
@@ -72,7 +77,12 @@ func UtxoValidateOutputTooBigUtxo(tx common.Transaction, slot uint64, _ common.L
7277
}
7378

7479
// UtxoValidateExUnitsTooBigUtxo ensures that ExUnits for a transaction do not exceed the maximum specified via protocol parameters
75-
func UtxoValidateExUnitsTooBigUtxo(tx common.Transaction, slot uint64, ls common.LedgerState, pp common.ProtocolParameters) error {
80+
func UtxoValidateExUnitsTooBigUtxo(
81+
tx common.Transaction,
82+
slot uint64,
83+
ls common.LedgerState,
84+
pp common.ProtocolParameters,
85+
) error {
7686
tmpPparams, ok := pp.(*AlonzoProtocolParameters)
7787
if !ok {
7888
return errors.New("pparams are not expected type")
@@ -86,7 +96,8 @@ func UtxoValidateExUnitsTooBigUtxo(tx common.Transaction, slot uint64, ls common
8696
totalSteps += redeemer.ExUnits.Steps
8797
totalMemory += redeemer.ExUnits.Memory
8898
}
89-
if totalSteps <= tmpPparams.MaxTxExUnits.Steps && totalMemory <= tmpPparams.MaxTxExUnits.Memory {
99+
if totalSteps <= tmpPparams.MaxTxExUnits.Steps &&
100+
totalMemory <= tmpPparams.MaxTxExUnits.Memory {
90101
return nil
91102
}
92103
return ExUnitsTooBigUtxoError{
@@ -98,24 +109,49 @@ func UtxoValidateExUnitsTooBigUtxo(tx common.Transaction, slot uint64, ls common
98109
}
99110
}
100111

101-
func UtxoValidateOutsideValidityIntervalUtxo(tx common.Transaction, slot uint64, ls common.LedgerState, pp common.ProtocolParameters) error {
112+
func UtxoValidateOutsideValidityIntervalUtxo(
113+
tx common.Transaction,
114+
slot uint64,
115+
ls common.LedgerState,
116+
pp common.ProtocolParameters,
117+
) error {
102118
return allegra.UtxoValidateOutsideValidityIntervalUtxo(tx, slot, ls, pp)
103119
}
104120

105-
func UtxoValidateInputSetEmptyUtxo(tx common.Transaction, slot uint64, ls common.LedgerState, pp common.ProtocolParameters) error {
121+
func UtxoValidateInputSetEmptyUtxo(
122+
tx common.Transaction,
123+
slot uint64,
124+
ls common.LedgerState,
125+
pp common.ProtocolParameters,
126+
) error {
106127
return shelley.UtxoValidateInputSetEmptyUtxo(tx, slot, ls, pp)
107128
}
108129

109-
func UtxoValidateFeeTooSmallUtxo(tx common.Transaction, slot uint64, ls common.LedgerState, pp common.ProtocolParameters) error {
130+
func UtxoValidateFeeTooSmallUtxo(
131+
tx common.Transaction,
132+
slot uint64,
133+
ls common.LedgerState,
134+
pp common.ProtocolParameters,
135+
) error {
110136
tmpPparams, ok := pp.(*AlonzoProtocolParameters)
111137
if !ok {
112138
return errors.New("pparams are not expected type")
113139
}
114-
return shelley.UtxoValidateFeeTooSmallUtxo(tx, slot, ls, &tmpPparams.ShelleyProtocolParameters)
140+
return shelley.UtxoValidateFeeTooSmallUtxo(
141+
tx,
142+
slot,
143+
ls,
144+
&tmpPparams.ShelleyProtocolParameters,
145+
)
115146
}
116147

117148
// UtxoValidateInsufficientCollateral ensures that there is sufficient collateral provided
118-
func UtxoValidateInsufficientCollateral(tx common.Transaction, slot uint64, ls common.LedgerState, pp common.ProtocolParameters) error {
149+
func UtxoValidateInsufficientCollateral(
150+
tx common.Transaction,
151+
slot uint64,
152+
ls common.LedgerState,
153+
pp common.ProtocolParameters,
154+
) error {
119155
tmpPparams, ok := pp.(*AlonzoProtocolParameters)
120156
if !ok {
121157
return errors.New("pparams are not expected type")
@@ -147,7 +183,12 @@ func UtxoValidateInsufficientCollateral(tx common.Transaction, slot uint64, ls c
147183
}
148184

149185
// UtxoValidateCollateralContainsNonAda ensures that collateral inputs don't contain non-ADA
150-
func UtxoValidateCollateralContainsNonAda(tx common.Transaction, slot uint64, ls common.LedgerState, pp common.ProtocolParameters) error {
186+
func UtxoValidateCollateralContainsNonAda(
187+
tx common.Transaction,
188+
slot uint64,
189+
ls common.LedgerState,
190+
pp common.ProtocolParameters,
191+
) error {
151192
tmpTx, ok := tx.(*AlonzoTransaction)
152193
if !ok {
153194
return errors.New("transaction is not expected type")
@@ -178,7 +219,12 @@ func UtxoValidateCollateralContainsNonAda(tx common.Transaction, slot uint64, ls
178219
}
179220

180221
// UtxoValidateNoCollateralInputs ensures that collateral inputs are provided when redeemers are present
181-
func UtxoValidateNoCollateralInputs(tx common.Transaction, slot uint64, ls common.LedgerState, pp common.ProtocolParameters) error {
222+
func UtxoValidateNoCollateralInputs(
223+
tx common.Transaction,
224+
slot uint64,
225+
ls common.LedgerState,
226+
pp common.ProtocolParameters,
227+
) error {
182228
tmpTx, ok := tx.(*AlonzoTransaction)
183229
if !ok {
184230
return errors.New("transaction is not expected type")
@@ -193,42 +239,92 @@ func UtxoValidateNoCollateralInputs(tx common.Transaction, slot uint64, ls commo
193239
return NoCollateralInputsError{}
194240
}
195241

196-
func UtxoValidateBadInputsUtxo(tx common.Transaction, slot uint64, ls common.LedgerState, pp common.ProtocolParameters) error {
242+
func UtxoValidateBadInputsUtxo(
243+
tx common.Transaction,
244+
slot uint64,
245+
ls common.LedgerState,
246+
pp common.ProtocolParameters,
247+
) error {
197248
return shelley.UtxoValidateBadInputsUtxo(tx, slot, ls, pp)
198249
}
199250

200-
func UtxoValidateValueNotConservedUtxo(tx common.Transaction, slot uint64, ls common.LedgerState, pp common.ProtocolParameters) error {
251+
func UtxoValidateValueNotConservedUtxo(
252+
tx common.Transaction,
253+
slot uint64,
254+
ls common.LedgerState,
255+
pp common.ProtocolParameters,
256+
) error {
201257
tmpPparams, ok := pp.(*AlonzoProtocolParameters)
202258
if !ok {
203259
return errors.New("pparams are not expected type")
204260
}
205-
return shelley.UtxoValidateValueNotConservedUtxo(tx, slot, ls, &tmpPparams.ShelleyProtocolParameters)
261+
return shelley.UtxoValidateValueNotConservedUtxo(
262+
tx,
263+
slot,
264+
ls,
265+
&tmpPparams.ShelleyProtocolParameters,
266+
)
206267
}
207268

208-
func UtxoValidateOutputTooSmallUtxo(tx common.Transaction, slot uint64, ls common.LedgerState, pp common.ProtocolParameters) error {
269+
func UtxoValidateOutputTooSmallUtxo(
270+
tx common.Transaction,
271+
slot uint64,
272+
ls common.LedgerState,
273+
pp common.ProtocolParameters,
274+
) error {
209275
tmpPparams, ok := pp.(*AlonzoProtocolParameters)
210276
if !ok {
211277
return errors.New("pparams are not expected type")
212278
}
213-
return shelley.UtxoValidateOutputTooSmallUtxo(tx, slot, ls, &tmpPparams.ShelleyProtocolParameters)
279+
return shelley.UtxoValidateOutputTooSmallUtxo(
280+
tx,
281+
slot,
282+
ls,
283+
&tmpPparams.ShelleyProtocolParameters,
284+
)
214285
}
215286

216-
func UtxoValidateOutputBootAddrAttrsTooBig(tx common.Transaction, slot uint64, ls common.LedgerState, pp common.ProtocolParameters) error {
287+
func UtxoValidateOutputBootAddrAttrsTooBig(
288+
tx common.Transaction,
289+
slot uint64,
290+
ls common.LedgerState,
291+
pp common.ProtocolParameters,
292+
) error {
217293
return shelley.UtxoValidateOutputBootAddrAttrsTooBig(tx, slot, ls, pp)
218294
}
219295

220-
func UtxoValidateWrongNetwork(tx common.Transaction, slot uint64, ls common.LedgerState, pp common.ProtocolParameters) error {
296+
func UtxoValidateWrongNetwork(
297+
tx common.Transaction,
298+
slot uint64,
299+
ls common.LedgerState,
300+
pp common.ProtocolParameters,
301+
) error {
221302
return shelley.UtxoValidateWrongNetwork(tx, slot, ls, pp)
222303
}
223304

224-
func UtxoValidateWrongNetworkWithdrawal(tx common.Transaction, slot uint64, ls common.LedgerState, pp common.ProtocolParameters) error {
305+
func UtxoValidateWrongNetworkWithdrawal(
306+
tx common.Transaction,
307+
slot uint64,
308+
ls common.LedgerState,
309+
pp common.ProtocolParameters,
310+
) error {
225311
return shelley.UtxoValidateWrongNetworkWithdrawal(tx, slot, ls, pp)
226312
}
227313

228-
func UtxoValidateMaxTxSizeUtxo(tx common.Transaction, slot uint64, ls common.LedgerState, pp common.ProtocolParameters) error {
314+
func UtxoValidateMaxTxSizeUtxo(
315+
tx common.Transaction,
316+
slot uint64,
317+
ls common.LedgerState,
318+
pp common.ProtocolParameters,
319+
) error {
229320
tmpPparams, ok := pp.(*AlonzoProtocolParameters)
230321
if !ok {
231322
return errors.New("pparams are not expected type")
232323
}
233-
return shelley.UtxoValidateMaxTxSizeUtxo(tx, slot, ls, &tmpPparams.ShelleyProtocolParameters)
324+
return shelley.UtxoValidateMaxTxSizeUtxo(
325+
tx,
326+
slot,
327+
ls,
328+
&tmpPparams.ShelleyProtocolParameters,
329+
)
234330
}

ledger/alonzo/rules_test.go

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,12 @@ func TestUtxoValidateBadInputsUtxo(t *testing.T) {
380380
}
381381

382382
func TestUtxoValidateWrongNetwork(t *testing.T) {
383-
testCorrectNetworkAddr, _ := common.NewAddress("addr1qytna5k2fq9ler0fuk45j7zfwv7t2zwhp777nvdjqqfr5tz8ztpwnk8zq5ngetcz5k5mckgkajnygtsra9aej2h3ek5seupmvd")
384-
testWrongNetworkAddr, _ := common.NewAddress("addr_test1qqx80sj9nwxdnglmzdl95v2k40d9422au0klwav8jz2dj985v0wma0mza32f8z6pv2jmkn7cen50f9vn9jmp7dd0njcqqpce07")
383+
testCorrectNetworkAddr, _ := common.NewAddress(
384+
"addr1qytna5k2fq9ler0fuk45j7zfwv7t2zwhp777nvdjqqfr5tz8ztpwnk8zq5ngetcz5k5mckgkajnygtsra9aej2h3ek5seupmvd",
385+
)
386+
testWrongNetworkAddr, _ := common.NewAddress(
387+
"addr_test1qqx80sj9nwxdnglmzdl95v2k40d9422au0klwav8jz2dj985v0wma0mza32f8z6pv2jmkn7cen50f9vn9jmp7dd0njcqqpce07",
388+
)
385389
testTx := &alonzo.AlonzoTransaction{
386390
Body: alonzo.AlonzoTransactionBody{
387391
TxOutputs: []alonzo.AlonzoTransactionOutput{
@@ -448,8 +452,12 @@ func TestUtxoValidateWrongNetwork(t *testing.T) {
448452
}
449453

450454
func TestUtxoValidateWrongNetworkWithdrawal(t *testing.T) {
451-
testCorrectNetworkAddr, _ := common.NewAddress("addr1qytna5k2fq9ler0fuk45j7zfwv7t2zwhp777nvdjqqfr5tz8ztpwnk8zq5ngetcz5k5mckgkajnygtsra9aej2h3ek5seupmvd")
452-
testWrongNetworkAddr, _ := common.NewAddress("addr_test1qqx80sj9nwxdnglmzdl95v2k40d9422au0klwav8jz2dj985v0wma0mza32f8z6pv2jmkn7cen50f9vn9jmp7dd0njcqqpce07")
455+
testCorrectNetworkAddr, _ := common.NewAddress(
456+
"addr1qytna5k2fq9ler0fuk45j7zfwv7t2zwhp777nvdjqqfr5tz8ztpwnk8zq5ngetcz5k5mckgkajnygtsra9aej2h3ek5seupmvd",
457+
)
458+
testWrongNetworkAddr, _ := common.NewAddress(
459+
"addr_test1qqx80sj9nwxdnglmzdl95v2k40d9422au0klwav8jz2dj985v0wma0mza32f8z6pv2jmkn7cen50f9vn9jmp7dd0njcqqpce07",
460+
)
453461
testTx := &alonzo.AlonzoTransaction{
454462
Body: alonzo.AlonzoTransactionBody{
455463
MaryTransactionBody: mary.MaryTransactionBody{
@@ -535,7 +543,10 @@ func TestUtxoValidateValueNotConservedUtxo(t *testing.T) {
535543
TxFee: testFee,
536544
TxInputs: shelley.NewShelleyTransactionInputSet(
537545
[]shelley.ShelleyTransactionInput{
538-
shelley.NewShelleyTransactionInput(testInputTxId, 0),
546+
shelley.NewShelleyTransactionInput(
547+
testInputTxId,
548+
0,
549+
),
539550
},
540551
),
541552
},
@@ -785,7 +796,9 @@ func TestUtxoValidateOutputTooBigUtxo(t *testing.T) {
785796
cbor.NewByteString(tmpAssetName): 1,
786797
}
787798
}
788-
tmpBadMultiAsset := common.NewMultiAsset[common.MultiAssetTypeOutput](tmpBadAssets)
799+
tmpBadMultiAsset := common.NewMultiAsset[common.MultiAssetTypeOutput](
800+
tmpBadAssets,
801+
)
789802
var testOutputValueBad = mary.MaryTransactionOutputValue{
790803
Amount: 1234567,
791804
Assets: &tmpBadMultiAsset,
@@ -853,7 +866,9 @@ func TestUtxoValidateOutputTooBigUtxo(t *testing.T) {
853866
}
854867

855868
func TestUtxoValidateOutputBootAddrAttrsTooBig(t *testing.T) {
856-
testGoodAddr, _ := common.NewAddress("addr1qytna5k2fq9ler0fuk45j7zfwv7t2zwhp777nvdjqqfr5tz8ztpwnk8zq5ngetcz5k5mckgkajnygtsra9aej2h3ek5seupmvd")
869+
testGoodAddr, _ := common.NewAddress(
870+
"addr1qytna5k2fq9ler0fuk45j7zfwv7t2zwhp777nvdjqqfr5tz8ztpwnk8zq5ngetcz5k5mckgkajnygtsra9aej2h3ek5seupmvd",
871+
)
857872
// Generate random pubkey
858873
testBadAddrPubkey := make([]byte, 28)
859874
if _, err := rand.Read(testBadAddrPubkey); err != nil {

0 commit comments

Comments
 (0)