Giter VIP home page Giter VIP logo

pokt-lint's Introduction

Unit Tests ย  Go Report Card

POKT Lint

An open-source diagnostic tool for Pocket Network node runners.


Using the public API

The public deployment of this tool is available at the following baseURLs:

Run the OpenAPI docs locally

make docserver

Deploying to AWS Lambda

A public deployment is maintained on AWS. To build executables that can be uploaded to AWS Lambda, run the following command:

make build-lambda

This will create 2 archives that can be uploaded to their corresponding Lambda functions:

  • build/LambdaPingTestHandler.zip
  • build/LambdaRelayTestHandler.zip

You can also build and deploy to AWS using the aws-cli:

make deploy-lambda-all-qa
# or
make deploy-lambda-all

This uses the aws-cli docker container and expects ~/.aws/config and ~/.aws/credentials to exist.


Build the test commands locally

This package provides 2 commands that can be used to test the operation of Pocket Network nodes:

  • pingtest measures the latency between the test client and a node
  • relaytest runs relay tests on a node

The commands can be built and run directly on your host, or they can be built and run in a docker container.

Option 1) Build directly on your host

Requirements:

# clone the repository
git clone https://github.com/decentralized-authority/pokt-lint

# build the commands
cd pokt-lint
make build-commands

Option 2) Build using Docker

Requirements:

  • Docker

Build for Linux:

# clone the repository
git clone https://github.com/decentralized-authority/pokt-lint

# build the commands
cd pokt-lint
docker build -t pokt-lint .
docker run --rm -ti -v $PWD/build:/app/build pokt-lint

Build for macOS:

# clone the repository
git clone https://github.com/decentralized-authority/pokt-lint

# build the commands
cd pokt-lint
docker build -t pokt-lint -f Dockerfile-mac .
docker run --rm -ti -v $PWD/build:/app/build pokt-lint

Build for Windows:

# clone the repository
git clone https://github.com/decentralized-authority/pokt-lint

# build the commands
cd pokt-lint
docker build -t pokt-lint -f Dockerfile-win .
docker run --rm -ti -v %cd%\build:/app/build pokt-lint

This will create 2 executable files:

./build/pingtest

Usage of ./build/pingtest:
  -num int
    	-num 10 (default 1)
  -url string
    	-url https://www.example.com

./build/relaytest

Usage of ./build/relaytest:
  -chains string
    	comma separated chains ids, eg: -chains=0001,0003,0005
  -id string
    	node id
  -url string
    	node url

Dev Toolchain Reference

pokt-lint % make
usage: make [target] ...

targets:
-------
help                            Show this help message.
docserver                       Run an interactive OpenAPI spec on port 3333
docserver-stop                  Stop the interactive spec
build-commands                  <-- compiles executables to ${BUILD_DIR}
build-lambda                    <-- builds lambda function bundles in ${BUILD_DIR}
build-lambda-pingtest           builds the pingtest lambda function
build-lambda-relaytest          builds the relaytest lambda function
build-lambda-cors               builds the cors handler (to return access-control-* headers)
deploy-lambda-all-qa            <-- deploys all lambda QA functions
deploy-lambda-all               <-- deploys all lambda functions
deploy-lambda-pingtest-qa       builds and deploys the pingtest QA function
deploy-lambda-relaytest-qa      builds and deploys the relaytest QA function
deploy-lambda-cors-qa           builds and deploys the CORS QA function
deploy-lambda-pingtest          builds and deploys the pingtest function
deploy-lambda-relaytest         builds and deploys the relaytest function
deploy-lambda-cors              builds and deploys the CORS function
test                            runs the unit tests
clean                           deletes build artifacts

pokt-lint's People

Contributors

itsnoproblem avatar rburgett avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

bjm3

pokt-lint's Issues

Improve JSON parsing errors in request validation

If I send a request to the relay-test endpoint with incorrect parameters, eg excluding the node_id param, the response is not very useful:

{
    "errorMessage": "relaying.HandleRequest: relaying.NewNodeChecker: init: Node: strconv.ParseUint: parsing \"\": invalid syntax",
    "errorType": "errorString"
}

Add Simulate Relay message to "404 page not found"

When simulate relays is not on, we should have something in the response that is more descriptive. "404 page not found" should follow up with: "Check that Simulate Relays is enabled"

Call

curl -X POST -H "Content-Type: application/json" -d '{"node_url": "https://node-001.testnet2.dopenodes.com:443", "chain_ids": ["0001","0040"]}' https://2eqrf8goof.execute-api.us-east-1.amazonaws.com/test/relay-test

Response:

{"0001":{"chain_id":"0001","chain_name":"POKT","success":true,"status_code":404,"message":"OK","duration_ms":36.672,"relay_request":{"data":"{}","method":"POST","path":"/v1/query/height","headers":null},"relay_response":{"status_code":404,"data":{"body":"404 page not found"}}},"0040":{"chain_id":"0040","chain_name":"HMY 0","success":true,"status_code":404,"message":"OK","duration_ms":36.288,"relay_request":{"data":"{\"jsonrpc\":\"2.0\",\"method\":\"hmy_blockNumber\",\"params\":[],\"id\":64}","method":"POST","path":"/","headers":null},"relay_response":{"status_code":404,"data":{"body":"404 page not found"}}}}da@chains01-04:~$

Relay Test response indicates success even if the simulate relay request failed

eg: this is the response for a relay test that should have failed. "success" should be false, but it is true

 "0025": {
        "chain_id": "0025",
        "chain_name": "ETH Rinkeby",
        "success": true,
        "status_code": 400,
        "message": "OK",
        "duration_ms": 46.652,
        "relay_request": {
            "data": "{\"jsonrpc\":\"2.0\",\"method\":\"eth_blockNumber\",\"params\":[],\"id\":64}",
            "method": "POST",
            "path": "/",
            "headers": null
        },
        "relay_response": {
            "status_code": 400,
            "data": {
                "code": 400,
                "message": "ERROR:\nCodespace: pocketcore\nCode: 46\nMessage: \"the blockchain requested is not hosted\"\n"
            }
        }
    },
    ```

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.