github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/storage/badger/operation/qcs_test.go (about)

     1  package operation
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/dgraph-io/badger/v2"
     7  	"github.com/stretchr/testify/assert"
     8  	"github.com/stretchr/testify/require"
     9  
    10  	"github.com/onflow/flow-go/model/flow"
    11  	"github.com/onflow/flow-go/utils/unittest"
    12  )
    13  
    14  func TestInsertQuorumCertificate(t *testing.T) {
    15  	unittest.RunWithBadgerDB(t, func(db *badger.DB) {
    16  		expected := unittest.QuorumCertificateFixture()
    17  
    18  		err := db.Update(InsertQuorumCertificate(expected))
    19  		require.Nil(t, err)
    20  
    21  		var actual flow.QuorumCertificate
    22  		err = db.View(RetrieveQuorumCertificate(expected.BlockID, &actual))
    23  		require.Nil(t, err)
    24  
    25  		assert.Equal(t, expected, &actual)
    26  	})
    27  }