diff --git a/ledger/byron/genesis_test.go b/ledger/byron/genesis_test.go index 5fadadf9..3d2fc1d9 100644 --- a/ledger/byron/genesis_test.go +++ b/ledger/byron/genesis_test.go @@ -282,13 +282,25 @@ func TestGenesisNonAvvmUtxos(t *testing.T) { } tmpUtxo := tmpGenesisUtxos[0] if tmpUtxo.Id.Id().String() != expectedTxId { - t.Fatalf("did not get expected TxID: got %s, wanted %s", tmpUtxo.Id.Id().String(), expectedTxId) + t.Fatalf( + "did not get expected TxID: got %s, wanted %s", + tmpUtxo.Id.Id().String(), + expectedTxId, + ) } if tmpUtxo.Output.Address().String() != testAddr { - t.Fatalf("did not get expected address: got %s, wanted %s", tmpUtxo.Output.Address().String(), testAddr) + t.Fatalf( + "did not get expected address: got %s, wanted %s", + tmpUtxo.Output.Address().String(), + testAddr, + ) } if tmpUtxo.Output.Amount() != testAmount { - t.Fatalf("did not get expected amount: got %d, wanted %d", tmpUtxo.Output.Amount(), testAmount) + t.Fatalf( + "did not get expected amount: got %d, wanted %d", + tmpUtxo.Output.Amount(), + testAmount, + ) } } @@ -323,12 +335,24 @@ func TestGenesisAvvmUtxos(t *testing.T) { } tmpUtxo := tmpGenesisUtxos[0] if tmpUtxo.Id.Id().String() != expectedTxId { - t.Fatalf("did not get expected TxID: got %s, wanted %s", tmpUtxo.Id.Id().String(), expectedTxId) + t.Fatalf( + "did not get expected TxID: got %s, wanted %s", + tmpUtxo.Id.Id().String(), + expectedTxId, + ) } if tmpUtxo.Output.Address().String() != expectedAddr { - t.Fatalf("did not get expected address: got %s, wanted %s", tmpUtxo.Output.Address().String(), expectedAddr) + t.Fatalf( + "did not get expected address: got %s, wanted %s", + tmpUtxo.Output.Address().String(), + expectedAddr, + ) } if tmpUtxo.Output.Amount() != testAmount { - t.Fatalf("did not get expected amount: got %d, wanted %d", tmpUtxo.Output.Amount(), testAmount) + t.Fatalf( + "did not get expected amount: got %d, wanted %d", + tmpUtxo.Output.Amount(), + testAmount, + ) } } diff --git a/ledger/common/address.go b/ledger/common/address.go index aedacb14..61e9e57e 100644 --- a/ledger/common/address.go +++ b/ledger/common/address.go @@ -181,18 +181,24 @@ func (a *Address) populateFromBytes(data []byte) error { } payloadBytes, ok := rawAddr.Payload.Content.([]byte) if !ok || rawAddr.Payload.Number != 24 { - return fmt.Errorf("invalid Byron address data: unexpected payload content") + return fmt.Errorf( + "invalid Byron address data: unexpected payload content", + ) } payloadChecksum := crc32.ChecksumIEEE(payloadBytes) if rawAddr.Checksum != payloadChecksum { - return fmt.Errorf("invalid Byron address data: checksum does not match") + return fmt.Errorf( + "invalid Byron address data: checksum does not match", + ) } var byronAddr byronAddressPayload if _, err := cbor.Decode(payloadBytes, &byronAddr); err != nil { return err } if len(byronAddr.Hash) != AddressHashSize { - return fmt.Errorf("invalid Byron address data: hash is not expected length") + return fmt.Errorf( + "invalid Byron address data: hash is not expected length", + ) } a.byronAddressType = byronAddr.AddrType a.byronAddressAttr = byronAddr.Attr diff --git a/ledger/common/nonce.go b/ledger/common/nonce.go index 1efc721d..c8e6ed59 100644 --- a/ledger/common/nonce.go +++ b/ledger/common/nonce.go @@ -85,9 +85,15 @@ func (n *Nonce) MarshalCBOR() ([]byte, error) { // CalculateRollingNonce calculates a rolling nonce (eta_v) value from the previous block's eta_v value and the current // block's VRF result -func CalculateRollingNonce(prevBlockNonce []byte, blockVrf []byte) (Blake2b256, error) { +func CalculateRollingNonce( + prevBlockNonce []byte, + blockVrf []byte, +) (Blake2b256, error) { if len(blockVrf) != 32 && len(blockVrf) != 64 { - return Blake2b256{}, fmt.Errorf("invalid block VRF length: %d, expected 32 or 64", len(blockVrf)) + return Blake2b256{}, fmt.Errorf( + "invalid block VRF length: %d, expected 32 or 64", + len(blockVrf), + ) } blockVrfHash := Blake2b256Hash(blockVrf) tmpData := slices.Concat(prevBlockNonce, blockVrfHash.Bytes()) @@ -96,7 +102,11 @@ func CalculateRollingNonce(prevBlockNonce []byte, blockVrf []byte) (Blake2b256, // CalculateEpochNonce calculates an epoch nonce from the rolling nonce (eta_v) value of the block immediately before the stability // window and the block hash of the first block from the previous epoch. -func CalculateEpochNonce(stableBlockNonce []byte, prevEpochFirstBlockHash []byte, extraEntropy []byte) (Blake2b256, error) { +func CalculateEpochNonce( + stableBlockNonce []byte, + prevEpochFirstBlockHash []byte, + extraEntropy []byte, +) (Blake2b256, error) { tmpData := slices.Concat( stableBlockNonce, prevEpochFirstBlockHash, diff --git a/ledger/common/nonce_test.go b/ledger/common/nonce_test.go index 60e6337f..ae4ce7af 100644 --- a/ledger/common/nonce_test.go +++ b/ledger/common/nonce_test.go @@ -146,7 +146,11 @@ func TestCalculateRollingNonce(t *testing.T) { } nonceHex := hex.EncodeToString(nonce.Bytes()) if nonceHex != testDef.expectedNonce { - t.Fatalf("did not get expected nonce value: got %s, wanted %s", nonceHex, testDef.expectedNonce) + t.Fatalf( + "did not get expected nonce value: got %s, wanted %s", + nonceHex, + testDef.expectedNonce, + ) } rollingNonce = nonce.Bytes() } @@ -176,7 +180,9 @@ func TestCalculateEpochNonce(t *testing.T) { if err != nil { t.Fatalf("unexpected error: %s", err) } - prevEpochFirstBlockHash, err := hex.DecodeString(testDef.prevEpochFirstBlockHash) + prevEpochFirstBlockHash, err := hex.DecodeString( + testDef.prevEpochFirstBlockHash, + ) if err != nil { t.Fatalf("unexpected error: %s", err) } @@ -188,13 +194,21 @@ func TestCalculateEpochNonce(t *testing.T) { } extraEntropy = tmpEntropy } - tmpNonce, err := common.CalculateEpochNonce(stableBlockNonce, prevEpochFirstBlockHash, extraEntropy) + tmpNonce, err := common.CalculateEpochNonce( + stableBlockNonce, + prevEpochFirstBlockHash, + extraEntropy, + ) if err != nil { t.Fatalf("unexpected error: %s", err) } tmpNonceHex := hex.EncodeToString(tmpNonce.Bytes()) if tmpNonceHex != testDef.expectedNonce { - t.Fatalf("did not get expected epoch nonce: got %s, wanted %s", tmpNonceHex, testDef.expectedNonce) + t.Fatalf( + "did not get expected epoch nonce: got %s, wanted %s", + tmpNonceHex, + testDef.expectedNonce, + ) } } } diff --git a/protocol/chainsync/chainsync.go b/protocol/chainsync/chainsync.go index 7f375ae5..dbbbb0cf 100644 --- a/protocol/chainsync/chainsync.go +++ b/protocol/chainsync/chainsync.go @@ -272,7 +272,9 @@ func WithRollForwardFunc(rollForwardFunc RollForwardFunc) ChainSyncOptionFunc { } // WithRollForwardRawFunc specifies the RollForwardRaw callback function. This will provide the raw header or block -func WithRollForwardRawFunc(rollForwardRawFunc RollForwardRawFunc) ChainSyncOptionFunc { +func WithRollForwardRawFunc( + rollForwardRawFunc RollForwardRawFunc, +) ChainSyncOptionFunc { return func(c *Config) { c.RollForwardRawFunc = rollForwardRawFunc } diff --git a/protocol/localstatequery/error.go b/protocol/localstatequery/error.go index 4c5b3fe4..96333ec0 100644 --- a/protocol/localstatequery/error.go +++ b/protocol/localstatequery/error.go @@ -20,4 +20,6 @@ import "errors" var ErrAcquireFailurePointTooOld = errors.New("acquire failure: point too old") // ErrAcquireFailurePointNotOnChain indicates a failure to acquire a point due to it not being present on the chain -var ErrAcquireFailurePointNotOnChain = errors.New("acquire failure: point not on chain") +var ErrAcquireFailurePointNotOnChain = errors.New( + "acquire failure: point not on chain", +) diff --git a/protocol/localstatequery/queries.go b/protocol/localstatequery/queries.go index b62426b7..36eb40cb 100644 --- a/protocol/localstatequery/queries.go +++ b/protocol/localstatequery/queries.go @@ -335,7 +335,11 @@ type ShelleyPoolDistrQuery struct { simpleQueryBase } -func decodeQuery(data []byte, typeDesc string, queryTypes map[int]any) (any, error) { +func decodeQuery( + data []byte, + typeDesc string, + queryTypes map[int]any, +) (any, error) { // Determine query type queryType, err := cbor.DecodeIdFromList(data) if err != nil {