Skip to content

Commit 00ed512

Browse files
committed
[FAB-3521] Increase test coverage for ESCC
Test coverage for core/scc/escc is now coverage: 91.2% of statements ok github.com/hyperledger/fabric/core/scc/escc 0.034s Change-Id: Id239dc169f6a42eecdfd9192289df425f27ffdd0 Signed-off-by: Alessandro Sorniotti <[email protected]>
1 parent a0763aa commit 00ed512

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

core/scc/escc/endorser_onevalidsignature_test.go

+36-1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,34 @@ func TestInvoke(t *testing.T) {
9696
t.Fatalf("escc invoke should have failed with invalid number of args: %v", args)
9797
}
9898

99+
// Too many parameters
100+
a := []byte("test")
101+
args = [][]byte{a, a, a, a, a, a, a, a, a}
102+
if res := stub.MockInvoke("1", args); res.Status == shim.OK {
103+
t.Fatalf("escc invoke should have failed with invalid number of args: %v", args)
104+
}
105+
106+
// Failed path: ccid is null
107+
args = [][]byte{[]byte("test"), []byte("test"), []byte("test"), nil, successRes, []byte("test")}
108+
if res := stub.MockInvoke("1", args); res.Status == shim.OK {
109+
fmt.Println("Invoke", args, "failed", string(res.Message))
110+
t.Fatalf("escc invoke should have failed with a null header. args: %v", args)
111+
}
112+
113+
// Failed path: ccid is bogus
114+
args = [][]byte{[]byte("test"), []byte("test"), []byte("test"), []byte("barf"), successRes, []byte("test")}
115+
if res := stub.MockInvoke("1", args); res.Status == shim.OK {
116+
fmt.Println("Invoke", args, "failed", string(res.Message))
117+
t.Fatalf("escc invoke should have failed with a null header. args: %v", args)
118+
}
119+
120+
// Failed path: response is bogus
121+
args = [][]byte{[]byte("test"), []byte("test"), []byte("test"), ccidBytes, []byte("barf"), []byte("test")}
122+
if res := stub.MockInvoke("1", args); res.Status == shim.OK {
123+
fmt.Println("Invoke", args, "failed", string(res.Message))
124+
t.Fatalf("escc invoke should have failed with a null header. args: %v", args)
125+
}
126+
99127
// Failed path: header is null
100128
args = [][]byte{[]byte("test"), nil, []byte("test"), ccidBytes, successRes, []byte("test")}
101129
if res := stub.MockInvoke("1", args); res.Status == shim.OK {
@@ -160,9 +188,16 @@ func TestInvoke(t *testing.T) {
160188
return
161189
}
162190

163-
// success test 1: invocation with mandatory args only
164191
simRes := []byte("simulation_result")
165192

193+
// bogus header
194+
args = [][]byte{[]byte(""), []byte("barf"), proposal.Payload, ccidBytes, successRes, simRes}
195+
if res := stub.MockInvoke("1", args); res.Status == shim.OK {
196+
fmt.Println("Invoke", args, "failed", string(res.Message))
197+
t.Fatalf("escc invoke should have failed with a null response. args: %v", args)
198+
}
199+
200+
// success test 1: invocation with mandatory args only
166201
args = [][]byte{[]byte(""), proposal.Header, proposal.Payload, ccidBytes, successRes, simRes}
167202
res := stub.MockInvoke("1", args)
168203
if res.Status != shim.OK {

0 commit comments

Comments
 (0)