CoinAlpha / gateway-api

Apache License 2.0
47 stars 25 forks source link

Add tests script for Uniswap routes #116

Closed fengtality closed 3 years ago

fengtality commented 3 years ago

Similar to how Balancer tests SOR in https://github.com/balancer-labs/balancer-sor/blob/master/test/, extend the sample tests file in the mf-uniswap branch https://github.com/CoinAlpha/gateway-api/pull/115/commits/2d9a77c9fc53ad5371cd89433cfc8b8d7e56d626.

QA will run these tests regularly, so the tests should assume that the tester defines keys stored in the config file.

Add tests that test each route, along with common edge cases.

fengtality commented 3 years ago

As discussed during sprint planning, here's what the script should do. The idea is to have the script call the routes in Gateway as if it's a client and complete an end-to-end test.

  1. connect to ETH wallet whose private key is in config file
  2. let user input symbols for token1 and token 2
  3. get token balances
  4. get token allowances
  5. call approve and increase allowance by X amount
  6. check that allowance increased by the correct amount
  7. get buy price
  8. execute a buy
  9. compare actual buy price to expected price
  10. get sell price
  11. execute a sell
  12. compare actual sell price to expected price