The Makefile make it easier to do mostly all the frequently commands needed to work on the project.

Work on Docs

we are using swaggo/swag to generate swagger docs based on the annotation inside the code.

  • install swag executable binary

    go install
  • now if you check the binary directory inside go directory you will find the executable file.

    ls $(go env GOPATH)/bin
  • to run swag you can either use the full path $(go env GOPATH)/bin/swag or export go binary to $PATH

    export PATH=$PATH:$(go env GOPATH)/bin
  • use swag to format code comments.

    swag fmt
  • update the docs

    swag init
  • to parse external types from vendor

    swag init --parseVendor
  • for a full generate docs command

    make docs

To start the GridProxy server

After preparing the postgres database you can go run the main file in cmds/proxy_server/main.go which responsible for starting all the needed server/clients.

The server options

-addressServer ip address (default ":443")
-cacertificate authority used to generate certificate (default "")
-cert-cache-dirpath to store generated certs in (default "/tmp/certs")
-domaindomain on which the server will be served
-emailemail address to generate certificate with
-log-levellog level [debug\|info\|warn\|error\|fatal\|panic] (default "info")
-no-certstart the server without certificate
-postgres-dbpostgres database
-postgres-hostpostgres host
-postgres-passwordpostgres password
-postgres-portpostgres port (default 5432)
-postgres-userpostgres username
-tfchain-urltF chain url (default "wss://")
-relay-urlRMB relay url (default"wss://")
-mnemonicsDummy user mnemonics for relay calls
-vshows the package version

For a full server setup:

make restart

Run tests

There is two types of tests in the project

  • Unit Tests
    • Found in pkg/client/*_test.go
    • Run with go test -v ./pkg/client
  • Integration Tests
    • Found in tests/queries/

    • Run with:

      go test -v \
      --seed 13 \
      --postgres-host <postgres-ip> \
      --postgres-db tfgrid-graphql \
      --postgres-password postgres \
      --postgres-user postgres \
      --endpoint <server-ip> \
      --mnemonics <insert user mnemonics>
    • Or to run a specific test you can append the previous command with

      -run <TestName>

      You can found the TestName in the tests/queries/*_test.go files.

To run all the tests use

make test-all