Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend unit tests for Badger storage #166

Merged
merged 31 commits into from
Dec 15, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
989b428
Add initial tests for blocks, transactions and seals
danukumanan Nov 18, 2020
5ea4a2c
Add more tests
danukumanan Nov 19, 2020
1f2eae5
Add more test cases
danukumanan Nov 23, 2020
509e4e1
Merge branch 'master' into danu/5045-unittest-badger-storage
danukumanan Nov 23, 2020
9f3aad7
Separated tests (#169)
Nov 25, 2020
a4bc5cb
Merge branch 'master' into danu/5045-unittest-badger-storage
danukumanan Nov 25, 2020
f1d2323
Merge branch 'master' into danu/5045-unittest-badger-storage
danukumanan Dec 3, 2020
c0fca0f
Fix linting
danukumanan Dec 3, 2020
4f7ca2f
Add more tests
danukumanan Dec 3, 2020
48e42d7
Merge branch 'master' into danu/5045-unittest-badger-storage
danukumanan Dec 4, 2020
090fa14
Add more tests
danukumanan Dec 7, 2020
2856cc6
branch 'danu/5045-unittest-badger-storage' of github.com:onflow/flow…
danukumanan Dec 7, 2020
a30580a
Merge branch 'master' of github.com:onflow/flow-go into danu/5045-uni…
danukumanan Dec 7, 2020
ffbbefe
Fix lintin
danukumanan Dec 7, 2020
5a9a6e5
Update storage/badger/commit_test.go
danukumanan Dec 7, 2020
4efcd6b
Merge branch 'master' into danu/5045-unittest-badger-storage
danukumanan Dec 8, 2020
2202cd2
Add more test case checks
danukumanan Dec 8, 2020
0e0a03d
Merge branch 'danu/5045-unittest-badger-storage' of github.com:onflow…
danukumanan Dec 8, 2020
84d15e6
Fix tests and add more
danukumanan Dec 8, 2020
8ae8d8e
Add comment
danukumanan Dec 8, 2020
8cde63c
Add guarantee tests
danukumanan Dec 10, 2020
a133ffa
Add rest of fixtures and add tests
danukumanan Dec 10, 2020
a03da10
Merge branch 'master' of github.com:onflow/flow-go into danu/5045-uni…
danukumanan Dec 10, 2020
fd1273e
Change error check to use storage.ErrAlreadyExists
danukumanan Dec 11, 2020
803beae
Merge branch 'master' into danu/5045-unittest-badger-storage
danukumanan Dec 11, 2020
f92d4a4
Update storage/badger/seals_test.go
danukumanan Dec 14, 2020
e077168
Update storage/badger/headers_test.go
danukumanan Dec 14, 2020
5f87566
Update storage/badger/headers_test.go
danukumanan Dec 14, 2020
31167d9
Update storage/badger/cluster_payloads.go
danukumanan Dec 14, 2020
21a47ef
Fix Linting errors
danukumanan Dec 14, 2020
7d8bcef
Merge branch 'master' of github.com:onflow/flow-go into danu/5045-uni…
danukumanan Dec 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions storage/badger/cluster_payloads.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ func (cp *ClusterPayloads) storeTx(blockID flow.Identifier, payload *cluster.Pay
func (cp *ClusterPayloads) retrieveTx(blockID flow.Identifier) func(*badger.Txn) (*cluster.Payload, error) {
return func(tx *badger.Txn) (*cluster.Payload, error) {
val, err := cp.cache.Get(blockID)(tx)
if err != nil {
return nil, err
}
danukumanan marked this conversation as resolved.
Show resolved Hide resolved
return val.(*cluster.Payload), err
danukumanan marked this conversation as resolved.
Show resolved Hide resolved
}
}
Expand Down
1 change: 0 additions & 1 deletion storage/badger/cluster_payloads_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func TestClusterPayloadRetrieveWithoutStore(t *testing.T) {

blockID := unittest.IdentifierFixture()

// storing again should error with key already exists
_, err := store.ByBlockID(blockID)
assert.True(t, errors.Is(err, storage.ErrNotFound))
})
Expand Down
24 changes: 13 additions & 11 deletions storage/badger/events_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package badger_test

import (
"errors"
"testing"

"github.com/dgraph-io/badger/v2"
"github.com/stretchr/testify/require"

"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/storage"
"github.com/onflow/flow-go/utils/unittest"

badgerstorage "github.com/onflow/flow-go/storage/badger"
Expand Down Expand Up @@ -52,18 +50,22 @@ func TestEventRetrieveWithoutStore(t *testing.T) {
store := badgerstorage.NewEvents(db)

blockID := unittest.IdentifierFixture()
// txID := unittest.IdentifierFixture()
txID := unittest.IdentifierFixture()

// retrieve by blockID
_, err := store.ByBlockID(blockID)
require.True(t, errors.Is(err, storage.ErrNotFound))
events, err := store.ByBlockID(blockID)
require.NoError(t, err)
require.True(t, len(events) == 0)

// // retrieve by blockID and event type
// _, err = store.ByBlockIDEventType(blockID, flow.EventAccountCreated)
// assert.True(t, errors.Is(err, storage.ErrNotFound))
// retrieve by blockID and event type
events, err = store.ByBlockIDEventType(blockID, flow.EventAccountCreated)
require.NoError(t, err)
require.True(t, len(events) == 0)

// retrieve by blockID and transaction id
events, err = store.ByBlockIDTransactionID(blockID, txID)
require.NoError(t, err)
require.True(t, len(events) == 0)
danukumanan marked this conversation as resolved.
Show resolved Hide resolved

// // retrieve by blockID and transaction id
// _, err = store.ByBlockIDTransactionID(blockID, txID)
// assert.True(t, errors.Is(err, storage.ErrNotFound))
})
}