Skip to content

Commit c93fbc0

Browse files
committed
ci: fix linter
1 parent fafe97e commit c93fbc0

6 files changed

Lines changed: 28 additions & 12 deletions

File tree

rpc/v8/block_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,9 @@ func TestBlockTransactionCount(t *testing.T) {
179179
t.Run("non-existent block hash", func(t *testing.T) {
180180
mockReader.EXPECT().BlockHeaderByHash(gomock.Any()).Return(nil, db.ErrKeyNotFound)
181181

182-
count, rpcErr := handler.BlockTransactionCount(blockIDHash(t, new(felt.Felt).SetBytes([]byte("random"))))
182+
count, rpcErr := handler.BlockTransactionCount(
183+
blockIDHash(t, new(felt.Felt).SetBytes([]byte("random"))),
184+
)
183185
assert.Equal(t, uint64(0), count)
184186
assert.Equal(t, rpccore.ErrBlockNotFound, rpcErr)
185187
})
@@ -472,7 +474,11 @@ func TestBlockWithTxs(t *testing.T) {
472474
require.NoError(t, err)
473475
latestBlockHash := latestBlock.Hash
474476

475-
checkLatestBlock := func(t *testing.T, blockWithTxHashes *rpc.BlockWithTxHashes, blockWithTxs *rpc.BlockWithTxs) {
477+
checkLatestBlock := func(
478+
t *testing.T,
479+
blockWithTxHashes *rpc.BlockWithTxHashes,
480+
blockWithTxs *rpc.BlockWithTxs,
481+
) {
476482
t.Helper()
477483
assert.Equal(t, blockWithTxHashes.BlockHeader, blockWithTxs.BlockHeader)
478484
assert.Equal(t, len(blockWithTxHashes.TxnHashes), len(blockWithTxs.Transactions))

rpc/v8/class.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ func (h *Handler) Class(id BlockID, classHash felt.Felt) (*Class, *jsonrpc.Error
111111
Program: c.Program,
112112
EntryPoints: EntryPoints{
113113
// Note that utils.Map returns nil if provided slice is nil
114-
// but this is not the case here, because we rely on sn2core adapters that will set it to empty slice
114+
// but this is not the case here, because we rely on sn2core adapters
115+
// that will set it to empty slice if it's nil. In the API spec these fields are required.
115116
// if it's nil. In the API spec these fields are required.
116117
Constructor: utils.Map(c.Constructors, adaptEntryPoint),
117118
External: utils.Map(c.Externals, adaptEntryPoint),
@@ -132,7 +133,8 @@ func (h *Handler) Class(id BlockID, classHash felt.Felt) (*Class, *jsonrpc.Error
132133
ContractClassVersion: c.SemanticVersion,
133134
EntryPoints: EntryPoints{
134135
// Note that utils.Map returns nil if provided slice is nil
135-
// but this is not the case here, because we rely on sn2core adapters that will set it to empty slice
136+
// but this is not the case here, because we rely on sn2core adapters
137+
// that will set it to empty slice if it's nil. In the API spec these fields are required.
136138
// if it's nil. In the API spec these fields are required.
137139
Constructor: utils.Map(c.EntryPoints.Constructor, adaptEntryPoint),
138140
External: utils.Map(c.EntryPoints.External, adaptEntryPoint),
@@ -146,7 +148,8 @@ func (h *Handler) Class(id BlockID, classHash felt.Felt) (*Class, *jsonrpc.Error
146148
return rpcClass, nil
147149
}
148150

149-
// ClassAt gets the contract class definition in the given block instantiated by the given contract address
151+
// ClassAt gets the contract class definition in the given block instantiated by
152+
// the given contract address
150153
//
151154
// It follows the specification defined here:
152155
// https://github.com/starkware-libs/starknet-specs/blob/v0.8.1/api/starknet_api_openrpc.json#L482
@@ -158,7 +161,8 @@ func (h *Handler) ClassAt(id BlockID, address felt.Felt) (*Class, *jsonrpc.Error
158161
return h.Class(id, *classHash)
159162
}
160163

161-
// ClassHashAt gets the class hash for the contract deployed at the given address in the given block.
164+
// ClassHashAt gets the class hash for the contract deployed at the given address
165+
// in the given block.
162166
//
163167
// It follows the specification defined here:
164168
// https://github.com/starkware-libs/starknet-specs/blob/v0.8.1/api/starknet_api_openrpc.json#L442

rpc/v8/state_update.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ func (h *Handler) StateUpdate(id BlockID) (*StateUpdate, *jsonrpc.Error) {
7575
update, err = h.bcReader.StateUpdateByNumber(height)
7676
}
7777
} else if id.IsPending() {
78+
//nolint:staticcheck // Necessary for v8
7879
var pending *core.Pending
7980
pending, err = h.Pending()
8081
if err == nil {

rpc/v8/sync_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ func TestSyncing(t *testing.T) {
5656
assert.Equal(t, &rpc.Sync{Syncing: &defaultSyncState}, syncing)
5757
})
5858

59-
synchronizer.EXPECT().HighestBlockHeader().Return(&core.Header{Number: 2, Hash: new(felt.Felt).SetUint64(2)}).Times(2)
59+
synchronizer.EXPECT().HighestBlockHeader().Return(
60+
&core.Header{Number: 2, Hash: new(felt.Felt).SetUint64(2)},
61+
).Times(2)
6062
t.Run("block height is equal to highest block", func(t *testing.T) {
6163
mockReader.EXPECT().BlockHeaderByNumber(startingBlock).Return(&core.Header{}, nil)
6264
mockReader.EXPECT().HeadsHeader().Return(&core.Header{Number: 2}, nil)
@@ -67,7 +69,10 @@ func TestSyncing(t *testing.T) {
6769
})
6870
t.Run("syncing", func(t *testing.T) {
6971
mockReader.EXPECT().BlockHeaderByNumber(startingBlock).Return(&core.Header{Hash: &felt.Zero}, nil)
70-
mockReader.EXPECT().HeadsHeader().Return(&core.Header{Number: 1, Hash: new(felt.Felt).SetUint64(1)}, nil)
72+
mockReader.EXPECT().HeadsHeader().Return(
73+
&core.Header{Number: 1, Hash: new(felt.Felt).SetUint64(1)},
74+
nil,
75+
)
7176

7277
currentBlockNumber := uint64(1)
7378
highestBlockNumber := uint64(2)

rpc/v8/trace.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ type FunctionInvocation struct {
4848
Calldata []felt.Felt `json:"calldata"`
4949
CallerAddress felt.Felt `json:"caller_address"`
5050
ClassHash *felt.Felt `json:"class_hash"`
51-
EntryPointType string `json:"entry_point_type"` // shouldnt we put it as enum here ?
52-
CallType string `json:"call_type"` // shouldnt we put it as enum here ?
51+
EntryPointType string `json:"entry_point_type"`
52+
CallType string `json:"call_type"`
5353
Result []felt.Felt `json:"result"`
5454
Calls []FunctionInvocation `json:"calls"`
5555
Events []OrderedEvent `json:"events"`

rpc/v8/trace_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ func TestAdaptVMTransactionTrace(t *testing.T) {
759759
},
760760
ConstructorInvocation: &vm.FunctionInvocation{},
761761
FunctionInvocation: &vm.ExecuteInvocation{},
762-
StateDiff: &vm.StateDiff{ //nolint:dupl
762+
StateDiff: &vm.StateDiff{ //nolint:dupl // Similar, but for different cases
763763
StorageDiffs: []vm.StorageDiff{
764764
{
765765
Address: felt.Zero,
@@ -843,7 +843,7 @@ func TestAdaptVMTransactionTrace(t *testing.T) {
843843
IsReverted: false,
844844
},
845845
},
846-
StateDiff: &rpc.StateDiff{ //nolint:dupl
846+
StateDiff: &rpc.StateDiff{ //nolint:dupl // Similar, but for different cases
847847
StorageDiffs: []rpc.StorageDiff{
848848
{
849849
Address: felt.Zero,

0 commit comments

Comments
 (0)