Skip to content

Commit a430304

Browse files
authored
chore: make format golines (#1203)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent e3f275b commit a430304

File tree

18 files changed

+168
-40
lines changed

18 files changed

+168
-40
lines changed

internal/test/ledger/ledger.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ func (ls MockLedgerState) PoolCurrentState(
6767
poolKeyHash []byte,
6868
) (*common.PoolRegistrationCertificate, *uint64, error) {
6969
for _, cert := range ls.MockPoolRegistration {
70-
if string(common.Blake2b224(cert.Operator).Bytes()) == string(poolKeyHash) {
70+
if string(
71+
common.Blake2b224(cert.Operator).Bytes(),
72+
) == string(
73+
poolKeyHash,
74+
) {
7175
// pretend latest registration is current; no retirement support in mock
7276
c := cert
7377
return &c, nil, nil

ledger/allegra/pparams_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,10 @@ func TestAllegraTransactionBody_Utxorpc(t *testing.T) {
164164
// Run Utxorpc conversion
165165
actual, err := txBody.Utxorpc()
166166
if err != nil {
167-
t.Fatalf("Could not convert transaction body to utxorpc format: %v", err)
167+
t.Fatalf(
168+
"Could not convert transaction body to utxorpc format: %v",
169+
err,
170+
)
168171
}
169172

170173
// Check that the fee matches

ledger/alonzo/alonzo_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,17 @@ func TestAlonzoTransactionOutputString(t *testing.T) {
284284
addr, _ := common.NewAddress(addrStr)
285285
ma := common.NewMultiAsset[common.MultiAssetTypeOutput](
286286
map[common.Blake2b224]map[cbor.ByteString]uint64{
287-
common.NewBlake2b224(make([]byte, 28)): {cbor.NewByteString([]byte("t")): 2},
287+
common.NewBlake2b224(make([]byte, 28)): {
288+
cbor.NewByteString([]byte("t")): 2,
289+
},
288290
},
289291
)
290292
out := AlonzoTransactionOutput{
291293
OutputAddress: addr,
292-
OutputAmount: mary.MaryTransactionOutputValue{Amount: 456, Assets: &ma},
294+
OutputAmount: mary.MaryTransactionOutputValue{
295+
Amount: 456,
296+
Assets: &ma,
297+
},
293298
}
294299
s := out.String()
295300
policyStr := common.NewBlake2b224(make([]byte, 28)).String()

ledger/alonzo/pparams_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,8 @@ func TestScientificNotationInCostModels(t *testing.T) {
261261
}
262262

263263
expected := []int64{2477736, 1500000, 1000000}
264-
if params.CostModels == nil || params.CostModels[alonzo.PlutusV1Key] == nil {
264+
if params.CostModels == nil ||
265+
params.CostModels[alonzo.PlutusV1Key] == nil {
265266
t.Fatal("CostModels not properly initialized")
266267
}
267268
for i := range 3 {
@@ -520,7 +521,10 @@ func TestAlonzoTransactionBody_Utxorpc(t *testing.T) {
520521
// Run Utxorpc conversion
521522
got, err := body.Utxorpc()
522523
if err != nil {
523-
t.Fatalf("Could not convert transaction body to utxorpc format: %v", err)
524+
t.Fatalf(
525+
"Could not convert transaction body to utxorpc format: %v",
526+
err,
527+
)
524528
}
525529

526530
// Assertion checks

ledger/babbage/babbage_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2976,12 +2976,17 @@ func TestBabbageTransactionOutputString(t *testing.T) {
29762976
addr, _ := common.NewAddress(addrStr)
29772977
ma := common.NewMultiAsset[common.MultiAssetTypeOutput](
29782978
map[common.Blake2b224]map[cbor.ByteString]uint64{
2979-
common.NewBlake2b224(make([]byte, 28)): {cbor.NewByteString([]byte("x")): 2},
2979+
common.NewBlake2b224(make([]byte, 28)): {
2980+
cbor.NewByteString([]byte("x")): 2,
2981+
},
29802982
},
29812983
)
29822984
out := BabbageTransactionOutput{
29832985
OutputAddress: addr,
2984-
OutputAmount: mary.MaryTransactionOutputValue{Amount: 456, Assets: &ma},
2986+
OutputAmount: mary.MaryTransactionOutputValue{
2987+
Amount: 456,
2988+
Assets: &ma,
2989+
},
29852990
}
29862991
s := out.String()
29872992
expected := "(BabbageTransactionOutput address=" + addrStr + " amount=456 assets=" + ma.String() + ")"

ledger/babbage/pparams_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,10 @@ func TestBabbageTransactionBody_Utxorpc(t *testing.T) {
637637

638638
got, err := body.Utxorpc()
639639
if err != nil {
640-
t.Fatalf("Could not convert transaction body to utxorpc format: %v", err)
640+
t.Fatalf(
641+
"Could not convert transaction body to utxorpc format: %v",
642+
err,
643+
)
641644
}
642645
if got.Fee != 100 {
643646
t.Errorf("Fee mismatch: got %d, want 100", got.Fee)

ledger/common/address.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,15 +228,21 @@ func (a *Address) populateFromBytes(data []byte) error {
228228
// Payment payload
229229
payload := data[1:]
230230
switch a.addressType {
231-
case AddressTypeKeyKey, AddressTypeKeyScript, AddressTypeKeyPointer, AddressTypeKeyNone:
231+
case AddressTypeKeyKey,
232+
AddressTypeKeyScript,
233+
AddressTypeKeyPointer,
234+
AddressTypeKeyNone:
232235
if len(payload) < AddressHashSize {
233236
return errors.New("invalid payment payload: key hash too small")
234237
}
235238
a.paymentPayload = AddressPayloadKeyHash{
236239
Hash: AddrKeyHash(payload[0:AddressHashSize]),
237240
}
238241
payload = payload[AddressHashSize:]
239-
case AddressTypeScriptKey, AddressTypeScriptScript, AddressTypeScriptPointer, AddressTypeScriptNone:
242+
case AddressTypeScriptKey,
243+
AddressTypeScriptScript,
244+
AddressTypeScriptPointer,
245+
AddressTypeScriptNone:
240246
if len(payload) < AddressHashSize {
241247
return errors.New("invalid payment payload: script hash too small")
242248
}

ledger/common/common.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,15 +338,21 @@ func (m *MultiAsset[T]) String() string {
338338
}
339339

340340
policies := slices.Collect(maps.Keys(norm))
341-
slices.SortFunc(policies, func(a, b Blake2b224) int { return bytes.Compare(a.Bytes(), b.Bytes()) })
341+
slices.SortFunc(
342+
policies,
343+
func(a, b Blake2b224) int { return bytes.Compare(a.Bytes(), b.Bytes()) },
344+
)
342345

343346
var b strings.Builder
344347
b.WriteByte('[')
345348
first := true
346349
for _, pid := range policies {
347350
assets := norm[pid]
348351
names := slices.Collect(maps.Keys(assets))
349-
slices.SortFunc(names, func(a, b cbor.ByteString) int { return bytes.Compare(a.Bytes(), b.Bytes()) })
352+
slices.SortFunc(
353+
names,
354+
func(a, b cbor.ByteString) int { return bytes.Compare(a.Bytes(), b.Bytes()) },
355+
)
350356

351357
for _, name := range names {
352358
if !first {

ledger/common/script/context.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,11 @@ func votingInfo(
458458
) KeyValuePairs[*lcommon.Voter, KeyValuePairs[*lcommon.GovActionId, lcommon.VotingProcedure]] {
459459
var ret KeyValuePairs[*lcommon.Voter, KeyValuePairs[*lcommon.GovActionId, lcommon.VotingProcedure]]
460460
for voter, voterData := range votingProcedures {
461-
voterPairs := make(KeyValuePairs[*lcommon.GovActionId, lcommon.VotingProcedure], 0, len(votingProcedures))
461+
voterPairs := make(
462+
KeyValuePairs[*lcommon.GovActionId, lcommon.VotingProcedure],
463+
0,
464+
len(votingProcedures),
465+
)
462466
for govActionId, votingProcedure := range voterData {
463467
voterPairs = append(
464468
voterPairs,
@@ -473,7 +477,10 @@ func votingInfo(
473477
voterPairs,
474478
func(a, b KeyValuePair[*lcommon.GovActionId, lcommon.VotingProcedure]) int {
475479
// Compare TX ID
476-
x := bytes.Compare(a.Key.TransactionId[:], b.Key.TransactionId[:])
480+
x := bytes.Compare(
481+
a.Key.TransactionId[:],
482+
b.Key.TransactionId[:],
483+
)
477484
if x != 0 {
478485
return x
479486
}

ledger/conway/conway_test.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,11 @@ func TestConwayTx_CborRoundTrip_UsingCborEncode(t *testing.T) {
145145
}
146146

147147
if !bytes.Equal(orig, enc) {
148-
t.Errorf("CBOR round-trip mismatch\noriginal: %x\nencoded : %x", orig, enc)
148+
t.Errorf(
149+
"CBOR round-trip mismatch\noriginal: %x\nencoded : %x",
150+
orig,
151+
enc,
152+
)
149153

150154
i := -1
151155
for j := 0; j < len(orig) && j < len(enc); j++ {
@@ -155,7 +159,12 @@ func TestConwayTx_CborRoundTrip_UsingCborEncode(t *testing.T) {
155159
}
156160
}
157161
if i != -1 {
158-
t.Logf("first diff at byte %d: orig=0x%02x enc=0x%02x", i, orig[i], enc[i])
162+
t.Logf(
163+
"first diff at byte %d: orig=0x%02x enc=0x%02x",
164+
i,
165+
orig[i],
166+
enc[i],
167+
)
159168
} else {
160169
t.Logf("length mismatch: orig=%d enc=%d", len(orig), len(enc))
161170
}
@@ -181,7 +190,11 @@ func TestConwayTx_Utxorpc(t *testing.T) {
181190

182191
expHash := tx.Id().Bytes()
183192
if !bytes.Equal(utxoTx.Hash, expHash) {
184-
t.Errorf("tx hash mismatch\nexpected: %x\nactual : %x", expHash, utxoTx.Hash)
193+
t.Errorf(
194+
"tx hash mismatch\nexpected: %x\nactual : %x",
195+
expHash,
196+
utxoTx.Hash,
197+
)
185198
}
186199

187200
if got, want := len(utxoTx.Inputs), len(tx.Inputs()); got != want {

0 commit comments

Comments
 (0)