From 634f315140bcc0fd16217ba4e8fbd7c53f2a3734 Mon Sep 17 00:00:00 2001 From: Diego Date: Thu, 10 Aug 2023 18:14:39 -0300 Subject: [PATCH] Fix deepsource checks --- dot/state/storage_notify_test.go | 12 +++++------- dot/state/storage_test.go | 4 ++-- dot/state/test_helpers.go | 3 ++- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/dot/state/storage_notify_test.go b/dot/state/storage_notify_test.go index 1f2f0da551..50e9c36236 100644 --- a/dot/state/storage_notify_test.go +++ b/dot/state/storage_notify_test.go @@ -175,20 +175,18 @@ func Test_Example(t *testing.T) { } if err := db.Subscribe(ctx, cb, match); err != nil && err != context.Canceled { - log.Fatal(err) + t.Error(err) } log.Printf("subscription closed") }() // Write both keys, but only one should be printed in the Output. err := db.Put(aKey, aValue) - if err != nil { - log.Fatal(err) - } + require.NoError(t, err) + err = db.Put(bKey, bValue) - if err != nil { - log.Fatal(err) - } + require.NoError(t, err) + log.Printf("stopping subscription") cancel() log.Printf("waiting for subscription to close") diff --git a/dot/state/storage_test.go b/dot/state/storage_test.go index fd0e597f0a..7d6da57e65 100644 --- a/dot/state/storage_test.go +++ b/dot/state/storage_test.go @@ -45,8 +45,8 @@ func TestStorage_StoreAndLoadTrie(t *testing.T) { trie, err := storage.LoadFromDB(root) require.NoError(t, err) ts2 := runtime.NewTrieState(trie) - new := ts2.Snapshot() - require.Equal(t, ts.Trie(), new) + newTrie := ts2.Snapshot() + require.Equal(t, ts.Trie(), newTrie) } func TestStorage_GetStorageByBlockHash(t *testing.T) { diff --git a/dot/state/test_helpers.go b/dot/state/test_helpers.go index 56255b3198..11818a5924 100644 --- a/dot/state/test_helpers.go +++ b/dot/state/test_helpers.go @@ -153,7 +153,7 @@ func AddBlocksToState(t *testing.T, blockState *BlockState, depth uint, // branches are provided with a map of depth -> # of branches func AddBlocksToStateWithFixedBranches(t *testing.T, blockState *BlockState, depth uint, branches map[uint]int) { bestBlockHash := blockState.BestBlockHash() - tb := []testBranch{} + var tb []testBranch arrivalTime := time.Now() rt, err := blockState.GetRuntime(bestBlockHash) @@ -235,6 +235,7 @@ func AddBlocksToStateWithFixedBranches(t *testing.T, blockState *BlockState, dep } } +//lint:ignore U1000 this has a real reason func generateBlockWithRandomTrie(t *testing.T, serv *Service, parent *common.Hash, bNum uint) (*types.Block, *runtime.TrieState) { trieState, err := serv.Storage.TrieState(nil)