Search code examples
unit-testinghyperledger-sawtooth

How to unit test a sawtooth hyperledger transaction processor


I having hard time figuring out how to run the unit tests of a sawtooth hyperledger transaction processor. I am following their documentation on this topic:

https://sawtooth.hyperledger.org/docs/core/releases/1.0/app_developers_guide/testing.html

However, it does not explain the modus operandi of setting up the necessary environment, etc and actually running the unit tests. I have tried building the docker compose file which seemingly tries to build and run tests:

docker-compose -f sawtooth-core/sdk/examples/xo_python/tests/test_tp_xo_python.yaml up

The docker-compose file seems to contain some environment vars such as

  • $SAWTOOTH_CORE
  • $INSTALL_TYPE
  • $ISOLATION_ID

Not sure what value needs to be set to the above environment variables and in my case it fails because it fails to get the values for these vars..

Any thoughts, pointers or direction on how to run the tests for the processor would be very helpful.

Many thanks!.


Solution

  • You can poke around the Sawtooth core repo and find the values: https://github.com/hyperledger/sawtooth-core

    • SAWTOOTH_CORE is the root directory of where you cloned the sawtooth-core git repository (default is your current directory)
    • INSTALL_TYPE is local (there may be other values, but I do not know them)
    • ISOLATION_ID is the Sawtooth Version. For example, 1.1 . It is used to identify the Docker container to download.

    You can run the tests through Docker with bin/run_tests

    Sawtooth testing is currently done with Jenkins CI. Start at Jenkinsfile to see how testing is done.