Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
bandreghetti committed Jul 14, 2021
1 parent c5f622e commit 240541a
Show file tree
Hide file tree
Showing 23 changed files with 81 additions and 252 deletions.
4 changes: 2 additions & 2 deletions assets/existsInLedger.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package assets
import (
"github.com/goledgerdev/cc-tools/errors"
sw "github.com/goledgerdev/cc-tools/stubwrapper"
"github.com/hyperledger/fabric/core/chaincode/shim"
"github.com/hyperledger/fabric-chaincode-go/shimtest"
)

func existsInLedger(stub *sw.StubWrapper, isPrivate bool, typeTag, key string) (bool, errors.ICCError) {
var assetBytes []byte
var err error
if isPrivate {
_, isMock := stub.Stub.(*shim.MockStub)
_, isMock := stub.Stub.(*shimtest.MockStub)
if isMock {
assetBytes, err = stub.GetPrivateData(typeTag, key)
} else {
Expand Down
2 changes: 1 addition & 1 deletion errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package errors
import (
"errors"

"github.com/hyperledger/fabric/protos/peer"
"github.com/hyperledger/fabric-protos-go/peer"
)

// ICCError Interface implements an error interface.
Expand Down
26 changes: 15 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,28 @@ module github.com/goledgerdev/cc-tools
go 1.14

require (
github.com/Knetic/govaluate v3.0.0+incompatible // indirect
github.com/Shopify/sarama v1.27.2 // indirect
github.com/fsouza/go-dockerclient v1.7.0 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/golang/protobuf v1.4.3 // indirect
github.com/google/uuid v1.1.2
github.com/grpc-ecosystem/go-grpc-middleware v1.2.2 // indirect
github.com/hashicorp/go-version v1.2.1 // indirect
github.com/hyperledger/fabric v1.4.8
github.com/hyperledger/fabric-amcl v0.0.0-20200424173818-327c9e2cf77a // indirect
github.com/google/go-cmp v0.5.4 // indirect
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/kr/text v0.2.0 // indirect
github.com/miekg/pkcs11 v1.0.3 // indirect
github.com/onsi/ginkgo v1.14.2 // indirect
github.com/onsi/gomega v1.10.4 // indirect
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/spf13/viper v1.7.1 // indirect
github.com/stretchr/testify v1.6.1 // indirect
github.com/sykesm/zap-logfmt v0.0.4 // 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
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-20200615113413-eeeca48fe776 // indirect
)
200 changes: 12 additions & 188 deletions go.sum

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions stubwrapper/stubWrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package stubwrapper

import (
"github.com/goledgerdev/cc-tools/errors"
"github.com/hyperledger/fabric-chaincode-go/pkg/cid"
"github.com/hyperledger/fabric-chaincode-go/shim"
"github.com/hyperledger/fabric-chaincode-go/shimtest"
pb "github.com/hyperledger/fabric-protos-go/peer"
"github.com/hyperledger/fabric/common/util"
"github.com/hyperledger/fabric/core/chaincode/shim"
"github.com/hyperledger/fabric/core/chaincode/shim/ext/cid"
pb "github.com/hyperledger/fabric/protos/peer"
)

type StubWrapper struct {
Expand Down Expand Up @@ -181,7 +182,7 @@ func (sw *StubWrapper) GetHistoryForKey(key string) (shim.HistoryQueryIteratorIn

// GetMSPID wraps cid.GetMSPID allowing for automated testing
func (sw *StubWrapper) GetMSPID() (string, errors.ICCError) {
mockStub, isMock := sw.Stub.(*shim.MockStub)
mockStub, isMock := sw.Stub.(*shimtest.MockStub)
if isMock {
return mockStub.Name, nil
}
Expand Down
4 changes: 2 additions & 2 deletions test/assets_checkWriters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (

"github.com/goledgerdev/cc-tools/assets"
sw "github.com/goledgerdev/cc-tools/stubwrapper"
"github.com/hyperledger/fabric/core/chaincode/shim"
"github.com/hyperledger/fabric-chaincode-go/shimtest"
)

func TestCheckWriters(t *testing.T) {
stub := shim.NewMockStub("org1MSP", new(testCC))
stub := shimtest.NewMockStub("org1MSP", new(testCC))
sw := &sw.StubWrapper{
Stub: stub,
}
Expand Down
4 changes: 2 additions & 2 deletions test/assets_delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (

"github.com/goledgerdev/cc-tools/assets"
sw "github.com/goledgerdev/cc-tools/stubwrapper"
"github.com/hyperledger/fabric/core/chaincode/shim"
"github.com/hyperledger/fabric-chaincode-go/shimtest"
)

func TestDeleteWithRef(t *testing.T) {
stub := shim.NewMockStub("org1MSP", new(testCC))
stub := shimtest.NewMockStub("org1MSP", new(testCC))

// State setup
setupPerson := map[string]interface{}{
Expand Down
8 changes: 4 additions & 4 deletions test/assets_get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (

"github.com/goledgerdev/cc-tools/assets"
sw "github.com/goledgerdev/cc-tools/stubwrapper"
"github.com/hyperledger/fabric/core/chaincode/shim"
"github.com/hyperledger/fabric-chaincode-go/shimtest"
)

func TestGetAsset(t *testing.T) {
stub := shim.NewMockStub("org1MSP", new(testCC))
stub := shimtest.NewMockStub("org1MSP", new(testCC))

// State setup
expectedResponse := assets.Asset{
Expand Down Expand Up @@ -51,7 +51,7 @@ func TestGetAsset(t *testing.T) {
}

func TestGetRecursive(t *testing.T) {
stub := shim.NewMockStub("org1MSP", new(testCC))
stub := shimtest.NewMockStub("org1MSP", new(testCC))

// State setup
setupPerson := map[string]interface{}{
Expand Down Expand Up @@ -134,7 +134,7 @@ func TestGetRecursive(t *testing.T) {
}

func TestGetRecursiveWithPvtData(t *testing.T) {
stub := shim.NewMockStub("org1MSP", new(testCC))
stub := shimtest.NewMockStub("org1MSP", new(testCC))

// State setup
setupSecret := map[string]interface{}{
Expand Down
8 changes: 4 additions & 4 deletions test/assets_put_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (

"github.com/goledgerdev/cc-tools/assets"
sw "github.com/goledgerdev/cc-tools/stubwrapper"
"github.com/hyperledger/fabric/core/chaincode/shim"
"github.com/hyperledger/fabric-chaincode-go/shimtest"
)

func TestPutAsset(t *testing.T) {
stub := shim.NewMockStub("org1MSP", new(testCC))
stub := shimtest.NewMockStub("org1MSP", new(testCC))
person := assets.Asset{
"@assetType": "person",
"name": "Maria",
Expand Down Expand Up @@ -56,7 +56,7 @@ func TestPutAsset(t *testing.T) {
}

func TestPutAssetWithSubAsset(t *testing.T) {
stub := shim.NewMockStub("org1MSP", new(testCC))
stub := shimtest.NewMockStub("org1MSP", new(testCC))

// State setup
setupPerson := map[string]interface{}{
Expand Down Expand Up @@ -123,7 +123,7 @@ func TestPutAssetWithSubAsset(t *testing.T) {
}

func TestPutAssetRecursive(t *testing.T) {
stub := shim.NewMockStub("org1MSP", new(testCC))
stub := shimtest.NewMockStub("org1MSP", new(testCC))

stub.MockTransactionStart("TestPutAsset")
sw := &sw.StubWrapper{
Expand Down
4 changes: 2 additions & 2 deletions test/chaincode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"github.com/goledgerdev/cc-tools/assets"
"github.com/goledgerdev/cc-tools/errors"
tx "github.com/goledgerdev/cc-tools/transactions"
"github.com/hyperledger/fabric/core/chaincode/shim"
pb "github.com/hyperledger/fabric/protos/peer"
"github.com/hyperledger/fabric-chaincode-go/shim"
pb "github.com/hyperledger/fabric-protos-go/peer"
)

// testCC implements the shim.Chaincode interface
Expand Down
4 changes: 2 additions & 2 deletions test/tryout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
"log"
"testing"

"github.com/hyperledger/fabric/core/chaincode/shim"
"github.com/hyperledger/fabric-chaincode-go/shimtest"
)

func TestTryout(t *testing.T) {
var err error
stub := shim.NewMockStub("org1MSP", new(testCC))
stub := shimtest.NewMockStub("org1MSP", new(testCC))

// Create Asset
reqPerson := map[string]interface{}{
Expand Down
8 changes: 4 additions & 4 deletions test/tx_createAsset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"reflect"
"testing"

"github.com/hyperledger/fabric/core/chaincode/shim"
"github.com/hyperledger/fabric-chaincode-go/shimtest"
)

func TestCreateAsset(t *testing.T) {
stub := shim.NewMockStub("org1MSP", new(testCC))
stub := shimtest.NewMockStub("org1MSP", new(testCC))
person := map[string]interface{}{
"@assetType": "person",
"name": "Maria",
Expand Down Expand Up @@ -79,7 +79,7 @@ func TestCreateAsset(t *testing.T) {
}

func TestCreateAssetEmptyList(t *testing.T) {
stub := shim.NewMockStub("org1MSP", new(testCC))
stub := shimtest.NewMockStub("org1MSP", new(testCC))

req := map[string]interface{}{
"asset": []map[string]interface{}{},
Expand All @@ -106,7 +106,7 @@ func TestCreateAssetEmptyList(t *testing.T) {
}

func TestCreatePrivate(t *testing.T) {
stub := shim.NewMockStub("org2MSP", new(testCC))
stub := shimtest.NewMockStub("org2MSP", new(testCC))
secret := map[string]interface{}{
"@assetType": "secret",
"secretName": "testSecret",
Expand Down
6 changes: 3 additions & 3 deletions test/tx_deleteAsset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"reflect"
"testing"

"github.com/hyperledger/fabric/core/chaincode/shim"
"github.com/hyperledger/fabric-chaincode-go/shimtest"
)

func TestDeleteAsset(t *testing.T) {
stub := shim.NewMockStub("org1MSP", new(testCC))
stub := shimtest.NewMockStub("org1MSP", new(testCC))

// State setup
expectedResponse := map[string]interface{}{
Expand Down Expand Up @@ -76,7 +76,7 @@ func TestDeleteAsset(t *testing.T) {
}

func TestDeleteCascade(t *testing.T) {
stub := shim.NewMockStub("org1MSP", new(testCC))
stub := shimtest.NewMockStub("org1MSP", new(testCC))

// State setup
setupPerson := map[string]interface{}{
Expand Down
4 changes: 2 additions & 2 deletions test/tx_getDataTypes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"log"
"testing"

"github.com/hyperledger/fabric/core/chaincode/shim"
"github.com/hyperledger/fabric-chaincode-go/shimtest"
)

func TestGetDataTypes(t *testing.T) {
stub := shim.NewMockStub("testcc", new(testCC))
stub := shimtest.NewMockStub("testcc", new(testCC))

expectedResponse := map[string]interface{}{
"boolean": map[string]interface{}{
Expand Down
4 changes: 2 additions & 2 deletions test/tx_getHeader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"log"
"testing"

"github.com/hyperledger/fabric/core/chaincode/shim"
"github.com/hyperledger/fabric-chaincode-go/shimtest"
)

func TestGetHeader(t *testing.T) {
stub := shim.NewMockStub("org1MSP", new(testCC))
stub := shimtest.NewMockStub("org1MSP", new(testCC))

expectedResponse := map[string]interface{}{
"ccToolsVersion": "v0.7.0",
Expand Down
6 changes: 3 additions & 3 deletions test/tx_getSchema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"log"
"testing"

"github.com/hyperledger/fabric/core/chaincode/shim"
"github.com/hyperledger/fabric-chaincode-go/shimtest"
)

func TestGetSchema(t *testing.T) {
stub := shim.NewMockStub("org1MSP", new(testCC))
stub := shimtest.NewMockStub("org1MSP", new(testCC))

expectedResponse := []interface{}{
map[string]interface{}{
Expand Down Expand Up @@ -109,7 +109,7 @@ func TestGetSchema(t *testing.T) {
}

func TestGetSchema404(t *testing.T) {
stub := shim.NewMockStub("org1MSP", new(testCC))
stub := shimtest.NewMockStub("org1MSP", new(testCC))

req := map[string]interface{}{
"assetType": "inexistentAsset",
Expand Down
8 changes: 4 additions & 4 deletions test/tx_getTx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"log"
"testing"

"github.com/hyperledger/fabric/core/chaincode/shim"
"github.com/hyperledger/fabric-chaincode-go/shimtest"
)

func TestGetTx(t *testing.T) {
stub := shim.NewMockStub("testcc", new(testCC))
stub := shimtest.NewMockStub("testcc", new(testCC))

expectedResponse := []interface{}{
map[string]interface{}{
Expand Down Expand Up @@ -97,7 +97,7 @@ func TestGetTx(t *testing.T) {
}

func TestGetTx404(t *testing.T) {
stub := shim.NewMockStub("org1MSP", new(testCC))
stub := shimtest.NewMockStub("org1MSP", new(testCC))

req := map[string]interface{}{
"txName": "inexistentTx",
Expand All @@ -110,7 +110,7 @@ func TestGetTx404(t *testing.T) {
}

func TestGetTxInvalidArg(t *testing.T) {
stub := shim.NewMockStub("org1MSP", new(testCC))
stub := shimtest.NewMockStub("org1MSP", new(testCC))

req := map[string]interface{}{
"txName": 2,
Expand Down
6 changes: 3 additions & 3 deletions test/tx_readAsset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"reflect"
"testing"

"github.com/hyperledger/fabric/core/chaincode/shim"
"github.com/hyperledger/fabric-chaincode-go/shimtest"
)

func TestReadAsset(t *testing.T) {
stub := shim.NewMockStub("org1MSP", new(testCC))
stub := shimtest.NewMockStub("org1MSP", new(testCC))

// State setup
expectedResponse := map[string]interface{}{
Expand Down Expand Up @@ -64,7 +64,7 @@ func TestReadAsset(t *testing.T) {
}

func TestReadRecursive(t *testing.T) {
stub := shim.NewMockStub("org1MSP", new(testCC))
stub := shimtest.NewMockStub("org1MSP", new(testCC))

// State setup
setupPerson := map[string]interface{}{
Expand Down
4 changes: 2 additions & 2 deletions test/tx_updateAsset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"reflect"
"testing"

"github.com/hyperledger/fabric/core/chaincode/shim"
"github.com/hyperledger/fabric-chaincode-go/shimtest"
)

func TestUpdateAsset(t *testing.T) {
stub := shim.NewMockStub("org1MSP", new(testCC))
stub := shimtest.NewMockStub("org1MSP", new(testCC))

// State setup
person := map[string]interface{}{
Expand Down
Loading

0 comments on commit 240541a

Please sign in to comment.