@@ -96,6 +96,34 @@ func TestInvoke(t *testing.T) {
96
96
t .Fatalf ("escc invoke should have failed with invalid number of args: %v" , args )
97
97
}
98
98
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
+
99
127
// Failed path: header is null
100
128
args = [][]byte {[]byte ("test" ), nil , []byte ("test" ), ccidBytes , successRes , []byte ("test" )}
101
129
if res := stub .MockInvoke ("1" , args ); res .Status == shim .OK {
@@ -160,9 +188,16 @@ func TestInvoke(t *testing.T) {
160
188
return
161
189
}
162
190
163
- // success test 1: invocation with mandatory args only
164
191
simRes := []byte ("simulation_result" )
165
192
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
166
201
args = [][]byte {[]byte ("" ), proposal .Header , proposal .Payload , ccidBytes , successRes , simRes }
167
202
res := stub .MockInvoke ("1" , args )
168
203
if res .Status != shim .OK {
0 commit comments