@@ -32,8 +32,8 @@ func jsonResponse(name string, value string) string {
32
32
return fmt .Sprintf ("jsonResponse = \" {\" Name\" :\" %v\" ,\" Value\" :\" %v\" }" , name , value )
33
33
}
34
34
35
- func checkInit (t * testing.T , stub * shim.MockStub , args []string ) {
36
- _ , err := stub .MockInit ("1" , "init" , args )
35
+ func checkInit (t * testing.T , stub * shim.MockStub , args [][] byte ) {
36
+ _ , err := stub .MockInit ("1" , args )
37
37
if err != nil {
38
38
fmt .Println ("Init failed" , err )
39
39
t .FailNow ()
@@ -52,8 +52,8 @@ func checkState(t *testing.T, stub *shim.MockStub, name string, expect string) {
52
52
}
53
53
}
54
54
55
- func checkQuery (t * testing.T , stub * shim.MockStub , args []string , expect string ) {
56
- bytes , err := stub .MockQuery ("query" , args )
55
+ func checkQuery (t * testing.T , stub * shim.MockStub , args [][] byte , expect string ) {
56
+ bytes , err := stub .MockQuery (args )
57
57
if err != nil {
58
58
fmt .Println ("Query" , args , "failed" , err )
59
59
t .FailNow ()
@@ -68,8 +68,8 @@ func checkQuery(t *testing.T, stub *shim.MockStub, args []string, expect string)
68
68
}
69
69
}
70
70
71
- func checkInvoke (t * testing.T , stub * shim.MockStub , args []string ) {
72
- _ , err := stub .MockInvoke ("1" , "query" , args )
71
+ func checkInvoke (t * testing.T , stub * shim.MockStub , args [][] byte ) {
72
+ _ , err := stub .MockInvoke ("1" , args )
73
73
if err != nil {
74
74
fmt .Println ("Invoke" , args , "failed" , err )
75
75
t .FailNow ()
@@ -81,7 +81,7 @@ func TestExample04_Init(t *testing.T) {
81
81
stub := shim .NewMockStub ("ex05" , scc )
82
82
83
83
// Init A=123 B=234
84
- checkInit (t , stub , []string { " sumStoreName", "432" })
84
+ checkInit (t , stub , [][] byte {[] byte ( "init" ), [] byte ( " sumStoreName"), [] byte ( "432" ) })
85
85
86
86
checkState (t , stub , "sumStoreName" , "432" )
87
87
}
@@ -92,13 +92,13 @@ func TestExample04_Query(t *testing.T) {
92
92
93
93
ccEx2 := new (ex02.SimpleChaincode )
94
94
stubEx2 := shim .NewMockStub ("ex02" , ccEx2 )
95
- checkInit (t , stubEx2 , []string { "a" , "111" , "b" , "222" })
95
+ checkInit (t , stubEx2 , [][] byte {[] byte ( "init" ), [] byte ( "a" ), [] byte ( "111" ), [] byte ( "b" ), [] byte ( "222" ) })
96
96
stub .MockPeerChaincode (example02Url , stubEx2 )
97
97
98
- checkInit (t , stub , []string { " sumStoreName", "0" })
98
+ checkInit (t , stub , [][] byte {[] byte ( "init" ), [] byte ( " sumStoreName"), [] byte ( "0" ) })
99
99
100
100
// a + b = 111 + 222 = 333
101
- checkQuery (t , stub , []string { example02Url , "sumStoreName" }, "333" ) // example05 doesn't return JSON?
101
+ checkQuery (t , stub , [][] byte {[] byte ( "query" ), [] byte ( example02Url ), [] byte ( "sumStoreName" ) }, "333" ) // example05 doesn't return JSON?
102
102
}
103
103
104
104
func TestExample04_Invoke (t * testing.T ) {
@@ -107,23 +107,23 @@ func TestExample04_Invoke(t *testing.T) {
107
107
108
108
ccEx2 := new (ex02.SimpleChaincode )
109
109
stubEx2 := shim .NewMockStub ("ex02" , ccEx2 )
110
- checkInit (t , stubEx2 , []string { "a" , "222" , "b" , "333" })
110
+ checkInit (t , stubEx2 , [][] byte {[] byte ( "init" ), [] byte ( "a" ), [] byte ( "222" ), [] byte ( "b" ), [] byte ( "333" ) })
111
111
stub .MockPeerChaincode (example02Url , stubEx2 )
112
112
113
- checkInit (t , stub , []string { " sumStoreName", "0" })
113
+ checkInit (t , stub , [][] byte {[] byte ( "init" ), [] byte ( " sumStoreName"), [] byte ( "0" ) })
114
114
115
115
// a + b = 222 + 333 = 555
116
- checkInvoke (t , stub , []string { example02Url , "sumStoreName" })
117
- checkQuery (t , stub , []string { example02Url , "sumStoreName" }, "555" ) // example05 doesn't return JSON?
118
- checkQuery (t , stubEx2 , []string { "a" }, "222" )
119
- checkQuery (t , stubEx2 , []string { "b" }, "333" )
116
+ checkInvoke (t , stub , [][] byte {[] byte ( "invoke" ), [] byte ( example02Url ), [] byte ( "sumStoreName" ) })
117
+ checkQuery (t , stub , [][] byte {[] byte ( "query" ), [] byte ( example02Url ), [] byte ( "sumStoreName" ) }, "555" ) // example05 doesn't return JSON?
118
+ checkQuery (t , stubEx2 , [][] byte {[] byte ( "query" ), [] byte ( "a" ) }, "222" )
119
+ checkQuery (t , stubEx2 , [][] byte {[] byte ( "query" ), [] byte ( "b" ) }, "333" )
120
120
121
121
// update A-=10 and B+=10
122
- checkInvoke (t , stubEx2 , []string { "a" , "b" , "10" })
122
+ checkInvoke (t , stubEx2 , [][] byte {[] byte ( "invoke" ), [] byte ( "a" ), [] byte ( "b" ), [] byte ( "10" ) })
123
123
124
124
// a + b = 212 + 343 = 555
125
- checkInvoke (t , stub , []string { example02Url , "sumStoreName" })
126
- checkQuery (t , stub , []string { example02Url , "sumStoreName" }, "555" ) // example05 doesn't return JSON?
127
- checkQuery (t , stubEx2 , []string { "a" }, "212" )
128
- checkQuery (t , stubEx2 , []string { "b" }, "343" )
125
+ checkInvoke (t , stub , [][] byte {[] byte ( "invoke" ), [] byte ( example02Url ), [] byte ( "sumStoreName" ) })
126
+ checkQuery (t , stub , [][] byte {[] byte ( "query" ), [] byte ( example02Url ), [] byte ( "sumStoreName" ) }, "555" ) // example05 doesn't return JSON?
127
+ checkQuery (t , stubEx2 , [][] byte {[] byte ( "query" ), [] byte ( "a" ) }, "212" )
128
+ checkQuery (t , stubEx2 , [][] byte {[] byte ( "query" ), [] byte ( "b" ) }, "343" )
129
129
}
0 commit comments