Grinnode-live / 2020-grin-bug-bash-challenge

Finding bugs in Grin-Wallet & Grin-nodes for a bounty prior to Grin fork v5.
3 stars 1 forks source link

[GRIN-Node][Owner API 2.0] test the get_peers API method #54

Closed marekyggdrasil closed 3 years ago

marekyggdrasil commented 3 years ago

Description Goal of this issue is to test the get_peers API method

Prerequisites

  1. GRIN-Node

Test procedure

  1. Run GRIN-Node in Owner API listener mode
  2. Run the get_connected_peers API method

Expected result:

Output should match the example. Include all cURL requests and responses.

Include the exact version of your grin-node and also your environment

uname -a
mojitoo commented 3 years ago

Step 1 : Run GRIN-Node in Owner API listener mode

grin server run 

Step 2 : Run the get_connected_peers API method

curl -ugrin:$(cat ~/.grin/main/.api_secret) localhost:3413/v2/owner -d '{"jsonrpc": "2.0", "method": "get_connected_peers", "params": [], "id": 1}' -w "\n" -v
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 3413 (#0)
* Server auth using Basic with user 'grin'
> POST /v2/owner HTTP/1.1
> Host: localhost:3413
> Authorization: Basic Z3JpbjpNajJuNDFkUVcyN3Y3SXNtNjBiUw==
> User-Agent: curl/7.64.1
> Accept: */*
> Content-Length: 74
> Content-Type: application/x-www-form-urlencoded
> 
* upload completely sent off: 74 out of 74 bytes
< HTTP/1.1 200 OK
< access-control-allow-origin: *
< access-control-allow-headers: Content-Type, Authorization
< content-type: application/json
< content-length: 2340
< date: Fri, 01 Jan 2021 09:43:17 GMT
< 
{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "Ok": [
      {
        "addr": "78.47.206.120:3414",
        "capabilities": {
          "bits": 15
        },
        "direction": "Outbound",
        "height": 1027437,
        "total_difficulty": 1739045550555972,
        "user_agent": "MW/Grin 5.0.0-rc.2",
        "version": 1000
      },
      {
        "addr": "139.99.37.158:3414",
        "capabilities": {
          "bits": 15
        },
        "direction": "Outbound",
        "height": 1027425,
        "total_difficulty": 1739043318215515,
        "user_agent": "MW/Grin 5.0.0-rc.1",
        "version": 1000
      },
      {
        "addr": "39.96.171.125:3414",
        "capabilities": {
          "bits": 15
        },
        "direction": "Outbound",
        "height": 1027437,
        "total_difficulty": 1739045550555972,
        "user_agent": "MW/Grin 4.0.1",
        "version": 2
      },
      {
        "addr": "45.153.187.189:3414",
        "capabilities": {
          "bits": 15
        },
        "direction": "Outbound",
        "height": 1027437,
        "total_difficulty": 1739045550555972,
        "user_agent": "MW/Grin 4.1.1",
        "version": 1000
      },
      {
        "addr": "162.220.62.124:3414",
        "capabilities": {
          "bits": 15
        },
        "direction": "Outbound",
        "height": 1027437,
        "total_difficulty": 1739045550555972,
        "user_agent": "MW/Grin 4.1.0",
        "version": 1000
      },
      {
        "addr": "178.196.7.116:3414",
        "capabilities": {
          "bits": 15
        },
        "direction": "Outbound",
        "height": 1027437,
        "total_difficulty": 1739045550555972,
        "user_agent": "MW/Grin 4.1.1",
        "version": 1000
      },
      {
        "addr": "129.226.150.153:3414",
        "capabilities": {
          "bits": 15
        },
        "direction": "Outbound",
        "height": 1027437,
        "total_difficulty": 1739045550555972,
        "user_agent": "MW/Grin 4.0.0",
        "version": 2
      },
      {
        "addr": "217.120.234.230:3414",
        "capabilities": {
          "bits": 15
        },
        "direction": "Outbound",
        "height": 1027437,
        "total_difficulty": 1739045550555972,
        "user_agent": "MW/Grin 5.0.0-rc.1",
        "version": 1000
      }
    ]
  }
* Connection #0 to host localhost left intact
}
* Closing connection 0
marekyggdrasil commented 3 years ago

Looking good! Thanks!