Skip to content

Commit 598d417

Browse files
liam-gracemastersingh24
authored andcommitted
[FAB-4065] core/container/inproccontroller coverage
This change brings the test coverage of core/container/inproccontroller up to 91.9% Change-Id: I82a6e8f7eb8e9cffa8c326cd64f1ebb504978ee4 Signed-off-by: Liam Grace <liamgrace.896@gmail.com> Signed-off-by: Gari Singh <gari.r.singh@gmail.com>
1 parent 7996cc7 commit 598d417

File tree

3 files changed

+637
-37
lines changed

3 files changed

+637
-37
lines changed

core/chaincode/platforms/platforms_test.go

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
/*
2-
Copyright IBM Corp. 2016 All Rights Reserved.
2+
Copyright IBM Corp. All Rights Reserved.
33
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
4+
SPDX-License-Identifier: Apache-2.0
155
*/
166

177
package platforms
@@ -118,7 +108,7 @@ func GetPathErr(str string) string {
118108
return ""
119109
}
120110

121-
func VGetBoolErr(str string) bool {
111+
func VGetBoolFalse(str string) bool {
122112
return false
123113
}
124114

@@ -130,7 +120,7 @@ func GetPathOk(str string) string {
130120
return "OK"
131121
}
132122

133-
func VGetBoolOk(str string) bool {
123+
func VGetBoolTrue(str string) bool {
134124
return true
135125
}
136126

@@ -155,7 +145,7 @@ func TestGetPeerTLSCert(t *testing.T) {
155145
}()
156146

157147
_GetPath = GetPathErr
158-
_VGetBool = VGetBoolErr
148+
_VGetBool = VGetBoolFalse
159149
_OSStat = OSStatOk
160150
_IOUtilReadFile = IOUtilReadFile
161151

@@ -165,7 +155,7 @@ func TestGetPeerTLSCert(t *testing.T) {
165155
assert.Nil(t, err, "err should have been nil")
166156

167157
_GetPath = GetPathOk
168-
_VGetBool = VGetBoolOk
158+
_VGetBool = VGetBoolTrue
169159
_OSStat = OSStatOk
170160
_IOUtilReadFile = IOUtilReadFile
171161

@@ -174,7 +164,7 @@ func TestGetPeerTLSCert(t *testing.T) {
174164
assert.Nil(t, err, "Err should have been nil")
175165
assert.NotNil(t, response, "Response should not have been nil")
176166

177-
_VGetBool = VGetBoolOk
167+
_VGetBool = VGetBoolTrue
178168
_GetPath = GetPathErr
179169
_OSStat = OSStatOk
180170
_IOUtilReadFile = IOUtilReadFile
@@ -184,7 +174,7 @@ func TestGetPeerTLSCert(t *testing.T) {
184174
assert.Nil(t, err, "Err should have been nil")
185175
assert.NotNil(t, response, "Response should not have been nil")
186176

187-
_VGetBool = VGetBoolOk
177+
_VGetBool = VGetBoolTrue
188178
_GetPath = GetPathOk
189179
_OSStat = OSStatErr
190180
_IOUtilReadFile = IOUtilReadFile

core/container/inproccontroller/inproccontroller.go

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
/*
2-
Copyright IBM Corp. 2016 All Rights Reserved.
2+
Copyright IBM Corp. All Rights Reserved.
33
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
4+
SPDX-License-Identifier: Apache-2.0
155
*/
166

177
package inproccontroller
@@ -38,9 +28,11 @@ type inprocContainer struct {
3828
}
3929

4030
var (
41-
inprocLogger = flogging.MustGetLogger("inproccontroller")
42-
typeRegistry = make(map[string]*inprocContainer)
43-
instRegistry = make(map[string]*inprocContainer)
31+
inprocLogger = flogging.MustGetLogger("inproccontroller")
32+
typeRegistry = make(map[string]*inprocContainer)
33+
instRegistry = make(map[string]*inprocContainer)
34+
_shimStartInProc = shim.StartInProc
35+
_inprocLoggerErrorf = inprocLogger.Errorf
4436
)
4537

4638
// errors
@@ -117,10 +109,10 @@ func (ipc *inprocContainer) launchInProc(ctxt context.Context, id string, args [
117109
if env == nil {
118110
env = ipc.env
119111
}
120-
err := shim.StartInProc(env, args, ipc.chaincode, ccRcvPeerSend, peerRcvCCSend)
112+
err := _shimStartInProc(env, args, ipc.chaincode, ccRcvPeerSend, peerRcvCCSend)
121113
if err != nil {
122114
err = fmt.Errorf("chaincode-support ended with err: %s", err)
123-
inprocLogger.Errorf("%s", err)
115+
_inprocLoggerErrorf("%s", err)
124116
}
125117
inprocLogger.Debugf("chaincode ended with for %s with err: %s", id, err)
126118
}()
@@ -132,7 +124,7 @@ func (ipc *inprocContainer) launchInProc(ctxt context.Context, id string, args [
132124
err := ccSupport.HandleChaincodeStream(ctxt, inprocStream)
133125
if err != nil {
134126
err = fmt.Errorf("chaincode ended with err: %s", err)
135-
inprocLogger.Errorf("%s", err)
127+
_inprocLoggerErrorf("%s", err)
136128
}
137129
inprocLogger.Debugf("chaincode-support ended with for %s with err: %s", id, err)
138130
}()
@@ -149,7 +141,6 @@ func (ipc *inprocContainer) launchInProc(ctxt context.Context, id string, args [
149141
close(peerRcvCCSend)
150142
inprocLogger.Debugf("chaincode %s stopped", id)
151143
}
152-
153144
return err
154145
}
155146

0 commit comments

Comments
 (0)