diff --git a/common/ledger/blkstorage/blockfile_mgr_test.go b/common/ledger/blkstorage/blockfile_mgr_test.go index 9127e618c32..de74018fafe 100644 --- a/common/ledger/blkstorage/blockfile_mgr_test.go +++ b/common/ledger/blkstorage/blockfile_mgr_test.go @@ -28,8 +28,8 @@ func TestBlockfileMgrBlockReadWrite(t *testing.T) { defer blkfileMgrWrapper.close() blocks := testutil.ConstructTestBlocks(t, 10) blkfileMgrWrapper.addBlocks(blocks) - blkfileMgrWrapper.testGetBlockByHash(blocks, nil) - blkfileMgrWrapper.testGetBlockByNumber(blocks, 0, nil) + blkfileMgrWrapper.testGetBlockByHash(blocks) + blkfileMgrWrapper.testGetBlockByNumber(blocks) } func TestAddBlockWithWrongHash(t *testing.T) { @@ -384,7 +384,7 @@ func TestBlockfileMgrRestart(t *testing.T) { blkfileMgrWrapper = newTestBlockfileWrapper(env, ledgerid) defer blkfileMgrWrapper.close() require.Equal(t, 9, int(blkfileMgrWrapper.blockfileMgr.blockfilesInfo.lastPersistedBlock)) - blkfileMgrWrapper.testGetBlockByHash(blocks, nil) + blkfileMgrWrapper.testGetBlockByHash(blocks) require.Equal(t, expectedHeight, blkfileMgrWrapper.blockfileMgr.getBlockchainInfo().Height) } @@ -406,14 +406,14 @@ func TestBlockfileMgrFileRolling(t *testing.T) { blkfileMgrWrapper := newTestBlockfileWrapper(env, ledgerid) blkfileMgrWrapper.addBlocks(blocks[:100]) require.Equal(t, 1, blkfileMgrWrapper.blockfileMgr.blockfilesInfo.latestFileNumber) - blkfileMgrWrapper.testGetBlockByHash(blocks[:100], nil) + blkfileMgrWrapper.testGetBlockByHash(blocks[:100]) blkfileMgrWrapper.close() blkfileMgrWrapper = newTestBlockfileWrapper(env, ledgerid) defer blkfileMgrWrapper.close() blkfileMgrWrapper.addBlocks(blocks[100:]) require.Equal(t, 2, blkfileMgrWrapper.blockfileMgr.blockfilesInfo.latestFileNumber) - blkfileMgrWrapper.testGetBlockByHash(blocks[100:], nil) + blkfileMgrWrapper.testGetBlockByHash(blocks[100:]) } func TestBlockfileMgrGetBlockByTxID(t *testing.T) { @@ -500,7 +500,7 @@ func testBlockfileMgrSimulateCrashAtFirstBlockInFile(t *testing.T, deleteBlkfile blkfileMgrWrapper.addBlocks(blocks[5:]) require.True(t, testutilGetFileSize(t, lastFilePath) > 0) require.Equal(t, firstBlkFileSize, testutilGetFileSize(t, firstFilePath)) - blkfileMgrWrapper.testGetBlockByNumber(blocks, 0, nil) + blkfileMgrWrapper.testGetBlockByNumber(blocks) testBlockfileMgrBlockIterator(t, blkfileMgrWrapper.blockfileMgr, 0, len(blocks)-1, blocks) } diff --git a/common/ledger/blkstorage/blockindex.go b/common/ledger/blkstorage/blockindex.go index 64fcad031ed..828f401b43c 100644 --- a/common/ledger/blkstorage/blockindex.go +++ b/common/ledger/blkstorage/blockindex.go @@ -161,33 +161,37 @@ func (index *blockIndex) isAttributeIndexed(attribute IndexableAttr) bool { func (index *blockIndex) getBlockLocByHash(blockHash []byte) (*fileLocPointer, error) { if !index.isAttributeIndexed(IndexableAttrBlockHash) { - return nil, ErrAttrNotIndexed + return nil, errors.New("block hashes not maintained in index") } b, err := index.db.Get(constructBlockHashKey(blockHash)) if err != nil { return nil, err } if b == nil { - return nil, ErrNotFoundInIndex + return nil, errors.Errorf("no such block hash [%x] in index", blockHash) } blkLoc := &fileLocPointer{} - blkLoc.unmarshal(b) + if err := blkLoc.unmarshal(b); err != nil { + return nil, err + } return blkLoc, nil } func (index *blockIndex) getBlockLocByBlockNum(blockNum uint64) (*fileLocPointer, error) { if !index.isAttributeIndexed(IndexableAttrBlockNum) { - return nil, ErrAttrNotIndexed + return nil, errors.New("block numbers not maintained in index") } b, err := index.db.Get(constructBlockNumKey(blockNum)) if err != nil { return nil, err } if b == nil { - return nil, ErrNotFoundInIndex + return nil, errors.Errorf("no such block number [%d] in index", blockNum) } blkLoc := &fileLocPointer{} - blkLoc.unmarshal(b) + if err := blkLoc.unmarshal(b); err != nil { + return nil, err + } return blkLoc, nil } @@ -225,7 +229,7 @@ func (index *blockIndex) getTxValidationCodeByTxID(txID string) (peer.TxValidati func (index *blockIndex) txIDExists(txID string) (bool, error) { if !index.isAttributeIndexed(IndexableAttrTxID) { - return false, ErrAttrNotIndexed + return false, errors.New("transaction IDs not maintained in index") } rangeScan := constructTxIDRangeScan(txID) itr, err := index.db.GetIterator(rangeScan.startKey, rangeScan.stopKey) @@ -243,7 +247,7 @@ func (index *blockIndex) txIDExists(txID string) (bool, error) { func (index *blockIndex) getTxIDVal(txID string) (*TxIDIndexValue, error) { if !index.isAttributeIndexed(IndexableAttrTxID) { - return nil, ErrAttrNotIndexed + return nil, errors.New("transaction IDs not maintained in index") } rangeScan := constructTxIDRangeScan(txID) itr, err := index.db.GetIterator(rangeScan.startKey, rangeScan.stopKey) @@ -257,7 +261,7 @@ func (index *blockIndex) getTxIDVal(txID string) (*TxIDIndexValue, error) { return nil, errors.Wrapf(err, "error while trying to retrieve transaction info by TXID [%s]", txID) } if !present { - return nil, ErrNotFoundInIndex + return nil, errors.Errorf("no such transaction ID [%s] in index", txID) } valBytes := itr.Value() if len(valBytes) == 0 { @@ -272,23 +276,25 @@ func (index *blockIndex) getTxIDVal(txID string) (*TxIDIndexValue, error) { func (index *blockIndex) getTXLocByBlockNumTranNum(blockNum uint64, tranNum uint64) (*fileLocPointer, error) { if !index.isAttributeIndexed(IndexableAttrBlockNumTranNum) { - return nil, ErrAttrNotIndexed + return nil, errors.New(" tuple not maintained in index") } b, err := index.db.Get(constructBlockNumTranNumKey(blockNum, tranNum)) if err != nil { return nil, err } if b == nil { - return nil, ErrNotFoundInIndex + return nil, errors.Errorf("no such blockNumber, transactionNumber <%d, %d> in index", blockNum, tranNum) } txFLP := &fileLocPointer{} - txFLP.unmarshal(b) + if err := txFLP.unmarshal(b); err != nil { + return nil, err + } return txFLP, nil } func (index *blockIndex) exportUniqueTxIDs(dir string, newHashFunc snapshot.NewHashFunc) (map[string][]byte, error) { if !index.isAttributeIndexed(IndexableAttrTxID) { - return nil, ErrAttrNotIndexed + return nil, errors.New("transaction IDs not maintained in index") } dbItr, err := index.db.GetIterator([]byte{txIDIdxKeyPrefix}, []byte{txIDIdxKeyPrefix + 1}) diff --git a/common/ledger/blkstorage/blockindex_test.go b/common/ledger/blkstorage/blockindex_test.go index 897748329c6..6d1826e5f04 100644 --- a/common/ledger/blkstorage/blockindex_test.go +++ b/common/ledger/blkstorage/blockindex_test.go @@ -70,7 +70,7 @@ func testBlockIndexSync(t *testing.T, numBlocks int, numBlocksToIndex int, syncB // Before, we test for index sync-up, verify that the last set of blocks not indexed in the original index for i := numBlocksToIndex + 1; i <= numBlocks; i++ { _, err := blkfileMgr.retrieveBlockByNumber(uint64(i)) - require.Exactly(t, ErrNotFoundInIndex, err) + require.EqualError(t, err, fmt.Sprintf("no such block number [%d] in index", i)) } // perform index sync @@ -125,7 +125,7 @@ func testBlockIndexSelectiveIndexing(t *testing.T, indexItems []IndexableAttr) { require.NoError(t, err, "Error while retrieving block by hash") require.Equal(t, blocks[0], block) } else { - require.Exactly(t, ErrAttrNotIndexed, err) + require.EqualError(t, err, "block hashes not maintained in index") } // test 'retrieveBlockByNumber' @@ -134,7 +134,7 @@ func testBlockIndexSelectiveIndexing(t *testing.T, indexItems []IndexableAttr) { require.NoError(t, err, "Error while retrieving block by number") require.Equal(t, blocks[0], block) } else { - require.Exactly(t, ErrAttrNotIndexed, err) + require.EqualError(t, err, "block numbers not maintained in index") } // test 'retrieveTransactionByID' @@ -148,7 +148,7 @@ func testBlockIndexSelectiveIndexing(t *testing.T, indexItems []IndexableAttr) { require.NoError(t, err) require.Equal(t, txEnvelopeOrig, txEnvelope) } else { - require.Exactly(t, ErrAttrNotIndexed, err) + require.EqualError(t, err, "transaction IDs not maintained in index") } // test txIDExists @@ -159,7 +159,7 @@ func testBlockIndexSelectiveIndexing(t *testing.T, indexItems []IndexableAttr) { require.NoError(t, err) require.True(t, exists) } else { - require.Exactly(t, ErrAttrNotIndexed, err) + require.EqualError(t, err, "transaction IDs not maintained in index") } //test 'retrieveTrasnactionsByBlockNumTranNum @@ -171,7 +171,7 @@ func testBlockIndexSelectiveIndexing(t *testing.T, indexItems []IndexableAttr) { require.NoError(t, err2) require.Equal(t, txEnvelopeOrig2, txEnvelope2) } else { - require.Exactly(t, ErrAttrNotIndexed, err) + require.EqualError(t, err, " tuple not maintained in index") } // test 'retrieveBlockByTxID' @@ -182,7 +182,7 @@ func testBlockIndexSelectiveIndexing(t *testing.T, indexItems []IndexableAttr) { require.NoError(t, err, "Error while retrieving block by txID") require.Equal(t, block, blocks[0]) } else { - require.Exactly(t, ErrAttrNotIndexed, err) + require.EqualError(t, err, "transaction IDs not maintained in index") } for _, block := range blocks { @@ -195,13 +195,11 @@ func testBlockIndexSelectiveIndexing(t *testing.T, indexItems []IndexableAttr) { reason, err := blockfileMgr.retrieveTxValidationCodeByTxID(txid) if containsAttr(indexItems, IndexableAttrTxID) { - require.NoError(t, err, "Error while retrieving tx validation code by txID") - + require.NoError(t, err) reasonFromFlags := flags.Flag(idx) - require.Equal(t, reasonFromFlags, reason) } else { - require.Exactly(t, ErrAttrNotIndexed, err) + require.EqualError(t, err, "transaction IDs not maintained in index") } } } @@ -349,7 +347,7 @@ func TestExportUniqueTxIDsWhenTxIDsNotIndexed(t *testing.T) { testSnapshotDir := testPath() defer os.RemoveAll(testSnapshotDir) _, err := blkfileMgrWrapper.blockfileMgr.index.exportUniqueTxIDs(testSnapshotDir, testNewHashFunc) - require.Equal(t, err, ErrAttrNotIndexed) + require.EqualError(t, err, "transaction IDs not maintained in index") } func TestExportUniqueTxIDsErrorCases(t *testing.T) { diff --git a/common/ledger/blkstorage/blockstore_provider.go b/common/ledger/blkstorage/blockstore_provider.go index 22b60d0f195..2fdb6a32a86 100644 --- a/common/ledger/blkstorage/blockstore_provider.go +++ b/common/ledger/blkstorage/blockstore_provider.go @@ -13,7 +13,6 @@ import ( "github.com/hyperledger/fabric/common/ledger/dataformat" "github.com/hyperledger/fabric/common/ledger/util/leveldbhelper" "github.com/hyperledger/fabric/common/metrics" - "github.com/hyperledger/fabric/core/ledger" "github.com/hyperledger/fabric/internal/fileutil" "github.com/pkg/errors" ) @@ -53,14 +52,6 @@ func (c *IndexConfig) Contains(indexableAttr IndexableAttr) bool { return false } -var ( - // ErrNotFoundInIndex is used to indicate missing entry in the index - ErrNotFoundInIndex = ledger.NotFoundInIndexErr("") - - // ErrAttrNotIndexed is used to indicate that an attribute is not indexed - ErrAttrNotIndexed = errors.New("attribute not indexed") -) - // BlockStoreProvider provides handle to block storage - this is not thread-safe type BlockStoreProvider struct { conf *Conf diff --git a/common/ledger/blkstorage/blockstore_provider_test.go b/common/ledger/blkstorage/blockstore_provider_test.go index e303782b31d..5305cb84503 100644 --- a/common/ledger/blkstorage/blockstore_provider_test.go +++ b/common/ledger/blkstorage/blockstore_provider_test.go @@ -140,23 +140,23 @@ func checkBlocks(t *testing.T, expectedBlocks []*common.Block, store *BlockStore func checkWithWrongInputs(t *testing.T, store *BlockStore, numBlocks int) { block, err := store.RetrieveBlockByHash([]byte("non-existent-hash")) require.Nil(t, block) - require.Equal(t, ErrNotFoundInIndex, err) + require.EqualError(t, err, fmt.Sprintf("no such block hash [%x] in index", []byte("non-existent-hash"))) block, err = store.RetrieveBlockByTxID("non-existent-txid") require.Nil(t, block) - require.Equal(t, ErrNotFoundInIndex, err) + require.EqualError(t, err, "no such transaction ID [non-existent-txid] in index") tx, err := store.RetrieveTxByID("non-existent-txid") require.Nil(t, tx) - require.Equal(t, ErrNotFoundInIndex, err) + require.EqualError(t, err, "no such transaction ID [non-existent-txid] in index") tx, err = store.RetrieveTxByBlockNumTranNum(uint64(numBlocks+1), uint64(0)) require.Nil(t, tx) - require.Equal(t, ErrNotFoundInIndex, err) + require.EqualError(t, err, fmt.Sprintf("no such blockNumber, transactionNumber <%d, 0> in index", numBlocks+1)) txCode, err := store.RetrieveTxValidationCodeByTxID("non-existent-txid") require.Equal(t, peer.TxValidationCode(-1), txCode) - require.Equal(t, ErrNotFoundInIndex, err) + require.EqualError(t, err, "no such transaction ID [non-existent-txid] in index") } func TestBlockStoreProvider(t *testing.T) { diff --git a/common/ledger/blkstorage/pkg_test.go b/common/ledger/blkstorage/pkg_test.go index 83904bf4392..81be51dc4d6 100644 --- a/common/ledger/blkstorage/pkg_test.go +++ b/common/ledger/blkstorage/pkg_test.go @@ -7,6 +7,7 @@ SPDX-License-Identifier: Apache-2.0 package blkstorage import ( + "fmt" "io/ioutil" "math" "os" @@ -90,26 +91,18 @@ func (w *testBlockfileMgrWrapper) addBlocks(blocks []*common.Block) { } } -func (w *testBlockfileMgrWrapper) testGetBlockByHash(blocks []*common.Block, expectedErr error) { +func (w *testBlockfileMgrWrapper) testGetBlockByHash(blocks []*common.Block) { for i, block := range blocks { hash := protoutil.BlockHeaderHash(block.Header) b, err := w.blockfileMgr.retrieveBlockByHash(hash) - if expectedErr != nil { - require.Error(w.t, err, expectedErr.Error()) - continue - } require.NoError(w.t, err, "Error while retrieving [%d]th block from blockfileMgr", i) require.Equal(w.t, block, b) } } -func (w *testBlockfileMgrWrapper) testGetBlockByNumber(blocks []*common.Block, startingNum uint64, expectedErr error) { +func (w *testBlockfileMgrWrapper) testGetBlockByNumber(blocks []*common.Block) { for i := 0; i < len(blocks); i++ { - b, err := w.blockfileMgr.retrieveBlockByNumber(startingNum + uint64(i)) - if expectedErr != nil { - require.Equal(w.t, err.Error(), expectedErr.Error()) - continue - } + b, err := w.blockfileMgr.retrieveBlockByNumber(blocks[0].Header.Number + uint64(i)) require.NoError(w.t, err, "Error while retrieving [%d]th block from blockfileMgr", i) require.Equal(w.t, blocks[i], b) } @@ -120,22 +113,37 @@ func (w *testBlockfileMgrWrapper) testGetBlockByNumber(blocks []*common.Block, s require.Equal(w.t, blocks[iLastBlock], b) } -func (w *testBlockfileMgrWrapper) testGetBlockByTxID(blocks []*common.Block, expectedErr error) { +func (w *testBlockfileMgrWrapper) testGetBlockByTxID(blocks []*common.Block) { for i, block := range blocks { for _, txEnv := range block.Data.Data { txID, err := protoutil.GetOrComputeTxIDFromEnvelope(txEnv) require.NoError(w.t, err) b, err := w.blockfileMgr.retrieveBlockByTxID(txID) - if expectedErr != nil { - require.Equal(w.t, err.Error(), expectedErr.Error()) - continue - } require.NoError(w.t, err, "Error while retrieving [%d]th block from blockfileMgr", i) require.Equal(w.t, block, b) } } } +func (w *testBlockfileMgrWrapper) testGetBlockByHashNotIndexed(blocks []*common.Block) { + for _, block := range blocks { + hash := protoutil.BlockHeaderHash(block.Header) + _, err := w.blockfileMgr.retrieveBlockByHash(hash) + require.EqualError(w.t, err, fmt.Sprintf("no such block hash [%x] in index", hash)) + } +} + +func (w *testBlockfileMgrWrapper) testGetBlockByTxIDNotIndexed(blocks []*common.Block) { + for _, block := range blocks { + for _, txEnv := range block.Data.Data { + txID, err := protoutil.GetOrComputeTxIDFromEnvelope(txEnv) + require.NoError(w.t, err) + _, err = w.blockfileMgr.retrieveBlockByTxID(txID) + require.EqualError(w.t, err, fmt.Sprintf("no such transaction ID [%s] in index", txID)) + } + } +} + func (w *testBlockfileMgrWrapper) testGetTransactionByTxID(txID string, expectedEnvelope []byte, expectedErr error) { envelope, err := w.blockfileMgr.retrieveTransactionByID(txID) if expectedErr != nil { diff --git a/common/ledger/blkstorage/reset_test.go b/common/ledger/blkstorage/reset_test.go index 91fdbcc12b9..a0ebfbe3b48 100644 --- a/common/ledger/blkstorage/reset_test.go +++ b/common/ledger/blkstorage/reset_test.go @@ -232,8 +232,7 @@ func assertBlockStorePostReset(t *testing.T, store *BlockStore, originallyCommit require.Equal(t, originallyCommittedBlocks[0], blk) _, err = store.RetrieveBlockByNumber(1) - require.Error(t, err) - require.Equal(t, err, ErrNotFoundInIndex) + require.EqualError(t, err, "no such block number [1] in index") err = store.AddBlock(originallyCommittedBlocks[0]) require.EqualError(t, err, "block number should have been 1 but was 0") diff --git a/common/ledger/blkstorage/rollback_test.go b/common/ledger/blkstorage/rollback_test.go index 6dfbcaaa0ef..5c915b730f6 100644 --- a/common/ledger/blkstorage/rollback_test.go +++ b/common/ledger/blkstorage/rollback_test.go @@ -15,7 +15,6 @@ import ( "github.com/hyperledger/fabric/common/ledger/testutil" "github.com/hyperledger/fabric/common/metrics/disabled" "github.com/hyperledger/fabric/protoutil" - "github.com/pkg/errors" "github.com/stretchr/testify/require" ) @@ -55,9 +54,9 @@ func TestRollback(t *testing.T) { require.Equal(t, actualBlkfilesInfo.latestFileNumber, 4) // 4. Check whether all blocks are stored correctly - blkfileMgrWrapper.testGetBlockByNumber(blocks, 0, nil) - blkfileMgrWrapper.testGetBlockByHash(blocks, nil) - blkfileMgrWrapper.testGetBlockByTxID(blocks, nil) + blkfileMgrWrapper.testGetBlockByNumber(blocks) + blkfileMgrWrapper.testGetBlockByHash(blocks) + blkfileMgrWrapper.testGetBlockByTxID(blocks) // 5. Close the blkfileMgrWrapper env.provider.Close() @@ -314,23 +313,22 @@ func assertBlockStoreRollback(t *testing.T, path, ledgerID string, blocks []*com // 3. Check whether all blocks till the target block number are stored correctly if blkfileMgrWrapper.blockfileMgr.index.isAttributeIndexed(IndexableAttrBlockNum) { - blkfileMgrWrapper.testGetBlockByNumber(blocks[:rollbackedToBlkNum+1], 0, nil) + blkfileMgrWrapper.testGetBlockByNumber(blocks[:rollbackedToBlkNum+1]) } if blkfileMgrWrapper.blockfileMgr.index.isAttributeIndexed(IndexableAttrBlockHash) { - blkfileMgrWrapper.testGetBlockByHash(blocks[:rollbackedToBlkNum+1], nil) + blkfileMgrWrapper.testGetBlockByHash(blocks[:rollbackedToBlkNum+1]) } if blkfileMgrWrapper.blockfileMgr.index.isAttributeIndexed(IndexableAttrTxID) { - blkfileMgrWrapper.testGetBlockByTxID(blocks[:rollbackedToBlkNum+1], nil) + blkfileMgrWrapper.testGetBlockByTxID(blocks[:rollbackedToBlkNum+1]) } // 4. Check whether all blocks with number greater than target block number // are removed including index entries - expectedErr := errors.New("Entry not found in index") if blkfileMgrWrapper.blockfileMgr.index.isAttributeIndexed(IndexableAttrBlockHash) { - blkfileMgrWrapper.testGetBlockByHash(blocks[rollbackedToBlkNum+1:], expectedErr) + blkfileMgrWrapper.testGetBlockByHashNotIndexed(blocks[rollbackedToBlkNum+1:]) } if blkfileMgrWrapper.blockfileMgr.index.isAttributeIndexed(IndexableAttrTxID) { - blkfileMgrWrapper.testGetBlockByTxID(blocks[rollbackedToBlkNum+1:], expectedErr) + blkfileMgrWrapper.testGetBlockByTxIDNotIndexed(blocks[rollbackedToBlkNum+1:]) } // 5. Close the blkfileMgrWrapper diff --git a/common/ledger/blkstorage/snapshot_test.go b/common/ledger/blkstorage/snapshot_test.go index 47ebda4192c..b0fde2be3da 100644 --- a/common/ledger/blkstorage/snapshot_test.go +++ b/common/ledger/blkstorage/snapshot_test.go @@ -285,7 +285,7 @@ func TestImportFromSnapshot(t *testing.T) { // before, we test for index sync-up, verify that the last set of blocks not indexed in the original index _, err := blkfileMgr.retrieveBlockByNumber(block.Header.Number) - require.Exactly(t, ErrNotFoundInIndex, err) + require.EqualError(t, err, fmt.Sprintf("no such block number [%d] in index", block.Header.Number)) // close and open should be able to sync-up the index closeBlockStore() @@ -473,7 +473,7 @@ func verifyQueriesOnBlocksPriorToSnapshot( require.EqualError(t, err, expectedErrStr) _, err = bootstrappedBlockStore.RetrieveBlockByHash(blockHash) - require.Equal(t, ErrNotFoundInIndex, err) + require.EqualError(t, err, fmt.Sprintf("no such block hash [%x] in index", blockHash)) } bootstrappingSnapshotHeight := uint64(len(blocksDetailsBeforeSnapshot)) diff --git a/core/ledger/kvledger/channelinfo_provider_test.go b/core/ledger/kvledger/channelinfo_provider_test.go index f062ba67d82..a33e8c48acf 100644 --- a/core/ledger/kvledger/channelinfo_provider_test.go +++ b/core/ledger/kvledger/channelinfo_provider_test.go @@ -202,7 +202,7 @@ func TestGetAllMSPIDs_NegativeTests(t *testing.T) { configBlock = newBlock(nil, lastBlockNum, lastBlockNum+1, protoutil.BlockHeaderHash(configBlock.Header)) require.NoError(t, blkStore.AddBlock(configBlock)) _, err = channelInfoProvider.getAllMSPIDs() - require.EqualError(t, err, "Entry not found in index") + require.EqualError(t, err, "no such block number [3] in index") // test GetLastConfigIndexFromBlock error by using invalid bytes for LastConfig metadata value lastBlockNum++ diff --git a/core/ledger/ledger_interface.go b/core/ledger/ledger_interface.go index 6680a302e4e..a34d08cd6a3 100644 --- a/core/ledger/ledger_interface.go +++ b/core/ledger/ledger_interface.go @@ -585,13 +585,6 @@ func (e *ErrCollectionConfigNotYetAvailable) Error() string { return e.Msg } -// NotFoundInIndexErr is used to indicate missing entry in the index -type NotFoundInIndexErr string - -func (NotFoundInIndexErr) Error() string { - return "Entry not found in index" -} - // CollConfigNotDefinedError is returned whenever an operation // is requested on a collection whose config has not been defined type CollConfigNotDefinedError struct {