@@ -23,8 +23,7 @@ import (
23
23
ex02 "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02"
24
24
)
25
25
26
- // chaincode_example02's hash is used here and must be updated if the example is changed
27
- var example02Url = "github.com/hyperledger/fabric/core/example/chaincode/chaincode_example02"
26
+ var chaincodeName = "ex02"
28
27
29
28
// chaincode_example05 looks like it wanted to return a JSON response to Query()
30
29
// it doesn't actually do this though, it just returns the sum value
@@ -76,7 +75,7 @@ func checkInvoke(t *testing.T, stub *shim.MockStub, args [][]byte) {
76
75
}
77
76
}
78
77
79
- func TestExample04_Init (t * testing.T ) {
78
+ func TestExample05_Init (t * testing.T ) {
80
79
scc := new (SimpleChaincode )
81
80
stub := shim .NewMockStub ("ex05" , scc )
82
81
@@ -86,44 +85,44 @@ func TestExample04_Init(t *testing.T) {
86
85
checkState (t , stub , "sumStoreName" , "432" )
87
86
}
88
87
89
- func TestExample04_Query (t * testing.T ) {
88
+ func TestExample05_Query (t * testing.T ) {
90
89
scc := new (SimpleChaincode )
91
90
stub := shim .NewMockStub ("ex05" , scc )
92
91
93
92
ccEx2 := new (ex02.SimpleChaincode )
94
- stubEx2 := shim .NewMockStub ("ex02" , ccEx2 )
93
+ stubEx2 := shim .NewMockStub (chaincodeName , ccEx2 )
95
94
checkInit (t , stubEx2 , [][]byte {[]byte ("init" ), []byte ("a" ), []byte ("111" ), []byte ("b" ), []byte ("222" )})
96
- stub .MockPeerChaincode (example02Url , stubEx2 )
95
+ stub .MockPeerChaincode (chaincodeName , stubEx2 )
97
96
98
97
checkInit (t , stub , [][]byte {[]byte ("init" ), []byte ("sumStoreName" ), []byte ("0" )})
99
98
100
99
// a + b = 111 + 222 = 333
101
- checkQuery (t , stub , [][]byte {[]byte ("query" ), []byte (example02Url ), []byte ("sumStoreName" )}, "333" ) // example05 doesn't return JSON?
100
+ checkQuery (t , stub , [][]byte {[]byte ("query" ), []byte (chaincodeName ), []byte ("sumStoreName" ), [] byte ( " " )}, "333" ) // example05 doesn't return JSON?
102
101
}
103
102
104
- func TestExample04_Invoke (t * testing.T ) {
103
+ func TestExample05_Invoke (t * testing.T ) {
105
104
scc := new (SimpleChaincode )
106
105
stub := shim .NewMockStub ("ex05" , scc )
107
106
108
107
ccEx2 := new (ex02.SimpleChaincode )
109
- stubEx2 := shim .NewMockStub ("ex02" , ccEx2 )
108
+ stubEx2 := shim .NewMockStub (chaincodeName , ccEx2 )
110
109
checkInit (t , stubEx2 , [][]byte {[]byte ("init" ), []byte ("a" ), []byte ("222" ), []byte ("b" ), []byte ("333" )})
111
- stub .MockPeerChaincode (example02Url , stubEx2 )
110
+ stub .MockPeerChaincode (chaincodeName , stubEx2 )
112
111
113
112
checkInit (t , stub , [][]byte {[]byte ("init" ), []byte ("sumStoreName" ), []byte ("0" )})
114
113
115
114
// a + b = 222 + 333 = 555
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?
115
+ checkInvoke (t , stub , [][]byte {[]byte ("invoke" ), []byte (chaincodeName ), []byte ("sumStoreName" ), [] byte ( " " )})
116
+ checkQuery (t , stub , [][]byte {[]byte ("query" ), []byte (chaincodeName ), []byte ("sumStoreName" ), [] byte ( " " )}, "555" ) // example05 doesn't return JSON?
118
117
checkQuery (t , stubEx2 , [][]byte {[]byte ("query" ), []byte ("a" )}, "222" )
119
118
checkQuery (t , stubEx2 , [][]byte {[]byte ("query" ), []byte ("b" )}, "333" )
120
119
121
120
// update A-=10 and B+=10
122
121
checkInvoke (t , stubEx2 , [][]byte {[]byte ("invoke" ), []byte ("a" ), []byte ("b" ), []byte ("10" )})
123
122
124
123
// a + b = 212 + 343 = 555
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?
124
+ checkInvoke (t , stub , [][]byte {[]byte ("invoke" ), []byte (chaincodeName ), []byte ("sumStoreName" ), [] byte ( " " )})
125
+ checkQuery (t , stub , [][]byte {[]byte ("query" ), []byte (chaincodeName ), []byte ("sumStoreName" ), [] byte ( " " )}, "555" ) // example05 doesn't return JSON?
127
126
checkQuery (t , stubEx2 , [][]byte {[]byte ("query" ), []byte ("a" )}, "212" )
128
127
checkQuery (t , stubEx2 , [][]byte {[]byte ("query" ), []byte ("b" )}, "343" )
129
128
}
0 commit comments