-
Notifications
You must be signed in to change notification settings - Fork 51
Integration Tests
Integration tests are for testing CodeChain application as a whole. Related files are located under test/
directory, and uses Typescript as script language.
yarn is used for a package manager. To install dependencies, run following command in the test
directory:
yarn install
Currently, It requires you to compile in advance to run the tests. The integration tests will directly execute the binary in target/debug
directory or target/release
directory.
# debug
cargo build
# release
cargo build --release
To run integration tests, run following command in integration test directory.
# debug
yarn start
# release
NODE_ENV=production yarn start
Simple integration test that sends a parcel and gets an invoice from CodeChain is implemented at src/basic.test.ts
. It would be a good starting point for implementing new tests.
Writing an integration test involves spawning a new CodeChain process and attaching SDK to it. Helper class for automating this process is defined under src/helper/spawn.ts
, named CodeChain
. Some important functions are described below:
Assigns globally unique instance id to this object. Many parameters that need to avoid conflict(such as a port number) are derived from this instance id.
Spawns a new CodeChain node, and returns Promise that resolves when initialization is completed.
Kills a process and cleanup files created while running this node.