-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathfabtoken_test.go
75 lines (67 loc) · 3.21 KB
/
fabtoken_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
Copyright IBM Corp All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package fabtoken
import (
"math"
"github.com/hyperledger-labs/fabric-smart-client/integration"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fsc"
"github.com/hyperledger-labs/fabric-smart-client/pkg/api"
integration2 "github.com/hyperledger-labs/fabric-token-sdk/integration"
token2 "github.com/hyperledger-labs/fabric-token-sdk/integration/token"
"github.com/hyperledger-labs/fabric-token-sdk/integration/token/common"
"github.com/hyperledger-labs/fabric-token-sdk/integration/token/common/sdk/ffabtoken"
"github.com/hyperledger-labs/fabric-token-sdk/integration/token/fungible"
"github.com/hyperledger-labs/fabric-token-sdk/integration/token/fungible/topology"
fabtokenv1 "github.com/hyperledger-labs/fabric-token-sdk/token/core/fabtoken/v1/core"
"github.com/hyperledger-labs/fabric-token-sdk/token/driver"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("EndToEnd", func() {
for _, t := range integration2.AllTestTypes {
Describe("Fungible", t.Label, func() {
ts, selector := newTestSuite(t.CommType, t.ReplicationFactor, "alice", "bob", "charlie")
BeforeEach(ts.Setup)
AfterEach(ts.TearDown)
It("succeeded", Label("T1"), func() { fungible.TestAll(ts.II, "auditor", nil, true, false, selector) })
It("Update public params", Label("T2"), func() { UpdatePublicParams(ts.II, selector) })
It("Test Identity Revocation", Label("T3"), func() { fungible.TestRevokeIdentity(ts.II, "auditor", selector) })
It("Test Remote Wallet (GRPC)", Label("T4"), func() { fungible.TestRemoteOwnerWallet(ts.II, "auditor", selector, false) })
It("Test Remote Wallet (WebSocket)", Label("T5"), func() { fungible.TestRemoteOwnerWallet(ts.II, "auditor", selector, true) })
It("Test redeem flow", Label("T6"), func() { fungible.TestRedeem(ts.II, selector, "default") })
})
}
})
func UpdatePublicParams(network *integration.Infrastructure, selector *token2.ReplicaSelector) {
tms := fungible.GetTMSByNetworkName(network, "default")
auditorId := fungible.GetAuditorIdentity(tms, "newAuditor")
issuerId := fungible.GetIssuerIdentity(tms, "newIssuer")
publicParam := fabtokenv1.PublicParams{
Label: "fabtoken",
QuantityPrecision: uint64(64),
Auditor: auditorId,
IssuerIDs: []driver.Identity{issuerId},
MaxToken: math.MaxUint64,
}
ppBytes, err := publicParam.Serialize()
Expect(err).NotTo(HaveOccurred())
fungible.TestPublicParamsUpdate(network, "newAuditor", ppBytes, "default", false, selector)
}
func newTestSuite(commType fsc.P2PCommunicationType, factor int, names ...string) (*token2.TestSuite, *token2.ReplicaSelector) {
opts, selector := token2.NewReplicationOptions(factor, names...)
ts := token2.NewTestSuite(StartPortDlog, topology.Topology(
common.Opts{
Backend: "fabric",
CommType: commType,
DefaultTMSOpts: common.TMSOpts{TokenSDKDriver: "fabtoken", Aries: true},
SDKs: []api.SDK{&ffabtoken.SDK{}},
ReplicationOpts: opts,
WebEnabled: true, // Needed for the Remote Wallet with websockets
// FSCLogSpec: "token-sdk=debug:fabric-sdk=debug:info",
OnlyUnity: true,
},
))
return ts, selector
}