Skip to content

Commit

Permalink
FAB-10994 Remove chaincode spec from Launch
Browse files Browse the repository at this point in the history
Minor change to bring the chaincode spec one step closer to death in the
runtime_launcher.go file

Change-Id: Ib87bd4095883785de1895bdba475ed0e2cb6ae97
Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
  • Loading branch information
Jason Yellick committed Jul 16, 2018
1 parent 1160b11 commit 2fffd02
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions core/chaincode/chaincode_support.go
Expand Up @@ -31,7 +31,7 @@ type Runtime interface {

// Launcher is used to launch chaincode runtimes.
type Launcher interface {
Launch(context context.Context, cccid *ccprovider.CCContext, spec *pb.ChaincodeInvocationSpec) error
Launch(context context.Context, channelID, chaincodeName string) error
LaunchInit(context context.Context, cccid *ccprovider.CCContext, spec *pb.ChaincodeDeploymentSpec) error
}

Expand Down Expand Up @@ -153,7 +153,7 @@ func (cs *ChaincodeSupport) Launch(ctx context.Context, cccid *ccprovider.CCCont
// appropriate reference to ChaincodeSupport.
ctx = context.WithValue(ctx, ccintf.GetCCHandlerKey(), cs)

return cs.Launcher.Launch(ctx, cccid, spec)
return cs.Launcher.Launch(ctx, cccid.ChainID, spec.ChaincodeSpec.ChaincodeId.Name)
}

// Stop stops a chaincode if running.
Expand Down
7 changes: 3 additions & 4 deletions core/chaincode/runtime_launcher.go
Expand Up @@ -59,11 +59,10 @@ func (r *RuntimeLauncher) LaunchInit(ctx context.Context, cccid *ccprovider.CCCo
}

// Launch chaincode with the appropriate runtime.
func (r *RuntimeLauncher) Launch(ctx context.Context, cccid *ccprovider.CCContext, spec *pb.ChaincodeInvocationSpec) error {
chaincodeID := spec.GetChaincodeSpec().ChaincodeId
ccci, err := r.Lifecycle.ChaincodeContainerInfo(cccid.ChainID, chaincodeID.Name)
func (r *RuntimeLauncher) Launch(ctx context.Context, channelID, chaincodeName string) error {
ccci, err := r.Lifecycle.ChaincodeContainerInfo(channelID, chaincodeName)
if err != nil {
return errors.Wrapf(err, "failed to get deployment spec for %s", cccid.GetCanonicalName())
return errors.Wrapf(err, "[channel %s] failed to get chaincode container info for %s", channelID, chaincodeName)
}

err = r.start(ctx, ccci)
Expand Down
14 changes: 7 additions & 7 deletions core/chaincode/runtime_launcher_test.go
Expand Up @@ -92,7 +92,7 @@ var _ = Describe("RuntimeLauncher", func() {
})

It("gets the chaincode container info", func() {
err := runtimeLauncher.Launch(context.Background(), cccid, invocationSpec)
err := runtimeLauncher.Launch(context.Background(), cccid.ChainID, invocationSpec.ChaincodeSpec.Name())
Expect(err).NotTo(HaveOccurred())

Expect(fakeLifecycle.ChaincodeContainerInfoCallCount()).To(Equal(1))
Expand All @@ -102,7 +102,7 @@ var _ = Describe("RuntimeLauncher", func() {
})

It("uses the chaincode container info when starting the runtime", func() {
err := runtimeLauncher.Launch(context.Background(), cccid, invocationSpec)
err := runtimeLauncher.Launch(context.Background(), cccid.ChainID, invocationSpec.ChaincodeSpec.Name())
Expect(err).NotTo(HaveOccurred())

Expect(fakeRuntime.StartCallCount()).To(Equal(1))
Expand All @@ -118,8 +118,8 @@ var _ = Describe("RuntimeLauncher", func() {
})

It("returns a wrapped error", func() {
err := runtimeLauncher.Launch(context.Background(), cccid, invocationSpec)
Expect(err).To(MatchError(MatchRegexp("failed to get deployment spec for context-name:context-version: king-kong")))
err := runtimeLauncher.Launch(context.Background(), cccid.ChainID, invocationSpec.ChaincodeSpec.Name())
Expect(err).To(MatchError("[channel chain-id] failed to get chaincode container info for chaincode-name: king-kong"))
})
})

Expand All @@ -128,7 +128,7 @@ var _ = Describe("RuntimeLauncher", func() {
})

It("gets the package from the package provider", func() {
err := runtimeLauncher.Launch(context.Background(), cccid, invocationSpec)
err := runtimeLauncher.Launch(context.Background(), cccid.ChainID, invocationSpec.ChaincodeSpec.Name())
Expect(err).NotTo(HaveOccurred())

Expect(fakePackageProvider.GetChaincodeCodePackageCallCount()).To(Equal(1))
Expand All @@ -143,7 +143,7 @@ var _ = Describe("RuntimeLauncher", func() {
})

It("returns a wrapped error", func() {
err := runtimeLauncher.Launch(context.Background(), cccid, invocationSpec)
err := runtimeLauncher.Launch(context.Background(), cccid.ChainID, invocationSpec.ChaincodeSpec.Name())
Expect(err).To(MatchError("failed to get chaincode package: tangerine"))
})
})
Expand All @@ -155,7 +155,7 @@ var _ = Describe("RuntimeLauncher", func() {
})

It("does not get the codepackage", func() {
err := runtimeLauncher.Launch(context.Background(), cccid, invocationSpec)
err := runtimeLauncher.Launch(context.Background(), cccid.ChainID, invocationSpec.ChaincodeSpec.Name())
Expect(err).NotTo(HaveOccurred())
Expect(fakePackageProvider.GetChaincodeCodePackageCallCount()).To(Equal(0))
})
Expand Down

0 comments on commit 2fffd02

Please sign in to comment.