@@ -34,6 +34,7 @@ var _ = Describe("RuntimeLauncher", func() {
34
34
proposal * pb.Proposal
35
35
chaincodeID * pb.ChaincodeID
36
36
deploymentSpec * pb.ChaincodeDeploymentSpec
37
+ ccci * lc.ChaincodeContainerInfo
37
38
38
39
runtimeLauncher * chaincode.RuntimeLauncher
39
40
@@ -122,57 +123,32 @@ var _ = Describe("RuntimeLauncher", func() {
122
123
Expect (err ).To (MatchError ("[channel chain-id] failed to get chaincode container info for chaincode-name: king-kong" ))
123
124
})
124
125
})
126
+ })
125
127
126
- Context ("when the returned deployment spec has a nil chaincode package" , func () {
127
- BeforeEach (func () {
128
- })
129
-
130
- It ("gets the package from the package provider" , func () {
131
- err := runtimeLauncher .Launch (context .Background (), cccid .ChainID , invocationSpec .ChaincodeSpec .Name ())
132
- Expect (err ).NotTo (HaveOccurred ())
133
-
134
- Expect (fakePackageProvider .GetChaincodeCodePackageCallCount ()).To (Equal (1 ))
135
- name , version := fakePackageProvider .GetChaincodeCodePackageArgsForCall (0 )
136
- Expect (name ).To (Equal ("info-name" ))
137
- Expect (version ).To (Equal ("info-version" ))
138
- })
139
-
140
- Context ("when getting the package fails" , func () {
141
- BeforeEach (func () {
142
- fakePackageProvider .GetChaincodeCodePackageReturns (nil , errors .New ("tangerine" ))
143
- })
144
-
145
- It ("returns a wrapped error" , func () {
146
- err := runtimeLauncher .Launch (context .Background (), cccid .ChainID , invocationSpec .ChaincodeSpec .Name ())
147
- Expect (err ).To (MatchError ("failed to get chaincode package: tangerine" ))
148
- })
149
- })
128
+ Context ("when launch is provided with a deployment spec" , func () {
129
+ BeforeEach (func () {
130
+ deploymentSpec .CodePackage = []byte ("code-package" )
131
+ ccci = lc .DeploymentSpecToChaincodeContainerInfo (deploymentSpec )
150
132
})
151
133
152
- Context ("when launching a system chaincode" , func () {
153
- BeforeEach (func () {
154
- ccciReturnValue .ContainerType = "SYSTEM"
155
- })
156
-
157
- It ("does not get the codepackage" , func () {
158
- err := runtimeLauncher .Launch (context .Background (), cccid .ChainID , invocationSpec .ChaincodeSpec .Name ())
159
- Expect (err ).NotTo (HaveOccurred ())
160
- Expect (fakePackageProvider .GetChaincodeCodePackageCallCount ()).To (Equal (0 ))
161
- })
134
+ It ("does not get the deployment spec from lifecycle" , func () {
135
+ err := runtimeLauncher .LaunchInit (context .Background (), ccci )
136
+ Expect (err ).NotTo (HaveOccurred ())
137
+ Expect (fakeLifecycle .ChaincodeContainerInfoCallCount ()).To (Equal (0 ))
162
138
})
163
139
})
164
140
165
141
It ("registers the chaincode as launching" , func () {
166
- err := runtimeLauncher .LaunchInit (context .Background (), cccid , deploymentSpec )
142
+ err := runtimeLauncher .LaunchInit (context .Background (), ccci )
167
143
Expect (err ).NotTo (HaveOccurred ())
168
144
169
145
Expect (fakeRegistry .LaunchingCallCount ()).To (Equal (1 ))
170
146
cname := fakeRegistry .LaunchingArgsForCall (0 )
171
- Expect (cname ).To (Equal ("chaincode-name:context -version" ))
147
+ Expect (cname ).To (Equal ("chaincode-name:chaincode -version" ))
172
148
})
173
149
174
150
It ("starts the runtime for the chaincode" , func () {
175
- err := runtimeLauncher .LaunchInit (context .Background (), cccid , deploymentSpec )
151
+ err := runtimeLauncher .LaunchInit (context .Background (), ccci )
176
152
Expect (err ).NotTo (HaveOccurred ())
177
153
178
154
Expect (fakeRuntime .StartCallCount ()).To (Equal (1 ))
@@ -182,7 +158,7 @@ var _ = Describe("RuntimeLauncher", func() {
182
158
Name : deploymentSpec .Name (),
183
159
Path : deploymentSpec .Path (),
184
160
Type : deploymentSpec .CCType (),
185
- Version : cccid .Version ,
161
+ Version : deploymentSpec .Version () ,
186
162
ContainerType : "DOCKER" ,
187
163
}))
188
164
Expect (codePackage ).To (Equal ([]byte ("code-package" )))
@@ -192,15 +168,15 @@ var _ = Describe("RuntimeLauncher", func() {
192
168
fakeRuntime .StartReturns (nil )
193
169
194
170
errCh := make (chan error , 1 )
195
- go func () { errCh <- runtimeLauncher .LaunchInit (context .Background (), cccid , deploymentSpec ) }()
171
+ go func () { errCh <- runtimeLauncher .LaunchInit (context .Background (), ccci ) }()
196
172
197
173
Consistently (errCh ).ShouldNot (Receive ())
198
174
launchState .Notify (nil )
199
175
Eventually (errCh ).Should (Receive (BeNil ()))
200
176
})
201
177
202
178
It ("does not deregister the chaincode" , func () {
203
- err := runtimeLauncher .LaunchInit (context .Background (), cccid , deploymentSpec )
179
+ err := runtimeLauncher .LaunchInit (context .Background (), ccci )
204
180
Expect (err ).NotTo (HaveOccurred ())
205
181
206
182
Expect (fakeRegistry .DeregisterCallCount ()).To (Equal (0 ))
@@ -212,8 +188,8 @@ var _ = Describe("RuntimeLauncher", func() {
212
188
})
213
189
214
190
It ("returns an error" , func () {
215
- err := runtimeLauncher .LaunchInit (context .Background (), cccid , deploymentSpec )
216
- Expect (err ).To (MatchError ("failed to register chaincode-name:context -version as launching: gargoyle" ))
191
+ err := runtimeLauncher .LaunchInit (context .Background (), ccci )
192
+ Expect (err ).To (MatchError ("failed to register chaincode-name:chaincode -version as launching: gargoyle" ))
217
193
})
218
194
})
219
195
@@ -223,12 +199,12 @@ var _ = Describe("RuntimeLauncher", func() {
223
199
})
224
200
225
201
It ("returns a wrapped error" , func () {
226
- err := runtimeLauncher .LaunchInit (context .Background (), cccid , deploymentSpec )
202
+ err := runtimeLauncher .LaunchInit (context .Background (), ccci )
227
203
Expect (err ).To (MatchError ("error starting container: banana" ))
228
204
})
229
205
230
206
It ("stops the runtime" , func () {
231
- runtimeLauncher .LaunchInit (context .Background (), cccid , deploymentSpec )
207
+ runtimeLauncher .LaunchInit (context .Background (), ccci )
232
208
233
209
Expect (fakeRuntime .StopCallCount ()).To (Equal (1 ))
234
210
ctx , ccci := fakeRuntime .StopArgsForCall (0 )
@@ -237,17 +213,17 @@ var _ = Describe("RuntimeLauncher", func() {
237
213
Name : deploymentSpec .Name (),
238
214
Path : deploymentSpec .Path (),
239
215
Type : deploymentSpec .CCType (),
240
- Version : cccid .Version ,
216
+ Version : deploymentSpec .Version () ,
241
217
ContainerType : "DOCKER" ,
242
218
}))
243
219
})
244
220
245
221
It ("deregisters the chaincode" , func () {
246
- runtimeLauncher .LaunchInit (context .Background (), cccid , deploymentSpec )
222
+ runtimeLauncher .LaunchInit (context .Background (), ccci )
247
223
248
224
Expect (fakeRegistry .DeregisterCallCount ()).To (Equal (1 ))
249
225
cname := fakeRegistry .DeregisterArgsForCall (0 )
250
- Expect (cname ).To (Equal ("chaincode-name:context -version" ))
226
+ Expect (cname ).To (Equal ("chaincode-name:chaincode -version" ))
251
227
})
252
228
})
253
229
@@ -260,12 +236,12 @@ var _ = Describe("RuntimeLauncher", func() {
260
236
})
261
237
262
238
It ("returns an error" , func () {
263
- err := runtimeLauncher .LaunchInit (context .Background (), cccid , deploymentSpec )
239
+ err := runtimeLauncher .LaunchInit (context .Background (), ccci )
264
240
Expect (err ).To (MatchError ("chaincode registration failed: papaya" ))
265
241
})
266
242
267
243
It ("stops the runtime" , func () {
268
- runtimeLauncher .LaunchInit (context .Background (), cccid , deploymentSpec )
244
+ runtimeLauncher .LaunchInit (context .Background (), ccci )
269
245
270
246
Expect (fakeRuntime .StopCallCount ()).To (Equal (1 ))
271
247
ctx , ccci := fakeRuntime .StopArgsForCall (0 )
@@ -274,17 +250,17 @@ var _ = Describe("RuntimeLauncher", func() {
274
250
Name : deploymentSpec .Name (),
275
251
Path : deploymentSpec .Path (),
276
252
Type : deploymentSpec .CCType (),
277
- Version : cccid .Version ,
253
+ Version : deploymentSpec .Version () ,
278
254
ContainerType : "DOCKER" ,
279
255
}))
280
256
})
281
257
282
258
It ("deregisters the chaincode" , func () {
283
- runtimeLauncher .LaunchInit (context .Background (), cccid , deploymentSpec )
259
+ runtimeLauncher .LaunchInit (context .Background (), ccci )
284
260
285
261
Expect (fakeRegistry .DeregisterCallCount ()).To (Equal (1 ))
286
262
cname := fakeRegistry .DeregisterArgsForCall (0 )
287
- Expect (cname ).To (Equal ("chaincode-name:context -version" ))
263
+ Expect (cname ).To (Equal ("chaincode-name:chaincode -version" ))
288
264
})
289
265
})
290
266
@@ -295,12 +271,12 @@ var _ = Describe("RuntimeLauncher", func() {
295
271
})
296
272
297
273
It ("returns a meaningful error" , func () {
298
- err := runtimeLauncher .LaunchInit (context .Background (), cccid , deploymentSpec )
299
- Expect (err ).To (MatchError ("timeout expired while starting chaincode chaincode-name:context -version for transaction" ))
274
+ err := runtimeLauncher .LaunchInit (context .Background (), ccci )
275
+ Expect (err ).To (MatchError ("timeout expired while starting chaincode chaincode-name:chaincode -version for transaction" ))
300
276
})
301
277
302
278
It ("stops the runtime" , func () {
303
- runtimeLauncher .LaunchInit (context .Background (), cccid , deploymentSpec )
279
+ runtimeLauncher .LaunchInit (context .Background (), ccci )
304
280
305
281
Expect (fakeRuntime .StopCallCount ()).To (Equal (1 ))
306
282
ctx , ccci := fakeRuntime .StopArgsForCall (0 )
@@ -309,17 +285,17 @@ var _ = Describe("RuntimeLauncher", func() {
309
285
Name : deploymentSpec .Name (),
310
286
Path : deploymentSpec .Path (),
311
287
Type : deploymentSpec .CCType (),
312
- Version : cccid .Version ,
288
+ Version : deploymentSpec .Version () ,
313
289
ContainerType : "DOCKER" ,
314
290
}))
315
291
})
316
292
317
293
It ("deregisters the chaincode" , func () {
318
- runtimeLauncher .LaunchInit (context .Background (), cccid , deploymentSpec )
294
+ runtimeLauncher .LaunchInit (context .Background (), ccci )
319
295
320
296
Expect (fakeRegistry .DeregisterCallCount ()).To (Equal (1 ))
321
297
cname := fakeRegistry .DeregisterArgsForCall (0 )
322
- Expect (cname ).To (Equal ("chaincode-name:context -version" ))
298
+ Expect (cname ).To (Equal ("chaincode-name:chaincode -version" ))
323
299
})
324
300
})
325
301
@@ -330,7 +306,7 @@ var _ = Describe("RuntimeLauncher", func() {
330
306
})
331
307
332
308
It ("preserves the initial error" , func () {
333
- err := runtimeLauncher .LaunchInit (context .Background (), cccid , deploymentSpec )
309
+ err := runtimeLauncher .LaunchInit (context .Background (), ccci )
334
310
Expect (err ).To (MatchError ("error starting container: whirled-peas" ))
335
311
Expect (fakeRuntime .StopCallCount ()).To (Equal (1 ))
336
312
})
0 commit comments