-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-4590] Auto-vendor all deps properly
It was noted that the auto-vendoring mechanism introduced in CR 6991 was failing to vendor dependencies properly. Investigating, it was root-caused that we were only auto- vendoring transitive dependencies, not direct imports. This patch corrects this by merging the direct imports into our dependency tree. Fix was verified by adding the unit-test, verifying that it fails, and subsequently verifying that it passes after the fix was applied. Credit to Rahul Hegde <rhegde@cls-bank.com> for finding the issue and proposing the proper fix that inspired this patch. Fixes FAB-4590 Change-Id: Ie0631ac1033c3f427ea42c43eccf76a0f7390320 Signed-off-by: Greg Haskins <gregory.haskins@gmail.com>
- Loading branch information
Showing
5 changed files
with
90 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright Greg Haskins All Rights Reserved | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The purpose of this test code is to prove that the system properly packages | ||
* up dependencies. We therefore synthesize the scenario where a chaincode | ||
* imports non-standard dependencies both directly and indirectly and then | ||
* expect a unit-test to verify that the package includes everything needed | ||
* and ultimately builds properly. | ||
* | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hyperledger/fabric/core/chaincode/shim" | ||
pb "github.com/hyperledger/fabric/protos/peer" | ||
"github.com/hyperledger/fabric/test/chaincodes/AutoVendor/directdep" | ||
) | ||
|
||
// SimpleChaincode example simple Chaincode implementation | ||
type SimpleChaincode struct { | ||
} | ||
|
||
func (t *SimpleChaincode) Init(stub shim.ChaincodeStubInterface) pb.Response { | ||
return shim.Error("NOT IMPL") | ||
} | ||
|
||
func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response { | ||
return shim.Error("NOT IMPL") | ||
} | ||
|
||
func main() { | ||
directdep.PointlessFunction() | ||
|
||
err := shim.Start(new(SimpleChaincode)) | ||
if err != nil { | ||
fmt.Printf("Error starting Simple chaincode: %s", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright Greg Haskins All Rights Reserved | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* See github.com/hyperledger/fabric/test/chaincodes/AutoVendor/chaincode/main.go for details | ||
*/ | ||
package directdep | ||
|
||
import ( | ||
"github.com/hyperledger/fabric/test/chaincodes/AutoVendor/indirectdep" | ||
) | ||
|
||
func PointlessFunction() { | ||
// delegate to our indirect dependency | ||
indirectdep.PointlessFunction() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright Greg Haskins All Rights Reserved | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* See github.com/hyperledger/fabric/test/chaincodes/AutoVendor/chaincode/main.go for details | ||
*/ | ||
package indirectdep | ||
|
||
import "fmt" | ||
|
||
func PointlessFunction() { | ||
fmt.Printf("Successfully invoked pointless function\n") | ||
} |