Skip to content

Commit

Permalink
Merge pull request #45 from hyperledger-labs/bump-to-go-1-21
Browse files Browse the repository at this point in the history
Bump Go version to 1.21
  • Loading branch information
samuelvenzi authored Jun 26, 2024
2 parents 3c78ac1 + 10894c1 commit a32bd38
Show file tree
Hide file tree
Showing 19 changed files with 229 additions and 425 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: 1.21

- name: Build
run: go build -v ./...
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
[![Go Report Card](https://goreportcard.com/badge/github.com/hyperledger-labs/cc-tools)](https://goreportcard.com/report/github.com/hyperledger-labs/cc-tools)
[![GoDoc](https://godoc.org/github.com/hyperledger-labs/cc-tools?status.svg)](https://godoc.org/github.com/hyperledger-labs/cc-tools)

This project is a GoLedger open-source project aimed at providing tools for Hyperledger Fabric chaincode development in Golang. This might have breaking changes before we arrive at release v1.0.0.
This project is a GoLedger open-source project aimed at providing tools for Hyperledger Fabric chaincode development in Golang.

## Getting Started

Make sure you visit the repository [hyperledger-labs/cc-tools-demo](https://github.com/hyperledger-labs/cc-tools-demo), which is a template of a functional chaincode that uses cc-tools and provides ready-to-use scripts to deploy development networks. This is our preferred way of working, but you can feel free to import the package and assemble the chaincode as you choose.

CC Tools has been tested with Hyperledger Fabric 1.x and 2.x realeases.
CC Tools has been tested with Hyperledger Fabric v2.2, v2.4 and v2.5 releases.

## Features
- Standard asset data mapping (and their properties)
Expand Down
3 changes: 0 additions & 3 deletions assets/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ func get(stub *sw.StubWrapper, pvtCollection, key string, committed bool) (*Asse
return nil, errors.WrapErrorWithStatus(err, "failed to unmarshal asset from ledger", 500)
}

delete(response, "@lastTouchBy")

return &response, nil
}

Expand Down Expand Up @@ -181,7 +179,6 @@ func getRecursive(stub *sw.StubWrapper, pvtCollection, key string, keysChecked [
return nil, errors.WrapErrorWithStatus(err, "failed to unmarshal asset from ledger", 500)
}

delete(response, "@lastTouchBy")
keysCheckedInScope := make([]string, 0)

for k, v := range response {
Expand Down
2 changes: 0 additions & 2 deletions assets/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ func (a *Asset) put(stub *sw.StubWrapper) (map[string]interface{}, errors.ICCErr
return nil, errors.WrapError(err, "failed to write asset to ledger")
}

delete(*a, "@lastTouchBy")

return *a, nil
}

Expand Down
2 changes: 0 additions & 2 deletions assets/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ func Search(stub *sw.StubWrapper, request map[string]interface{}, privateCollect
data = asset
}

delete(data, "@lastTouchBy")

searchResult = append(searchResult, data)
}

Expand Down
31 changes: 19 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
module github.com/hyperledger-labs/cc-tools

go 1.14
go 1.21

require (
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/golang/protobuf v1.4.3
github.com/google/go-cmp v0.5.4 // indirect
github.com/golang/protobuf v1.5.3
github.com/google/uuid v1.3.0
github.com/hyperledger/fabric v2.1.1+incompatible
github.com/hyperledger/fabric-chaincode-go v0.0.0-20210603161043-af0e3898842a
github.com/hyperledger/fabric-protos-go v0.0.0-20210528200356-82833ecdac31
github.com/stretchr/testify v1.6.1
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/miekg/pkcs11 v1.0.3 // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/viper v1.7.1 // indirect
github.com/stretchr/testify v1.6.1
github.com/sykesm/zap-logfmt v0.0.4 // indirect
go.uber.org/atomic v1.6.0 // indirect
go.uber.org/multierr v1.5.0 // indirect
go.uber.org/zap v1.16.0 // indirect
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b // indirect
golang.org/x/net v0.0.0-20210119194325-5f4716e94777 // indirect
golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/grpc v1.35.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/grpc v1.56.3 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
93 changes: 28 additions & 65 deletions go.sum

Large diffs are not rendered by default.

61 changes: 31 additions & 30 deletions test/assets_get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ func TestGetAsset(t *testing.T) {

// State setup
expectedResponse := assets.Asset{
"@key": "person:47061146-c642-51a1-844a-bf0b17cb5e19",
"@lastTx": "createAsset",
"@assetType": "person",
"name": "Maria",
"id": "31820792048",
"height": 0.0,
"@key": "person:47061146-c642-51a1-844a-bf0b17cb5e19",
"@lastTouchBy": "org1MSP",
"@lastTx": "createAsset",
"@assetType": "person",
"name": "Maria",
"id": "31820792048",
"height": 0.0,
}
stub.MockTransactionStart("setupGetAsset")
setupState, _ := json.Marshal(expectedResponse)
Expand Down Expand Up @@ -92,9 +93,6 @@ func TestGetManyAssets(t *testing.T) {
stub.PutState("person:916c708a-1d6c-5c4f-8f12-d9d36f2aad27", setupState)
stub.MockTransactionEnd("setupGetManyAssets")

delete(asset1, "@lastTouchBy")
delete(asset2, "@lastTouchBy")
delete(asset3, "@lastTouchBy")
expectedResponse := []*assets.Asset{&asset1, &asset2, &asset3}

assetKeys := []assets.Key{
Expand Down Expand Up @@ -163,7 +161,6 @@ func TestGetCommittedAsset(t *testing.T) {
t.FailNow()
}

delete(expectedResponse, "@lastTouchBy")
if !reflect.DeepEqual(*gotAsset, expectedResponse) {
log.Println("these should be deeply equal")
log.Println(expectedResponse)
Expand Down Expand Up @@ -219,18 +216,20 @@ func TestGetRecursive(t *testing.T) {
"@key": "book:a36a2920-c405-51c3-b584-dcd758338cb5",
}
expectedResponse := map[string]interface{}{
"@key": "book:a36a2920-c405-51c3-b584-dcd758338cb5",
"@lastTx": "createAsset",
"@assetType": "book",
"title": "Meu Nome é Maria",
"author": "Maria Viana",
"@key": "book:a36a2920-c405-51c3-b584-dcd758338cb5",
"@lastTouchBy": "org2MSP",
"@lastTx": "createAsset",
"@assetType": "book",
"title": "Meu Nome é Maria",
"author": "Maria Viana",
"currentTenant": map[string]interface{}{
"@key": "person:47061146-c642-51a1-844a-bf0b17cb5e19",
"@lastTx": "createAsset",
"@assetType": "person",
"name": "Maria",
"id": "31820792048",
"height": 0.0,
"@key": "person:47061146-c642-51a1-844a-bf0b17cb5e19",
"@lastTouchBy": "org1MSP",
"@lastTx": "createAsset",
"@assetType": "person",
"name": "Maria",
"id": "31820792048",
"height": 0.0,
},
"genres": []interface{}{"biography", "non-fiction"},
"published": "2019-05-06T22:12:41Z",
Expand Down Expand Up @@ -296,16 +295,18 @@ func TestGetRecursiveWithPvtData(t *testing.T) {
"@key": "library:37262f3f-5f08-5649-b488-e5abaad266e1",
}
expectedResponse := map[string]interface{}{
"@assetType": "library",
"@key": "library:37262f3f-5f08-5649-b488-e5abaad266e1",
"@lastTx": "createAsset",
"name": "Biblioteca Maria da Silva",
"@assetType": "library",
"@key": "library:37262f3f-5f08-5649-b488-e5abaad266e1",
"@lastTouchBy": "org3MSP",
"@lastTx": "createAsset",
"name": "Biblioteca Maria da Silva",
"entranceCode": map[string]interface{}{
"@assetType": "secret",
"@key": "secret:73a3f9a7-eb91-5f4d-b1bb-c0487e90f40b",
"@lastTx": "createAsset",
"secretName": "testSecret",
"secret": "this is very secret",
"@assetType": "secret",
"@key": "secret:73a3f9a7-eb91-5f4d-b1bb-c0487e90f40b",
"@lastTouchBy": "org2MSP",
"@lastTx": "createAsset",
"secretName": "testSecret",
"secret": "this is very secret",
},
}

Expand Down
Loading

0 comments on commit a32bd38

Please sign in to comment.