diff --git a/internal/test/ledger/ledger.go b/internal/test/ledger/ledger.go index 2915945c..6e4e3ead 100644 --- a/internal/test/ledger/ledger.go +++ b/internal/test/ledger/ledger.go @@ -67,7 +67,11 @@ func (ls MockLedgerState) PoolCurrentState( poolKeyHash []byte, ) (*common.PoolRegistrationCertificate, *uint64, error) { for _, cert := range ls.MockPoolRegistration { - if string(common.Blake2b224(cert.Operator).Bytes()) == string(poolKeyHash) { + if string( + common.Blake2b224(cert.Operator).Bytes(), + ) == string( + poolKeyHash, + ) { // pretend latest registration is current; no retirement support in mock c := cert return &c, nil, nil diff --git a/ledger/allegra/pparams_test.go b/ledger/allegra/pparams_test.go index e1f4346f..cc007ed3 100644 --- a/ledger/allegra/pparams_test.go +++ b/ledger/allegra/pparams_test.go @@ -164,7 +164,10 @@ func TestAllegraTransactionBody_Utxorpc(t *testing.T) { // Run Utxorpc conversion actual, err := txBody.Utxorpc() if err != nil { - t.Fatalf("Could not convert transaction body to utxorpc format: %v", err) + t.Fatalf( + "Could not convert transaction body to utxorpc format: %v", + err, + ) } // Check that the fee matches diff --git a/ledger/alonzo/alonzo_test.go b/ledger/alonzo/alonzo_test.go index a3d6d8b7..5b498d84 100644 --- a/ledger/alonzo/alonzo_test.go +++ b/ledger/alonzo/alonzo_test.go @@ -284,12 +284,17 @@ func TestAlonzoTransactionOutputString(t *testing.T) { addr, _ := common.NewAddress(addrStr) ma := common.NewMultiAsset[common.MultiAssetTypeOutput]( map[common.Blake2b224]map[cbor.ByteString]uint64{ - common.NewBlake2b224(make([]byte, 28)): {cbor.NewByteString([]byte("t")): 2}, + common.NewBlake2b224(make([]byte, 28)): { + cbor.NewByteString([]byte("t")): 2, + }, }, ) out := AlonzoTransactionOutput{ OutputAddress: addr, - OutputAmount: mary.MaryTransactionOutputValue{Amount: 456, Assets: &ma}, + OutputAmount: mary.MaryTransactionOutputValue{ + Amount: 456, + Assets: &ma, + }, } s := out.String() policyStr := common.NewBlake2b224(make([]byte, 28)).String() diff --git a/ledger/alonzo/pparams_test.go b/ledger/alonzo/pparams_test.go index 77d24b5c..e108caac 100644 --- a/ledger/alonzo/pparams_test.go +++ b/ledger/alonzo/pparams_test.go @@ -261,7 +261,8 @@ func TestScientificNotationInCostModels(t *testing.T) { } expected := []int64{2477736, 1500000, 1000000} - if params.CostModels == nil || params.CostModels[alonzo.PlutusV1Key] == nil { + if params.CostModels == nil || + params.CostModels[alonzo.PlutusV1Key] == nil { t.Fatal("CostModels not properly initialized") } for i := range 3 { @@ -520,7 +521,10 @@ func TestAlonzoTransactionBody_Utxorpc(t *testing.T) { // Run Utxorpc conversion got, err := body.Utxorpc() if err != nil { - t.Fatalf("Could not convert transaction body to utxorpc format: %v", err) + t.Fatalf( + "Could not convert transaction body to utxorpc format: %v", + err, + ) } // Assertion checks diff --git a/ledger/babbage/babbage_test.go b/ledger/babbage/babbage_test.go index c6bd7c63..3523eb7c 100644 --- a/ledger/babbage/babbage_test.go +++ b/ledger/babbage/babbage_test.go @@ -2976,12 +2976,17 @@ func TestBabbageTransactionOutputString(t *testing.T) { addr, _ := common.NewAddress(addrStr) ma := common.NewMultiAsset[common.MultiAssetTypeOutput]( map[common.Blake2b224]map[cbor.ByteString]uint64{ - common.NewBlake2b224(make([]byte, 28)): {cbor.NewByteString([]byte("x")): 2}, + common.NewBlake2b224(make([]byte, 28)): { + cbor.NewByteString([]byte("x")): 2, + }, }, ) out := BabbageTransactionOutput{ OutputAddress: addr, - OutputAmount: mary.MaryTransactionOutputValue{Amount: 456, Assets: &ma}, + OutputAmount: mary.MaryTransactionOutputValue{ + Amount: 456, + Assets: &ma, + }, } s := out.String() expected := "(BabbageTransactionOutput address=" + addrStr + " amount=456 assets=" + ma.String() + ")" diff --git a/ledger/babbage/pparams_test.go b/ledger/babbage/pparams_test.go index a8addc91..97b5f235 100644 --- a/ledger/babbage/pparams_test.go +++ b/ledger/babbage/pparams_test.go @@ -637,7 +637,10 @@ func TestBabbageTransactionBody_Utxorpc(t *testing.T) { got, err := body.Utxorpc() if err != nil { - t.Fatalf("Could not convert transaction body to utxorpc format: %v", err) + t.Fatalf( + "Could not convert transaction body to utxorpc format: %v", + err, + ) } if got.Fee != 100 { t.Errorf("Fee mismatch: got %d, want 100", got.Fee) diff --git a/ledger/common/address.go b/ledger/common/address.go index a6a5dd16..67e03e29 100644 --- a/ledger/common/address.go +++ b/ledger/common/address.go @@ -228,7 +228,10 @@ func (a *Address) populateFromBytes(data []byte) error { // Payment payload payload := data[1:] switch a.addressType { - case AddressTypeKeyKey, AddressTypeKeyScript, AddressTypeKeyPointer, AddressTypeKeyNone: + case AddressTypeKeyKey, + AddressTypeKeyScript, + AddressTypeKeyPointer, + AddressTypeKeyNone: if len(payload) < AddressHashSize { return errors.New("invalid payment payload: key hash too small") } @@ -236,7 +239,10 @@ func (a *Address) populateFromBytes(data []byte) error { Hash: AddrKeyHash(payload[0:AddressHashSize]), } payload = payload[AddressHashSize:] - case AddressTypeScriptKey, AddressTypeScriptScript, AddressTypeScriptPointer, AddressTypeScriptNone: + case AddressTypeScriptKey, + AddressTypeScriptScript, + AddressTypeScriptPointer, + AddressTypeScriptNone: if len(payload) < AddressHashSize { return errors.New("invalid payment payload: script hash too small") } diff --git a/ledger/common/common.go b/ledger/common/common.go index 716d6dcb..15a9a9b8 100644 --- a/ledger/common/common.go +++ b/ledger/common/common.go @@ -338,7 +338,10 @@ func (m *MultiAsset[T]) String() string { } policies := slices.Collect(maps.Keys(norm)) - slices.SortFunc(policies, func(a, b Blake2b224) int { return bytes.Compare(a.Bytes(), b.Bytes()) }) + slices.SortFunc( + policies, + func(a, b Blake2b224) int { return bytes.Compare(a.Bytes(), b.Bytes()) }, + ) var b strings.Builder b.WriteByte('[') @@ -346,7 +349,10 @@ func (m *MultiAsset[T]) String() string { for _, pid := range policies { assets := norm[pid] names := slices.Collect(maps.Keys(assets)) - slices.SortFunc(names, func(a, b cbor.ByteString) int { return bytes.Compare(a.Bytes(), b.Bytes()) }) + slices.SortFunc( + names, + func(a, b cbor.ByteString) int { return bytes.Compare(a.Bytes(), b.Bytes()) }, + ) for _, name := range names { if !first { diff --git a/ledger/common/script/context.go b/ledger/common/script/context.go index f7b3bd00..1328acd9 100644 --- a/ledger/common/script/context.go +++ b/ledger/common/script/context.go @@ -458,7 +458,11 @@ func votingInfo( ) KeyValuePairs[*lcommon.Voter, KeyValuePairs[*lcommon.GovActionId, lcommon.VotingProcedure]] { var ret KeyValuePairs[*lcommon.Voter, KeyValuePairs[*lcommon.GovActionId, lcommon.VotingProcedure]] for voter, voterData := range votingProcedures { - voterPairs := make(KeyValuePairs[*lcommon.GovActionId, lcommon.VotingProcedure], 0, len(votingProcedures)) + voterPairs := make( + KeyValuePairs[*lcommon.GovActionId, lcommon.VotingProcedure], + 0, + len(votingProcedures), + ) for govActionId, votingProcedure := range voterData { voterPairs = append( voterPairs, @@ -473,7 +477,10 @@ func votingInfo( voterPairs, func(a, b KeyValuePair[*lcommon.GovActionId, lcommon.VotingProcedure]) int { // Compare TX ID - x := bytes.Compare(a.Key.TransactionId[:], b.Key.TransactionId[:]) + x := bytes.Compare( + a.Key.TransactionId[:], + b.Key.TransactionId[:], + ) if x != 0 { return x } diff --git a/ledger/conway/conway_test.go b/ledger/conway/conway_test.go index 6e68120d..3be839fc 100644 --- a/ledger/conway/conway_test.go +++ b/ledger/conway/conway_test.go @@ -145,7 +145,11 @@ func TestConwayTx_CborRoundTrip_UsingCborEncode(t *testing.T) { } if !bytes.Equal(orig, enc) { - t.Errorf("CBOR round-trip mismatch\noriginal: %x\nencoded : %x", orig, enc) + t.Errorf( + "CBOR round-trip mismatch\noriginal: %x\nencoded : %x", + orig, + enc, + ) i := -1 for j := 0; j < len(orig) && j < len(enc); j++ { @@ -155,7 +159,12 @@ func TestConwayTx_CborRoundTrip_UsingCborEncode(t *testing.T) { } } if i != -1 { - t.Logf("first diff at byte %d: orig=0x%02x enc=0x%02x", i, orig[i], enc[i]) + t.Logf( + "first diff at byte %d: orig=0x%02x enc=0x%02x", + i, + orig[i], + enc[i], + ) } else { t.Logf("length mismatch: orig=%d enc=%d", len(orig), len(enc)) } @@ -181,7 +190,11 @@ func TestConwayTx_Utxorpc(t *testing.T) { expHash := tx.Id().Bytes() if !bytes.Equal(utxoTx.Hash, expHash) { - t.Errorf("tx hash mismatch\nexpected: %x\nactual : %x", expHash, utxoTx.Hash) + t.Errorf( + "tx hash mismatch\nexpected: %x\nactual : %x", + expHash, + utxoTx.Hash, + ) } if got, want := len(utxoTx.Inputs), len(tx.Inputs()); got != want { diff --git a/ledger/conway/pparams.go b/ledger/conway/pparams.go index 0e46b37e..2699f790 100644 --- a/ledger/conway/pparams.go +++ b/ledger/conway/pparams.go @@ -407,13 +407,23 @@ func (u ConwayProtocolParameterUpdate) ToPlutusData() data.PlutusData { push(1, data.NewInteger(new(big.Int).SetUint64(uint64(*u.MinFeeB)))) } if u.MaxBlockBodySize != nil { - push(2, data.NewInteger(new(big.Int).SetUint64(uint64(*u.MaxBlockBodySize)))) + push( + 2, + data.NewInteger( + new(big.Int).SetUint64(uint64(*u.MaxBlockBodySize)), + ), + ) } if u.MaxTxSize != nil { push(3, data.NewInteger(new(big.Int).SetUint64(uint64(*u.MaxTxSize)))) } if u.MaxBlockHeaderSize != nil { - push(4, data.NewInteger(new(big.Int).SetUint64(uint64(*u.MaxBlockHeaderSize)))) + push( + 4, + data.NewInteger( + new(big.Int).SetUint64(uint64(*u.MaxBlockHeaderSize)), + ), + ) } if u.KeyDeposit != nil { push(5, data.NewInteger(new(big.Int).SetUint64(uint64(*u.KeyDeposit)))) @@ -452,10 +462,16 @@ func (u ConwayProtocolParameterUpdate) ToPlutusData() data.PlutusData { ) } if u.MinPoolCost != nil { - push(16, data.NewInteger(new(big.Int).SetUint64(uint64(*u.MinPoolCost)))) + push( + 16, + data.NewInteger(new(big.Int).SetUint64(uint64(*u.MinPoolCost))), + ) } if u.AdaPerUtxoByte != nil { - push(17, data.NewInteger(new(big.Int).SetUint64(uint64(*u.AdaPerUtxoByte)))) + push( + 17, + data.NewInteger(new(big.Int).SetUint64(uint64(*u.AdaPerUtxoByte))), + ) } // TODO: CostModels if u.ExecutionCosts != nil { @@ -489,13 +505,26 @@ func (u ConwayProtocolParameterUpdate) ToPlutusData() data.PlutusData { ) } if u.MaxValueSize != nil { - push(22, data.NewInteger(new(big.Int).SetUint64(uint64(*u.MaxValueSize)))) + push( + 22, + data.NewInteger(new(big.Int).SetUint64(uint64(*u.MaxValueSize))), + ) } if u.CollateralPercentage != nil { - push(23, data.NewInteger(new(big.Int).SetUint64(uint64(*u.CollateralPercentage)))) + push( + 23, + data.NewInteger( + new(big.Int).SetUint64(uint64(*u.CollateralPercentage)), + ), + ) } if u.MaxCollateralInputs != nil { - push(24, data.NewInteger(new(big.Int).SetUint64(uint64(*u.MaxCollateralInputs)))) + push( + 24, + data.NewInteger( + new(big.Int).SetUint64(uint64(*u.MaxCollateralInputs)), + ), + ) } if u.PoolVotingThresholds != nil { push(25, u.PoolVotingThresholds.ToPlutusData()) @@ -504,13 +533,21 @@ func (u ConwayProtocolParameterUpdate) ToPlutusData() data.PlutusData { push(26, u.DRepVotingThresholds.ToPlutusData()) } if u.MinCommitteeSize != nil { - push(27, data.NewInteger(new(big.Int).SetUint64(uint64(*u.MinCommitteeSize)))) + push( + 27, + data.NewInteger( + new(big.Int).SetUint64(uint64(*u.MinCommitteeSize)), + ), + ) } if u.CommitteeTermLimit != nil { push(28, data.NewInteger(new(big.Int).SetUint64(*u.CommitteeTermLimit))) } if u.GovActionValidityPeriod != nil { - push(29, data.NewInteger(new(big.Int).SetUint64(*u.GovActionValidityPeriod))) + push( + 29, + data.NewInteger(new(big.Int).SetUint64(*u.GovActionValidityPeriod)), + ) } if u.GovActionDeposit != nil { push(30, data.NewInteger(new(big.Int).SetUint64(*u.GovActionDeposit))) @@ -519,7 +556,10 @@ func (u ConwayProtocolParameterUpdate) ToPlutusData() data.PlutusData { push(31, data.NewInteger(new(big.Int).SetUint64(*u.DRepDeposit))) } if u.DRepInactivityPeriod != nil { - push(32, data.NewInteger(new(big.Int).SetUint64(*u.DRepInactivityPeriod))) + push( + 32, + data.NewInteger(new(big.Int).SetUint64(*u.DRepInactivityPeriod)), + ) } if u.MinFeeRefScriptCostPerByte != nil { push(33, diff --git a/ledger/conway/pparams_test.go b/ledger/conway/pparams_test.go index 86b18cd6..5012f30f 100644 --- a/ledger/conway/pparams_test.go +++ b/ledger/conway/pparams_test.go @@ -656,7 +656,10 @@ func TestConwayTransactionBody_Utxorpc(t *testing.T) { got, err := body.Utxorpc() if err != nil { - t.Fatalf("Could not convert the transaction body to utxorpc format %v", err) + t.Fatalf( + "Could not convert the transaction body to utxorpc format %v", + err, + ) } if got.Fee != 1000 { diff --git a/ledger/mary/mary_test.go b/ledger/mary/mary_test.go index ef4ad79c..04d216d9 100644 --- a/ledger/mary/mary_test.go +++ b/ledger/mary/mary_test.go @@ -122,7 +122,9 @@ func TestMaryTransactionOutputString(t *testing.T) { addr, _ := common.NewAddress(addrStr) ma := common.NewMultiAsset[common.MultiAssetTypeOutput]( map[common.Blake2b224]map[cbor.ByteString]uint64{ - common.NewBlake2b224(make([]byte, 28)): {cbor.NewByteString([]byte("token")): 2}, + common.NewBlake2b224(make([]byte, 28)): { + cbor.NewByteString([]byte("token")): 2, + }, }, ) out := MaryTransactionOutput{ @@ -130,7 +132,11 @@ func TestMaryTransactionOutputString(t *testing.T) { OutputAmount: MaryTransactionOutputValue{Amount: 456, Assets: &ma}, } s := out.String() - expected := fmt.Sprintf("(MaryTransactionOutput address=%s amount=456 assets=%s)", addrStr, ma.String()) + expected := fmt.Sprintf( + "(MaryTransactionOutput address=%s amount=456 assets=%s)", + addrStr, + ma.String(), + ) if s != expected { t.Fatalf("unexpected string: %s", s) } @@ -143,8 +149,13 @@ func TestMaryOutputTooBigErrorFormatting(t *testing.T) { OutputAddress: addr, OutputAmount: MaryTransactionOutputValue{Amount: 456}, } - errStr := OutputTooBigUtxoError{Outputs: []common.TransactionOutput{out}}.Error() - expected := fmt.Sprintf("output value too large: (MaryTransactionOutput address=%s amount=456)", addrStr) + errStr := OutputTooBigUtxoError{ + Outputs: []common.TransactionOutput{out}, + }.Error() + expected := fmt.Sprintf( + "output value too large: (MaryTransactionOutput address=%s amount=456)", + addrStr, + ) if errStr != expected { t.Fatalf("unexpected error: %s", errStr) } diff --git a/ledger/mary/pparams_test.go b/ledger/mary/pparams_test.go index 50c596eb..8feeb955 100644 --- a/ledger/mary/pparams_test.go +++ b/ledger/mary/pparams_test.go @@ -214,7 +214,10 @@ func TestMaryTransactionBody_Utxorpc(t *testing.T) { got, err := body.Utxorpc() if err != nil { - t.Fatalf("Could not convert the transaction body to utxorpc format %v", err) + t.Fatalf( + "Could not convert the transaction body to utxorpc format %v", + err, + ) } if got.Fee != 100 { diff --git a/ledger/shelley/pparams_test.go b/ledger/shelley/pparams_test.go index 3e259475..dba149e1 100644 --- a/ledger/shelley/pparams_test.go +++ b/ledger/shelley/pparams_test.go @@ -271,7 +271,10 @@ func TestShelleyTransactionBody_Utxorpc(t *testing.T) { // Convert the transaction body to utxorpc format actual, err := txBody.Utxorpc() if err != nil { - t.Fatalf("Could not convert the transaction body to utxorpc format %v", err) + t.Fatalf( + "Could not convert the transaction body to utxorpc format %v", + err, + ) } // Check that the fee matches diff --git a/ledger/shelley/shelley_test.go b/ledger/shelley/shelley_test.go index dbc2ba67..49941fe9 100644 --- a/ledger/shelley/shelley_test.go +++ b/ledger/shelley/shelley_test.go @@ -16,7 +16,10 @@ func TestShelleyTransactionOutputString(t *testing.T) { OutputAmount: 456, } s := out.String() - expected := fmt.Sprintf("(ShelleyTransactionOutput address=%s amount=456)", addrStr) + expected := fmt.Sprintf( + "(ShelleyTransactionOutput address=%s amount=456)", + addrStr, + ) if s != expected { t.Fatalf("unexpected string: %s", s) } @@ -29,8 +32,13 @@ func TestShelleyOutputTooSmallErrorFormatting(t *testing.T) { OutputAddress: addr, OutputAmount: 456, } - errStr := shelley.OutputTooSmallUtxoError{Outputs: []common.TransactionOutput{out}}.Error() - expected := fmt.Sprintf("output too small: (ShelleyTransactionOutput address=%s amount=456)", addrStr) + errStr := shelley.OutputTooSmallUtxoError{ + Outputs: []common.TransactionOutput{out}, + }.Error() + expected := fmt.Sprintf( + "output too small: (ShelleyTransactionOutput address=%s amount=456)", + addrStr, + ) if errStr != expected { t.Fatalf("unexpected error: %s", errStr) } diff --git a/protocol/leiosnotify/leiosnotify.go b/protocol/leiosnotify/leiosnotify.go index 93ebe063..592cab99 100644 --- a/protocol/leiosnotify/leiosnotify.go +++ b/protocol/leiosnotify/leiosnotify.go @@ -115,7 +115,9 @@ func NewConfig(options ...LeiosNotifyOptionFunc) Config { return c } -func WithRequestNextFunc(requestNextFunc RequestNextFunc) LeiosNotifyOptionFunc { +func WithRequestNextFunc( + requestNextFunc RequestNextFunc, +) LeiosNotifyOptionFunc { return func(c *Config) { c.RequestNextFunc = requestNextFunc } diff --git a/protocol/leiosnotify/messages.go b/protocol/leiosnotify/messages.go index 19a31dfd..95a75305 100644 --- a/protocol/leiosnotify/messages.go +++ b/protocol/leiosnotify/messages.go @@ -75,7 +75,9 @@ type MsgBlockAnnouncement struct { BlockHeaderRaw cbor.RawMessage } -func NewMsgBlockAnnouncement(blockHeader cbor.RawMessage) *MsgBlockAnnouncement { +func NewMsgBlockAnnouncement( + blockHeader cbor.RawMessage, +) *MsgBlockAnnouncement { m := &MsgBlockAnnouncement{ MessageBase: protocol.MessageBase{ MessageType: MessageTypeBlockAnnouncement,