Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • ChaincodeMockStub

Implements

  • MockStub

Index

Constructors

constructor

  • new ChaincodeMockStub(name: string, cc: ChaincodeInterface, usercert?: string): ChaincodeMockStub

Properties

event

event: Map<string, Buffer> = new Map()

history

history: Map<string, KeyModification[]> = new Map()

privateCollections

privateCollections: Map<string, StateMap> = new Map()

state

state: StateMap = new Map()

transientMap

transientMap: StateMap = new Map()

Methods

createCompositeKey

  • createCompositeKey(objectType: string, attributes: string[]): string

deletePrivateData

  • deletePrivateData(collection: string, key: string): Promise<any>
  • DelState removes the specified key and its value from the ledger.

    Parameters

    • collection: string
    • key: string

    Returns Promise<any>

deleteState

  • deleteState(key: string): Promise<any>
  • DelState removes the specified key and its value from the ledger.

    Parameters

    • key: string

    Returns Promise<any>

getArgs

  • getArgs(): string[]

getBinding

  • getBinding(): string

getChannelID

  • getChannelID(): string

getCreator

  • getCreator(): ProposalCreator

getEvent

  • getEvent(name: string): Promise<Buffer>
  • Get the stored payload for an event name in the local event map

    Parameters

    • name: string

    Returns Promise<Buffer>

getFunctionAndParameters

  • getFunctionAndParameters(): object

getHistoryForKey

  • getHistoryForKey(key: string): Promise<HistoryQueryIterator>

getPrivateData

  • getPrivateData(collection: string, key: string): Promise<Buffer>
  • Get a stored value for this key in the local state

    Parameters

    • collection: string
    • key: string

    Returns Promise<Buffer>

getPrivateDataByPartialCompositeKey

  • getPrivateDataByPartialCompositeKey(collection: string, objectType: string, attributes: string[]): Promise<StateQueryIterator>
  • Parameters

    • collection: string
    • objectType: string
    • attributes: string[]

    Returns Promise<StateQueryIterator>

getPrivateDataByRange

  • getPrivateDataByRange(collection: string, startKey: string, endKey: string): Promise<StateQueryIterator>
  • Get state by range of keys, empty keys will return everything

    Parameters

    • collection: string
    • startKey: string
    • endKey: string

    Returns Promise<StateQueryIterator>

getPrivateDataQueryResult

  • getPrivateDataQueryResult(collection: string, query: string): Promise<StateQueryIterator>

getQueryResult

  • getQueryResult(query: string): Promise<StateQueryIterator>

getSignedProposal

  • getSignedProposal(): SignedProposal

getState

  • getState(key: string): Promise<Buffer>
  • Get a stored value for this key in the local state

    Parameters

    • key: string

    Returns Promise<Buffer>

getStateByPartialCompositeKey

  • getStateByPartialCompositeKey(objectType: string, attributes: string[]): Promise<StateQueryIterator>
  • Retrieve state by partial keys

    Parameters

    • objectType: string
    • attributes: string[]

    Returns Promise<StateQueryIterator>

getStateByRange

  • getStateByRange(startKey: string, endKey: string): Promise<StateQueryIterator>
  • Get state by range of keys, empty keys will return everything

    Parameters

    • startKey: string
    • endKey: string

    Returns Promise<StateQueryIterator>

getStringArgs

  • getStringArgs(): string[]

getTransient

getTxID

  • getTxID(): string

getTxTimestamp

  • getTxTimestamp(): Timestamp

invokeChaincode

  • invokeChaincode(chaincodeName: string, args: Buffer[], channel: string): Promise<ChaincodeResponse>
  • InvokeChaincode calls a peered chaincode.

    Parameters

    • chaincodeName: string
    • args: Buffer[]
    • channel: string

    Returns Promise<ChaincodeResponse>

mockInit

  • mockInit(uuid: string, args: string[], transientMap?: StateMap): Promise<ChaincodeResponse>
  • Initialise this chaincode, also starts and ends a transaction.

    Parameters

    • uuid: string
    • args: string[]
    • Optional transientMap: StateMap

    Returns Promise<ChaincodeResponse>

mockInvoke

  • mockInvoke(uuid: string, args: string[], transientMap?: StateMap): Promise<ChaincodeResponse>
  • Invoke this chaincode, also starts and ends a transaction.

    Parameters

    • uuid: string
    • args: string[]
    • Optional transientMap: StateMap

    Returns Promise<ChaincodeResponse>

mockInvokeWithSignedProposal

  • mockInvokeWithSignedProposal(uuid: string, args: string[], sp: SignedProposal): Promise<ChaincodeResponse>
  • Invoke this chaincode, also starts and ends a transaction.

    Parameters

    • uuid: string
    • args: string[]
    • sp: SignedProposal

    Returns Promise<ChaincodeResponse>

mockPeerChaincode

  • mockPeerChaincode(invokableChaincodeName: string, otherStub: MockStub): void
  • Register a peer chaincode with this MockStub invokableChaincodeName is the name or hash of the peer otherStub is a MockStub of the peer, already intialised

    Parameters

    • invokableChaincodeName: string
    • otherStub: MockStub

    Returns void

mockTransactionEnd

  • mockTransactionEnd(uuid: string): void

mockTransactionStart

  • mockTransactionStart(txid: string, transientMap?: StateMap): void
  • Used to indicate to a chaincode that it is part of a transaction. This is important when chaincodes invoke each other. MockStub doesn't support concurrent transactions at present.

    Parameters

    • txid: string
    • Optional transientMap: StateMap

    Returns void

putPrivateData

  • putPrivateData(collection: string, key: string, value: Buffer): Promise<any>
  • Store a value for this key in the local state

    Parameters

    • collection: string
    • key: string
    • value: Buffer

    Returns Promise<any>

putState

  • putState(key: string, value: Buffer): Promise<any>
  • Store a value for this key in the local state

    Parameters

    • key: string
    • value: Buffer

    Returns Promise<any>

setCreator

  • setCreator(mspId: string): void

setEvent

  • setEvent(name: string, payload: Buffer): Promise<any>
  • Store the payload corresponding to an event name to the local event map

    Parameters

    • name: string
    • payload: Buffer

    Returns Promise<any>

setSignedProposal

  • setSignedProposal(sp: SignedProposal): void

setTxTimestamp

  • setTxTimestamp(t: Timestamp): void

splitCompositeKey

  • splitCompositeKey(compositeKey: string): SplitCompositekey

Generated using TypeDoc