Skip to content

Commit

Permalink
Two TMS on the same fabric network (#476)
Browse files Browse the repository at this point in the history
Signed-off-by: Angelo De Caro <[email protected]>
Signed-off-by: Alexandros Filios <[email protected]>
  • Loading branch information
adecaro authored Jul 11, 2023
1 parent fa8cf04 commit 647d2db
Show file tree
Hide file tree
Showing 31 changed files with 572 additions and 129 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ jobs:
tests: [
dlog-fabric-t1,
dlog-fabric-t2,
fabtoken-dlog-fabric,
dloghsm-fabric-t1,
dloghsm-fabric-t2,
fabtoken-fabric,
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ clean:
rm -rf ./integration/token/fungible/fabtoken/cmd/
rm -rf ./integration/token/fungible/odlog/cmd/
rm -rf ./integration/token/fungible/ofabtoken/cmd/
rm -rf ./integration/token/fungible/mixed/cmd/
rm -rf ./integration/token/nft/dlog/cmd/
rm -rf ./integration/token/nft/fabtoken/cmd/
rm -rf ./integration/token/nft/odlog/cmd/
Expand Down
12 changes: 6 additions & 6 deletions cmd/tokengen/samples/topology/fungible.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ func Topology(tokenSDKDriver string) []api.Topology {
alice := fscTopology.AddNodeByName("alice").AddOptions(
fabric.WithOrganization("Org2"),
fabric.WithAnonymousIdentity(),
token.WithDefaultOwnerIdentity(tokenSDKDriver),
token.WithOwnerIdentity(tokenSDKDriver, "alice.id1"),
token.WithDefaultOwnerIdentity(),
token.WithOwnerIdentity("alice.id1"),
)
alice.RegisterResponder(&views.AcceptCashView{}, &views.IssueCashView{})
alice.RegisterResponder(&views.AcceptCashView{}, &views.TransferView{})
Expand All @@ -71,8 +71,8 @@ func Topology(tokenSDKDriver string) []api.Topology {
bob := fscTopology.AddNodeByName("bob").AddOptions(
fabric.WithOrganization("Org2"),
fabric.WithAnonymousIdentity(),
token.WithDefaultOwnerIdentity(tokenSDKDriver),
token.WithOwnerIdentity(tokenSDKDriver, "bob.id1"),
token.WithDefaultOwnerIdentity(),
token.WithOwnerIdentity("bob.id1"),
)
bob.RegisterResponder(&views.AcceptCashView{}, &views.IssueCashView{})
bob.RegisterResponder(&views.AcceptCashView{}, &views.TransferView{})
Expand All @@ -86,8 +86,8 @@ func Topology(tokenSDKDriver string) []api.Topology {
charlie := fscTopology.AddNodeByName("charlie").AddOptions(
fabric.WithOrganization("Org2"),
fabric.WithAnonymousIdentity(),
token.WithDefaultOwnerIdentity(tokenSDKDriver),
token.WithOwnerIdentity(tokenSDKDriver, "charlie.id1"),
token.WithDefaultOwnerIdentity(),
token.WithOwnerIdentity("charlie.id1"),
)
charlie.RegisterResponder(&views.AcceptCashView{}, &views.IssueCashView{})
charlie.RegisterResponder(&views.AcceptCashView{}, &views.TransferView{})
Expand Down
4 changes: 4 additions & 0 deletions fungible.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ integration-tests-dlog-fabric-t1:
integration-tests-dlog-fabric-t2:
cd ./integration/token/fungible/dlog; export FAB_BINS=$(FAB_BINS); ginkgo $(GINKGO_TEST_OPTS) --focus "Fungible with Auditor = Issuer" .

.PHONY: integration-tests-fabtoken-dlog-fabric
integration-tests-mixed:
cd ./integration/token/fungible/mixed; export FAB_BINS=$(FAB_BINS); ginkgo $(GINKGO_TEST_OPTS) .

.PHONY: integration-tests-dloghsm-fabric
integration-tests-dloghsm-fabric: install-softhsm
@echo "Setup SoftHSM"
Expand Down
7 changes: 3 additions & 4 deletions integration/nwo/token/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package token

import (
fsc "github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fsc/node"

"github.com/hyperledger-labs/fabric-token-sdk/integration/nwo/token/topology"
)

Expand Down Expand Up @@ -45,11 +44,11 @@ func WithDefaultIssuerIdentityWithHSM() fsc.Option {
return WithIssuerIdentityWithHSM("_default_")
}

func WithDefaultOwnerIdentity(driver string) fsc.Option {
return WithOwnerIdentity(driver, "_default_")
func WithDefaultOwnerIdentity() fsc.Option {
return WithOwnerIdentity("_default_")
}

func WithOwnerIdentity(driver string, label string) fsc.Option {
func WithOwnerIdentity(label string) fsc.Option {
return func(o *fsc.Options) error {
to := topology.ToOptions(o)
to.SetOwners(append(to.Owners(), label))
Expand Down
4 changes: 2 additions & 2 deletions integration/token/dvp/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func Topology(tokenSDKDriver string) []api.Topology {
seller := fscTopology.AddNodeByName("seller").AddOptions(
fabric.WithOrganization("Org2"),
fabric.WithAnonymousIdentity(),
token.WithDefaultOwnerIdentity(tokenSDKDriver),
token.WithDefaultOwnerIdentity(),
)
seller.RegisterResponder(&house.AcceptHouseView{}, &house.IssueHouseView{})
seller.RegisterViewFactory("sell", &views2.SellHouseViewFactory{})
Expand All @@ -80,7 +80,7 @@ func Topology(tokenSDKDriver string) []api.Topology {
buyer := fscTopology.AddNodeByName("buyer").AddOptions(
fabric.WithOrganization("Org2"),
fabric.WithAnonymousIdentity(),
token.WithDefaultOwnerIdentity(tokenSDKDriver),
token.WithDefaultOwnerIdentity(),
)
buyer.RegisterResponder(&cash.AcceptCashView{}, &cash.IssueCashView{})
buyer.RegisterResponder(&views2.BuyHouseView{}, &views2.SellHouseView{})
Expand Down
22 changes: 11 additions & 11 deletions integration/token/fungible/dloghsm/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ func Topology(backend string, tokenSDKDriver string, auditorAsIssuer bool) []api
orion.WithRole("issuer"),
token.WithDefaultIssuerIdentityWithHSM(),
token.WithIssuerIdentityWithHSM("issuer.id1"),
token.WithDefaultOwnerIdentity(tokenSDKDriver),
token.WithOwnerIdentity(tokenSDKDriver, "issuer.owner"),
token.WithDefaultOwnerIdentity(),
token.WithOwnerIdentity("issuer.owner"),
)
issuer.RegisterViewFactory("issue", &views.IssueCashViewFactory{})
issuer.RegisterViewFactory("transfer", &views.TransferViewFactory{})
Expand Down Expand Up @@ -109,7 +109,7 @@ func Topology(backend string, tokenSDKDriver string, auditorAsIssuer bool) []api
fabric.WithOrganization("Org2"),
fabric.WithAnonymousIdentity(),
orion.WithRole("alice"),
token.WithOwnerIdentity(tokenSDKDriver, "alice.id1"),
token.WithOwnerIdentity("alice.id1"),
)
alice.RegisterResponder(&views.AcceptCashView{}, &views.IssueCashView{})
alice.RegisterResponder(&views.AcceptCashView{}, &views.TransferView{})
Expand Down Expand Up @@ -137,8 +137,8 @@ func Topology(backend string, tokenSDKDriver string, auditorAsIssuer bool) []api
fabric.WithOrganization("Org2"),
fabric.WithAnonymousIdentity(),
orion.WithRole("bob"),
token.WithDefaultOwnerIdentity(tokenSDKDriver),
token.WithOwnerIdentity(tokenSDKDriver, "bob.id1"),
token.WithDefaultOwnerIdentity(),
token.WithOwnerIdentity("bob.id1"),
)
bob.RegisterResponder(&views.AcceptCashView{}, &views.IssueCashView{})
bob.RegisterResponder(&views.AcceptCashView{}, &views.TransferView{})
Expand Down Expand Up @@ -168,8 +168,8 @@ func Topology(backend string, tokenSDKDriver string, auditorAsIssuer bool) []api
fabric.WithOrganization("Org2"),
fabric.WithAnonymousIdentity(),
orion.WithRole("charlie"),
token.WithDefaultOwnerIdentity(tokenSDKDriver),
token.WithOwnerIdentity(tokenSDKDriver, "charlie.id1"),
token.WithDefaultOwnerIdentity(),
token.WithOwnerIdentity("charlie.id1"),
)
charlie.RegisterResponder(&views.AcceptCashView{}, &views.IssueCashView{})
charlie.RegisterResponder(&views.AcceptCashView{}, &views.TransferView{})
Expand All @@ -195,10 +195,10 @@ func Topology(backend string, tokenSDKDriver string, auditorAsIssuer bool) []api
fabric.WithOrganization("Org2"),
fabric.WithAnonymousIdentity(),
orion.WithRole("manager"),
token.WithDefaultOwnerIdentity(tokenSDKDriver),
token.WithOwnerIdentity(tokenSDKDriver, "manager.id1"),
token.WithOwnerIdentity(tokenSDKDriver, "manager.id2"),
token.WithOwnerIdentity(tokenSDKDriver, "manager.id3"),
token.WithDefaultOwnerIdentity(),
token.WithOwnerIdentity("manager.id1"),
token.WithOwnerIdentity("manager.id2"),
token.WithOwnerIdentity("manager.id3"),
)
manager.RegisterResponder(&views.AcceptCashView{}, &views.IssueCashView{})
manager.RegisterResponder(&views.AcceptCashView{}, &views.TransferView{})
Expand Down
29 changes: 29 additions & 0 deletions integration/token/fungible/mixed/mixed_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
Copyright IBM Corp All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package mixed

import (
"testing"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/hyperledger-labs/fabric-token-sdk/integration"
)

func TestEndToEnd(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode.")
}

RegisterFailHandler(Fail)
RunSpecs(t, "EndToEnd Fungible (DLOG) Suite")
}

func StartPortDlog() int {
return integration.ZKATDLogFungible.StartPortForNode()
}
44 changes: 44 additions & 0 deletions integration/token/fungible/mixed/mixed_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
Copyright IBM Corp All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package mixed

import (
"github.com/hyperledger-labs/fabric-smart-client/integration"
"github.com/hyperledger-labs/fabric-token-sdk/integration/nwo/token"
"github.com/hyperledger-labs/fabric-token-sdk/integration/token/fungible"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

var _ = Describe("EndToEnd", func() {
var (
network *integration.Infrastructure
)

AfterEach(func() {
network.Stop()
})

Describe("Fungible with Auditor ne Issuer", func() {
BeforeEach(func() {
var err error
network, err = integration.New(StartPortDlog(), "", Topology()...)
Expect(err).NotTo(HaveOccurred())
network.DeleteOnStop = false
network.DeleteOnStart = true
network.RegisterPlatformFactory(token.NewPlatformFactory())
network.Generate()
network.Start()
})

It("succeeded", func() {
fungible.TestMixed(network)
})

})

})
Loading

0 comments on commit 647d2db

Please sign in to comment.