github.com/koko1123/flow-go-1@v0.29.6/storage/badger/operation/commits_test.go (about)

     1  package operation
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/dgraph-io/badger/v3"
     7  	"github.com/stretchr/testify/assert"
     8  	"github.com/stretchr/testify/require"
     9  
    10  	"github.com/koko1123/flow-go-1/model/flow"
    11  	"github.com/koko1123/flow-go-1/utils/unittest"
    12  )
    13  
    14  func TestStateCommitments(t *testing.T) {
    15  	unittest.RunWithBadgerDB(t, func(db *badger.DB) {
    16  		expected := unittest.StateCommitmentFixture()
    17  		id := unittest.IdentifierFixture()
    18  		err := db.Update(IndexStateCommitment(id, expected))
    19  		require.Nil(t, err)
    20  
    21  		var actual flow.StateCommitment
    22  		err = db.View(LookupStateCommitment(id, &actual))
    23  		require.Nil(t, err)
    24  		assert.Equal(t, expected, actual)
    25  	})
    26  }