chaincode_suite_test.go 4.7 KB
Newer Older
1
2
3
4
5
6
/*
Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0
*/

7
package chaincode_test
8
9

import (
10
11
	"testing"

12
	commonledger "github.com/hyperledger/fabric/common/ledger"
13
	"github.com/hyperledger/fabric/core/chaincode"
14
	"github.com/hyperledger/fabric/core/common/privdata"
15
	"github.com/hyperledger/fabric/core/container/ccintf"
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
	"github.com/hyperledger/fabric/core/ledger"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

func TestChaincode(t *testing.T) {
	RegisterFailHandler(Fail)
	RunSpecs(t, "Chaincode Suite")
}

//go:generate counterfeiter -o mock/tx_simulator.go --fake-name TxSimulator . txSimulator
type txSimulator interface {
	ledger.TxSimulator
}

//go:generate counterfeiter -o mock/history_query_executor.go --fake-name HistoryQueryExecutor . historyQueryExecutor
type historyQueryExecutor interface {
	ledger.HistoryQueryExecutor
}

36
37
38
//go:generate counterfeiter -o mock/results_iterator.go --fake-name QueryResultsIterator . queryResultsIterator
type queryResultsIterator interface {
	commonledger.QueryResultsIterator
39
}
40
41
42

//go:generate counterfeiter -o mock/runtime.go --fake-name Runtime . chaincodeRuntime
type chaincodeRuntime interface {
43
	chaincode.Runtime
44
45
46
47
}

//go:generate counterfeiter -o mock/cert_generator.go --fake-name CertGenerator . certGenerator
type certGenerator interface {
48
	chaincode.CertGenerator
49
50
51
52
}

//go:generate counterfeiter -o mock/processor.go --fake-name Processor . processor
type processor interface {
53
	chaincode.Processor
54
}
55

56
57
58
59
60
//go:generate counterfeiter -o mock/invoker.go --fake-name Invoker . invoker
type invoker interface {
	chaincode.Invoker
}

61
62
//go:generate counterfeiter -o mock/package_provider.go --fake-name PackageProvider . packageProvider
type packageProvider interface {
63
	chaincode.PackageProvider
64
65
}

66
67
68
69
// This is a bit weird, we need to import the chaincode/lifecycle package, but there is an error,
// even if we alias it to another name, so, calling 'lifecycleIface' instead of 'lifecycle'
//go:generate counterfeiter -o mock/lifecycle.go --fake-name Lifecycle . lifecycleIface
type lifecycleIface interface {
70
71
72
	chaincode.Lifecycle
}

73
74
75
76
77
//go:generate counterfeiter -o mock/chaincode_stream.go --fake-name ChaincodeStream . chaincodeStream
type chaincodeStream interface {
	ccintf.ChaincodeStream
}

78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//go:generate counterfeiter -o mock/transaction_registry.go --fake-name TransactionRegistry . transactionRegistry
type transactionRegistry interface {
	chaincode.TransactionRegistry
}

//go:generate counterfeiter -o mock/system_chaincode_provider.go --fake-name SystemCCProvider . systemCCProvider
type systemCCProvider interface {
	chaincode.SystemCCProvider
}

//go:generate counterfeiter -o mock/acl_provider.go --fake-name ACLProvider . aclProvider
type aclProvider interface {
	chaincode.ACLProvider
}

//go:generate counterfeiter -o mock/chaincode_definition_getter.go --fake-name ChaincodeDefinitionGetter . chaincodeDefinitionGetter
type chaincodeDefinitionGetter interface {
	chaincode.ChaincodeDefinitionGetter
}

98
99
100
//go:generate counterfeiter -o mock/instantiation_policy_checker.go --fake-name InstantiationPolicyChecker . instantiationPolicyChecker
type instantiationPolicyChecker interface {
	chaincode.InstantiationPolicyChecker
101
102
103
104
105
106
107
108
109
110
111
112
113
114
}

//go:generate counterfeiter -o mock/ledger_getter.go --fake-name LedgerGetter . ledgerGetter
type ledgerGetter interface {
	chaincode.LedgerGetter
}

//go:generate counterfeiter -o mock/peer_ledger.go --fake-name PeerLedger . peerLedger
type peerLedger interface {
	ledger.PeerLedger
}

// NOTE: These are getting generated into the "fake" package to avoid import cycles. We need to revisit this.

115
116
117
118
119
//go:generate counterfeiter -o fake/launch_registry.go --fake-name LaunchRegistry . launchRegistry
type launchRegistry interface {
	chaincode.LaunchRegistry
}

120
121
122
123
124
125
126
127
128
129
130
131
132
133
//go:generate counterfeiter -o fake/message_handler.go --fake-name MessageHandler . messageHandler
type messageHandler interface {
	chaincode.MessageHandler
}

//go:generate counterfeiter -o fake/context_registry.go --fake-name ContextRegistry  . contextRegistry
type contextRegistry interface {
	chaincode.ContextRegistry
}

//go:generate counterfeiter -o fake/query_response_builder.go --fake-name QueryResponseBuilder . queryResponseBuilder
type queryResponseBuilder interface {
	chaincode.QueryResponseBuilder
}
134

135
136
137
//go:generate counterfeiter -o fake/registry.go --fake-name Registry . registry
type registry interface {
	chaincode.Registry
138
}
139
140
141
142
143

//go:generate counterfeiter -o fake/application_config_retriever.go --fake-name ApplicationConfigRetriever . applicationConfigRetriever
type applicationConfigRetriever interface {
	chaincode.ApplicationConfigRetriever
}
144
145
146
147
148

//go:generate counterfeiter -o mock/collection_store.go --fake-name CollectionStore . collectionStore
type collectionStore interface {
	privdata.CollectionStore
}