Skip to content

Commit

Permalink
[FAB-3521] Increase test coverage for ESCC
Browse files Browse the repository at this point in the history
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 <ale.linux@sopit.net>
  • Loading branch information
ale-linux committed Apr 29, 2017
1 parent a0763aa commit 00ed512
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion core/scc/escc/endorser_onevalidsignature_test.go
Expand Up @@ -96,6 +96,34 @@ func TestInvoke(t *testing.T) {
t.Fatalf("escc invoke should have failed with invalid number of args: %v", args)
}

// Too many parameters
a := []byte("test")
args = [][]byte{a, a, a, a, a, a, a, a, a}
if res := stub.MockInvoke("1", args); res.Status == shim.OK {
t.Fatalf("escc invoke should have failed with invalid number of args: %v", args)
}

// Failed path: ccid is null
args = [][]byte{[]byte("test"), []byte("test"), []byte("test"), nil, successRes, []byte("test")}
if res := stub.MockInvoke("1", args); res.Status == shim.OK {
fmt.Println("Invoke", args, "failed", string(res.Message))
t.Fatalf("escc invoke should have failed with a null header. args: %v", args)
}

// Failed path: ccid is bogus
args = [][]byte{[]byte("test"), []byte("test"), []byte("test"), []byte("barf"), successRes, []byte("test")}
if res := stub.MockInvoke("1", args); res.Status == shim.OK {
fmt.Println("Invoke", args, "failed", string(res.Message))
t.Fatalf("escc invoke should have failed with a null header. args: %v", args)
}

// Failed path: response is bogus
args = [][]byte{[]byte("test"), []byte("test"), []byte("test"), ccidBytes, []byte("barf"), []byte("test")}
if res := stub.MockInvoke("1", args); res.Status == shim.OK {
fmt.Println("Invoke", args, "failed", string(res.Message))
t.Fatalf("escc invoke should have failed with a null header. args: %v", args)
}

// Failed path: header is null
args = [][]byte{[]byte("test"), nil, []byte("test"), ccidBytes, successRes, []byte("test")}
if res := stub.MockInvoke("1", args); res.Status == shim.OK {
Expand Down Expand Up @@ -160,9 +188,16 @@ func TestInvoke(t *testing.T) {
return
}

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

// bogus header
args = [][]byte{[]byte(""), []byte("barf"), proposal.Payload, ccidBytes, successRes, simRes}
if res := stub.MockInvoke("1", args); res.Status == shim.OK {
fmt.Println("Invoke", args, "failed", string(res.Message))
t.Fatalf("escc invoke should have failed with a null response. args: %v", args)
}

// success test 1: invocation with mandatory args only
args = [][]byte{[]byte(""), proposal.Header, proposal.Payload, ccidBytes, successRes, simRes}
res := stub.MockInvoke("1", args)
if res.Status != shim.OK {
Expand Down

0 comments on commit 00ed512

Please sign in to comment.