After the Gateway server is running, we recommend testing out the endpoints using the supplied Postman collection and environment.
In addition, you can also run unit tests and manual test scripts if you have installed Gateway from source.
These methods allows you to test out the endpoints and understand how Gateway works, before interacting with it through the Hummingbot client. This is an important step because you will likely need to configure your node provider, gas settings, wallet, and other dependencies in order to run DEX trading bots successfully, and understanding Gateway's behavior on a standalone basis helps tremendously.
Testing with Postman¶
Postman is an app that helps you interact with API endpoints.
The official Hummingbot Postman workspace is: https://www.postman.com/hummingbot. Here, you can download collections and environments for use with Hummingbot.
Postman is the easiest way to test Gateway on a standalone basis. In the future, we should encourage community maintainers to upload DEX and chain-specific collections to the Hummingbot workspace.
Download and install the desktop version of Postman on your machine. You first have to establish a secure connection with your Gateway instance using certificates in the settings section, so the web version won’t work.
First, go to Settings >> Certificates in Postman:
In this view, eable the CA Certificates toggle, Then go to the certs_path folder location from Installation - Generating Certs. Add the
ca_cert.pem from this folder to PEM file in Postman.
In the Client Certificates section, set the following:
- Host: localhost:15888 (or the port where you are running Gateway)
- CRT file: path to the
client_cert.pemfile in your certs_path
- KEY file: path to the
client_key.pemfile in your certs_path
- Passphrase: the passphrase you defined from Installation - Generating Certs
You can also find Postman collections and environments from the /postman folder in the Gateway repo.
Import the GatewayAPI collection and the acccompanying Gateway environment into your Postman app in order to test the Gateway endpoints.
After you have imported the collection and environment, test the various endpoints and change the request parameters to understand the their behavior. This will help you understand the speed/latency of each endpoint and configure important setting, especially your node provider, to match your trading style.
By convention, the POST requests have sample request payloads in the Body field, which allows you to run the same
If you have installed Gateway from source, you can also run the
curl test scripts, defined in the /test-helpers/curl/curl.sh file.
On Linux and Windows/WSL systems, you can install these with
sudo apt install curl and
sudo apt install envsubst On MacOS, you can run
brew install curl and
brew install envsubst if you have Homebrew.
Finally, define the
GATEWAY_KEY environment variables. These are the paths to
client_key.pem in your certs_path, respectively.
Here's an example:
Now, you an copy and paste individual commands into Bash/Terminal to execute the tests accordingly.
When using curl any of the tests that can be run using
uniswap can be run on
sushiswap connector or any future compatible connector that is similar to Uniswap by simply replacing the connector value in the JSON file.
Here are a few examples:
To maintain a high quality bar, connector developers must add unit tests when contributing connectors.
If you have installed Gateway from source, you can run these unit tests locally from the root directory:
Writing unit tests
If you are looking to add a connector to Gateway, read this document for more details about how to write unit tests: Writing unit tests for gateway.