mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-23 01:55:10 +00:00
Many users raise questions on how to test chaincode. It used to be much easier with the old shim, as they could directly use the old mock stub in the shim. Now that it no longer exists the fabcar example can provide an example of how to test chaincode. Also worth noting is our current directory structure of our Go chaincodes prevents the creation of mocks due to import cycles. This change also pushes the chaincode logic down into a `contract` package. Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
21 lines
665 B
Go
21 lines
665 B
Go
package contract
|
|
|
|
import (
|
|
"github.com/hyperledger/fabric-chaincode-go/shim"
|
|
"github.com/hyperledger/fabric-contract-api-go/contractapi"
|
|
)
|
|
|
|
//go:generate counterfeiter -o mocks/transaction.go -fake-name TransactionContext . TransactionContext
|
|
type TransactionContext interface {
|
|
contractapi.TransactionContextInterface
|
|
}
|
|
|
|
//go:generate counterfeiter -o mocks/chaincodestub.go -fake-name ChaincodeStub . ChaincodeStub
|
|
type ChaincodeStub interface {
|
|
shim.ChaincodeStubInterface
|
|
}
|
|
|
|
//go:generate counterfeiter -o mocks/statequeryiterator.go -fake-name StateQueryIterator . StateQueryIterator
|
|
type StateQueryIterator interface {
|
|
shim.StateQueryIteratorInterface
|
|
}
|