Commit 5f5ea434 authored by Christopher Ferris's avatar Christopher Ferris Committed by Gerrit Code Review
Browse files

Merge "[FAB-10090] Increase UT coverage ledger/pvtdatapolicy"

parents 316c196e b1e029b5
......@@ -7,6 +7,7 @@ SPDX-License-Identifier: Apache-2.0
package pvtdatapolicy
import (
"math"
"testing"
"github.com/hyperledger/fabric/core/common/privdata"
......@@ -37,3 +38,27 @@ func TestBTLPolicy(t *testing.T) {
_, ok := err.(privdata.NoSuchCollectionError)
assert.True(t, ok)
}
func TestExpiringBlock(t *testing.T) {
mockCollectionStore := testutil.NewMockCollectionStore()
mockCollectionStore.SetBTL("ns1", "coll1", 100)
mockCollectionStore.SetBTL("ns1", "coll2", 200)
mockCollectionStore.SetBTL("ns1", "coll3", 0)
btlPolicy := ConstructBTLPolicy(mockCollectionStore)
expiringBlk, err := btlPolicy.GetExpiringBlock("ns1", "coll1", 50)
assert.NoError(t, err)
assert.Equal(t, uint64(151), expiringBlk)
expiringBlk, err = btlPolicy.GetExpiringBlock("ns1", "coll2", 50)
assert.NoError(t, err)
assert.Equal(t, uint64(251), expiringBlk)
expiringBlk, err = btlPolicy.GetExpiringBlock("ns1", "coll3", 50)
assert.NoError(t, err)
assert.Equal(t, uint64(math.MaxUint64), expiringBlk)
expiringBlk, err = btlPolicy.GetExpiringBlock("ns1", "coll4", 50)
_, ok := err.(privdata.NoSuchCollectionError)
assert.True(t, ok)
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment