Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ INTEGRATION_TARGETS += fabric-twonets

## fabricx section
INTEGRATION_TARGETS += fabricx-iou
INTEGRATION_TARGETS += fabricx-simple

.PHONE: list-integration-tests
list-integration-tests: ## List all integration tests
Expand Down
9 changes: 5 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ require (
github.com/miekg/pkcs11 v1.1.1
github.com/miracl/conflate v1.3.4
github.com/multiformats/go-multiaddr v0.13.0
github.com/onsi/ginkgo/v2 v2.23.4
github.com/onsi/gomega v1.37.0
github.com/onsi/ginkgo/v2 v2.25.1
github.com/onsi/gomega v1.38.2
github.com/prometheus/client_golang v1.20.5
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.20.1
Expand Down Expand Up @@ -63,8 +63,6 @@ require (
modernc.org/sqlite v1.32.0
)

require golang.org/x/telemetry v0.0.0-20251008203120-078029d740a8 // indirect

require (
cel.dev/expr v0.24.0 // indirect
cloud.google.com/go v0.116.0 // indirect
Expand All @@ -82,6 +80,7 @@ require (
github.com/IBM/idemix/bccsp/schemes/aries v0.0.0-20241220065751-dc7206770307 // indirect
github.com/IBM/idemix/bccsp/schemes/weak-bb v0.0.0-20241220065751-dc7206770307 // indirect
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect
github.com/Masterminds/semver/v3 v3.4.0 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/VictoriaMetrics/fastcache v1.12.2 // indirect
github.com/alecthomas/kingpin/v2 v2.4.0 // indirect
Expand Down Expand Up @@ -289,12 +288,14 @@ require (
go.uber.org/fx v1.23.0 // indirect
go.uber.org/mock v0.5.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/arch v0.11.0 // indirect
golang.org/x/crypto v0.45.0 // indirect
golang.org/x/mod v0.29.0 // indirect
golang.org/x/net v0.47.0 // indirect
golang.org/x/oauth2 v0.30.0 // indirect
golang.org/x/sys v0.38.0 // indirect
golang.org/x/telemetry v0.0.0-20251008203120-078029d740a8 // indirect
golang.org/x/time v0.8.0 // indirect
golang.org/x/tools v0.38.0 // indirect
gonum.org/v1/gonum v0.16.0 // indirect
Expand Down
12 changes: 8 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,8 @@ github.com/IBM/mathlib v0.0.3-0.20250709075152-a138079496c3/go.mod h1:O230ebw6/2
github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible h1:1G1pk05UrOh0NlF1oeaaix1x8XzrfjIDK47TY0Zehcw=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0=
github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
Expand Down Expand Up @@ -1335,8 +1337,8 @@ github.com/onsi/ginkgo/v2 v2.9.0/go.mod h1:4xkjoL/tZv4SMWeww56BU5kAt19mVB47gTWxm
github.com/onsi/ginkgo/v2 v2.9.1/go.mod h1:FEcmzVcCHl+4o9bQZVab+4dC9+j+91t2FHSzmGAPfuo=
github.com/onsi/ginkgo/v2 v2.9.2/go.mod h1:WHcJJG2dIlcCqVfBAwUCrJxSPFb6v4azBwgxeMeDuts=
github.com/onsi/ginkgo/v2 v2.9.4/go.mod h1:gCQYp2Q+kSoIj7ykSVb9nskRSsR6PUj4AiLywzIhbKM=
github.com/onsi/ginkgo/v2 v2.23.4 h1:ktYTpKJAVZnDT4VjxSbiBenUjmlL/5QkBEocaWXiQus=
github.com/onsi/ginkgo/v2 v2.23.4/go.mod h1:Bt66ApGPBFzHyR+JO10Zbt0Gsp4uWxu5mIOTusL46e8=
github.com/onsi/ginkgo/v2 v2.25.1 h1:Fwp6crTREKM+oA6Cz4MsO8RhKQzs2/gOIVOUscMAfZY=
github.com/onsi/ginkgo/v2 v2.25.1/go.mod h1:ppTWQ1dh9KM/F1XgpeRqelR+zHVwV81DGRSDnFxK7Sk=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
Expand All @@ -1351,8 +1353,8 @@ github.com/onsi/gomega v1.27.1/go.mod h1:aHX5xOykVYzWOV4WqQy0sy8BQptgukenXpCXfad
github.com/onsi/gomega v1.27.3/go.mod h1:5vG284IBtfDAmDyrK+eGyZmUgUlmi+Wngqo557cZ6Gw=
github.com/onsi/gomega v1.27.4/go.mod h1:riYq/GJKh8hhoM01HN6Vmuy93AarCXCBGpvFDK3q3fQ=
github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg=
github.com/onsi/gomega v1.37.0 h1:CdEG8g0S133B4OswTDC/5XPSzE1OeP29QOioj2PID2Y=
github.com/onsi/gomega v1.37.0/go.mod h1:8D9+Txp43QWKhM24yyOBEdpkzN8FvJyAwecBgsU4KU0=
github.com/onsi/gomega v1.38.2 h1:eZCjf2xjZAqe+LeWvKb5weQ+NcPwX84kqJ0cZNxok2A=
github.com/onsi/gomega v1.38.2/go.mod h1:W2MJcYxRGV63b418Ai34Ud0hEdTVXq9NW9+Sx6uXf3k=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040=
Expand Down Expand Up @@ -1674,6 +1676,8 @@ go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE=
golang.org/x/arch v0.11.0 h1:KXV8WWKCXm6tRpLirl2szsO5j/oOODwZf4hATmGVNs4=
golang.org/x/arch v0.11.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
Expand Down
39 changes: 39 additions & 0 deletions integration/fabricx/simple/sdk.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0
*/

package simple

import (
"errors"

common "github.com/hyperledger-labs/fabric-smart-client/platform/common/sdk/dig"
digutils "github.com/hyperledger-labs/fabric-smart-client/platform/common/utils/dig"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric/services/state"
fabricx "github.com/hyperledger-labs/fabric-smart-client/platform/fabricx/sdk/dig"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services"
)

type SDK struct {
common.SDK
}

func NewSDK(registry services.Registry) *SDK {
return NewFrom(fabricx.NewSDK(registry))
}

func NewFrom(sdk common.SDK) *SDK {
return &SDK{SDK: sdk}
}

func (p *SDK) Install() error {
if err := p.SDK.Install(); err != nil {
return err
}

return errors.Join(
digutils.Register[state.VaultService](p.Container()),
)
}
151 changes: 151 additions & 0 deletions integration/fabricx/simple/simple_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
/*
Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0
*/

package simple_test

import (
"testing"

"github.com/hyperledger-labs/fabric-smart-client/integration"
"github.com/hyperledger-labs/fabric-smart-client/integration/fabricx/simple"
"github.com/hyperledger-labs/fabric-smart-client/integration/fabricx/simple/views"
nwocommon "github.com/hyperledger-labs/fabric-smart-client/integration/nwo/common"
nwofabricx "github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fabricx"
nwofsc "github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fsc"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/view"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

const testDataPath = "./out/testdata"

func TestEndToEnd(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "simple suite")
}

type TestSuite struct {
*integration.TestSuite
}

var _ = Describe("EndToEnd", func() {
for _, c := range []nwofsc.P2PCommunicationType{nwofsc.WebSocket} {
Describe("simple Life Cycle", Label(c), func() {
s := NewTestSuite(c)
BeforeEach(s.Setup)
AfterEach(s.TearDown)
It("succeeded", func() {
RunTest(s.II)
})
})
}
})

var testObjects = []views.SomeObject{
{
Owner: "Boss",
Value: 100,
},
{
Owner: "Bob",
Value: 200,
},
{
Owner: "RedHotChilli",
Value: 900,
},
{
Owner: "DogsEatCarrots",
Value: 600,
},
}

// This object has a negative value, it should return an error from the test.
var negativeTestObjects = []views.SomeObject{
{
Owner: "TigerEatsGrass",
Value: -100,
},
}

func RunTest(n *integration.Infrastructure) {
// create some objects
for _, obj := range testObjects {
res, err := n.Client(simple.CreatorNode).CallView("create", nwocommon.JSONMarshall(views.CreateParams{
Owner: obj.Owner,
Value: obj.Value,
Namespace: simple.Namespace,
Approvers: []view.Identity{n.Identity(simple.ApproverNode)},
}))
Expect(err).NotTo(HaveOccurred())
_ = res
}

// try to create one of our objects again, this should fail and return with an error
someExistingObject := testObjects[0]
_, err := n.Client(simple.CreatorNode).CallView("create", nwocommon.JSONMarshall(views.CreateParams{
Owner: someExistingObject.Owner,
Value: someExistingObject.Value,
Namespace: simple.Namespace,
Approvers: []view.Identity{n.Identity(simple.ApproverNode)},
}))
Expect(err).To(HaveOccurred())

// try to create an object with a negative value, this should fail and return with an error
someAbsurdObject := negativeTestObjects[0]
_, err = n.Client(simple.CreatorNode).CallView("create", nwocommon.JSONMarshall(views.CreateParams{
Owner: someAbsurdObject.Owner,
Value: someAbsurdObject.Value,
Namespace: simple.Namespace,
Approvers: []view.Identity{n.Identity(simple.ApproverNode)},
}))
Expect(err).To(HaveOccurred())

// lets see that we can query all our objects
lookupIDs := make([]string, len(testObjects))
for i, obj := range testObjects {
linearID, errx := obj.GetLinearID()
Expect(errx).ToNot(HaveOccurred())
lookupIDs[i] = linearID
}

res, err := n.Client(simple.CreatorNode).CallView("query", nwocommon.JSONMarshall(views.QueryParams{
SomeIDs: lookupIDs,
Namespace: simple.Namespace,
}))
Expect(err).ToNot(HaveOccurred())

raw, ok := res.([]byte)
Expect(ok).To(BeTrue())
var objs []views.SomeObject
nwocommon.JSONUnmarshal(raw, &objs)
Expect(objs).To(ConsistOf(testObjects))

// do some lookup which do not exist
_, err = n.Client(simple.CreatorNode).CallView("query", nwocommon.JSONMarshall(views.QueryParams{
SomeIDs: []string{"doo", "boo", "bong", "ding"},
Namespace: simple.Namespace,
}))
Expect(err).ToNot(HaveOccurred())
}

func NewTestSuite(commType nwofsc.P2PCommunicationType) *TestSuite {
return &TestSuite{integration.NewTestSuite(func() (*integration.Infrastructure, error) {
ii, err := integration.New(integration.IOUPort.StartPortForNode(), testDataPath, simple.Topology(&simple.SDK{}, commType)...)
if err != nil {
return nil, err
}

ii.RegisterPlatformFactory(nwofabricx.NewPlatformFactory())

ii.DeleteOnStart = true
ii.DeleteOnStop = false

ii.Generate()

return ii, nil
})}
}
52 changes: 52 additions & 0 deletions integration/fabricx/simple/topo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0
*/

package simple

import (
simpleviews "github.com/hyperledger-labs/fabric-smart-client/integration/fabricx/simple/views"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/api"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fabric"
nwofabricx "github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fabricx"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fabricx/extensions/scv2"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fsc"
"github.com/hyperledger-labs/fabric-smart-client/pkg/node"
)

const (
ApproverNode = "approver"
CreatorNode = "creator"
Namespace = "simple"
)

func Topology(sdk node.SDK, commType fsc.P2PCommunicationType) []api.Topology {
fabricTopology := nwofabricx.NewDefaultTopology()
fabricTopology.AddOrganizationsByName("Org1")
fabricTopology.AddNamespaceWithUnanimity(Namespace, "Org1")

fscTopology := fsc.NewTopology()
fscTopology.P2PCommunicationType = commType
fscTopology.SetLogging("grpc=error:fabricx=debug:info", "")

fscTopology.AddNodeByName(ApproverNode).
AddOptions(fabric.WithOrganization("Org1")).
AddOptions(scv2.WithApproverRole()).
// simple approval
RegisterResponder(&simpleviews.ApproveView{}, &simpleviews.CreateView{})

fscTopology.AddNodeByName(CreatorNode).
AddOptions(fabric.WithOrganization("Org1")).
// simple logic
RegisterViewFactory("create", &simpleviews.CreateViewFactory{}).
RegisterViewFactory("query", &simpleviews.QueryViewFactory{})

fscTopology.AddSDK(sdk)

return []api.Topology{
fabricTopology,
fscTopology,
}
}
Loading
Loading