0

I'm new to hyperledger fabric and I'm trying to write unit tests for my chaincode. Im using version 2.3 with the contract.api for writing my chaincode. Now i try to unit test this but all the resources i find are outdated and use the deprecated shimtest or deprecated shim versions.

What is the correct up to date method of unit testing chaincode? Is there a example or tutorial i can follow? I did take a look at the hyperledger fabric examples. They refer to a ChaincodeStubInterface, but there is no further explanation on how to use this. I also noticed that many (recent) examples have a mock folder with generated files in it, that they use for their tests. But how these get generated, I have no clue.

Help is much appreciated!

Stephan
  • 1
  • 1

1 Answers1

0

Unit testing chaincode should just be a case of following the standard practice of writing unit tests for that language (admittedly things never stay the same so best to look for tutorials on unit testing for your language to see what others do).

If you look at the fabric codebase you can see the tools that are currently used to help develop fabric are here https://github.com/hyperledger/fabric/blob/main/tools/tools.go

For example fabric uses mockery which is a mock generator as well as counterfeiter so maybe take a look at those tools.

david_k
  • 5,843
  • 2
  • 9
  • 16