Commit f096ff73 authored by yacovm's avatar yacovm
Browse files

[FAB-10154] Close RWSetScanner at end of use



There is a missing call to Close() after obtaining the RWSetScanner
and iterating over the results, in the private data support
for the endorser plugins.

Change-Id: I645ae82f2e985188b1d526461695aaf24a77674e
Signed-off-by: default avataryacovm <yacovm@il.ibm.com>
parent ec1f138b
......@@ -234,6 +234,7 @@ func (fep *fakeEndorsementPlugin) Init(dependencies ...endorsement.Dependency) e
}
type rwsetScanner struct {
mock.Mock
data []*rwset.TxPvtReadWriteSet
}
......@@ -254,8 +255,8 @@ func (rws *rwsetScanner) NextWithConfig() (*transientstore.EndorserPvtSimulation
}, nil
}
func (*rwsetScanner) Close() {
panic("implement me")
func (rws *rwsetScanner) Close() {
rws.Called()
}
func TestTransientStore(t *testing.T) {
......@@ -312,6 +313,7 @@ func TestTransientStore(t *testing.T) {
scanner := &rwsetScanner{
data: []*rwset.TxPvtReadWriteSet{rws},
}
scanner.On("Close")
transientStore.On("GetTxPvtRWSetByTxid", mock.Anything, mock.Anything).Return(scanner, nil)
......@@ -322,4 +324,5 @@ func TestTransientStore(t *testing.T) {
err = proto.Unmarshal(resp.Payload, txrws)
assert.NoError(t, err)
assert.Equal(t, rws, txrws)
scanner.AssertCalled(t, "Close")
}
......@@ -51,6 +51,7 @@ func (sc *StateContext) GetTransientByTXID(txID string) ([]*rwset.TxPvtReadWrite
if err != nil {
return nil, errors.WithStack(err)
}
defer scanner.Close()
var data []*rwset.TxPvtReadWriteSet
for {
res, err := scanner.NextWithConfig()
......
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