Skip to content
Snippets Groups Projects
Unverified Commit aec6710e authored by Luca Moser's avatar Luca Moser Committed by GitHub
Browse files

Adds relay-checker tool readme (#171)

* partial readme

* adds readme to the relay-checker and refactors it a little bit
parent fa05123e
No related branches found
No related tags found
No related merge requests found
# Relay-Checker
This tool checks whether a transaction which is created on a given node (via `broadcastData`),
is actually relayed/gossiped through the network by checking the transaction's existence on other
specified nodes after a cooldown.
This program can be configured via CLI flags:
```
--relayChecker.cooldownTime int the cooldown time after broadcasting the data on the specified target node (default 10)
--relayChecker.data string data to broadcast (default "TEST99BROADCAST99DATA")
--relayChecker.repeat int the amount of times to repeat the relay-checker queries (default 1)
--relayChecker.targetNode string the target node from the which transaction will be broadcasted from (default "http://127.0.0.1:8080")
--relayChecker.testNodes strings the list of nodes to check after the cooldown
--relayChecker.txAddress string the transaction address (default "SHIMMER99TEST99999999999999999999999999999999999999999999999999999999999999999999")
```
\ No newline at end of file
...@@ -5,12 +5,12 @@ import ( ...@@ -5,12 +5,12 @@ import (
) )
var ( var (
nodes []string nodes []string
target = "" target = ""
txnAddr = "GOSHIMMER99TEST999999999999999999999999999999999999999999999999999999999999999999" txnAddr = "GOSHIMMER99TEST999999999999999999999999999999999999999999999999999999999999999999"
txnData = "TEST99BROADCAST99DATA" txnData = "TEST99BROADCAST99DATA"
cooldown = 2 cooldownTime = 2
maxQuery = 1 repeat = 1
) )
func LoadConfig() { func LoadConfig() {
...@@ -31,16 +31,16 @@ func SetConfig() { ...@@ -31,16 +31,16 @@ func SetConfig() {
nodes = append(nodes, parameter.NodeConfig.GetStringSlice(CFG_TEST_NODES)...) nodes = append(nodes, parameter.NodeConfig.GetStringSlice(CFG_TEST_NODES)...)
// optional settings // optional settings
if parameter.NodeConfig.GetString(CFG_TXN_ADDRESS) != "" { if parameter.NodeConfig.GetString(CFG_TX_ADDRESS) != "" {
txnAddr = parameter.NodeConfig.GetString(CFG_TXN_ADDRESS) txnAddr = parameter.NodeConfig.GetString(CFG_TX_ADDRESS)
} }
if parameter.NodeConfig.GetString(CFG_DATA) != "" { if parameter.NodeConfig.GetString(CFG_DATA) != "" {
txnData = parameter.NodeConfig.GetString(CFG_DATA) txnData = parameter.NodeConfig.GetString(CFG_DATA)
} }
if parameter.NodeConfig.GetInt(CFG_COOL_DOWN_TIME) > 0 { if parameter.NodeConfig.GetInt(CFG_COOLDOWN_TIME) > 0 {
cooldown = parameter.NodeConfig.GetInt(CFG_COOL_DOWN_TIME) cooldownTime = parameter.NodeConfig.GetInt(CFG_COOLDOWN_TIME)
} }
if parameter.NodeConfig.GetInt(CFG_MAX_QUERY) > 0 { if parameter.NodeConfig.GetInt(CFG_REPEAT) > 0 {
maxQuery = parameter.NodeConfig.GetInt(CFG_MAX_QUERY) repeat = parameter.NodeConfig.GetInt(CFG_REPEAT)
} }
} }
{ {
"relaycheck": { "relayChecker": {
"targetnode": "http://127.0.0.1:8080", "targetNode": "http://127.0.0.1:8080",
"nodes": [ "testNodes": [
"http://127.0.0.1:8080" "http://127.0.0.1:8080"
], ],
"txnaddress": "SHIMMER99TEST99999999999999999999999999999999999999999999999999999999999999999999", "txAddress": "SHIMMER99TEST99999999999999999999999999999999999999999999999999999999999999999999",
"data": "TEST99BROADCAST99DATA", "data": "TEST99BROADCAST99DATA",
"cooldowntime": 10, "cooldownTime": 10,
"maxquery": 2 "repeat": 2
} }
} }
...@@ -41,7 +41,7 @@ func main() { ...@@ -41,7 +41,7 @@ func main() {
SetConfig() SetConfig()
api := client.NewGoShimmerAPI(target) api := client.NewGoShimmerAPI(target)
for i := 0; i < maxQuery; i++ { for i := 0; i < repeat; i++ {
txnHash, err := testBroadcastData(api) txnHash, err := testBroadcastData(api)
if err != nil { if err != nil {
fmt.Printf("%s\n", err) fmt.Printf("%s\n", err)
...@@ -50,7 +50,7 @@ func main() { ...@@ -50,7 +50,7 @@ func main() {
fmt.Printf("txnHash: %s\n", txnHash) fmt.Printf("txnHash: %s\n", txnHash)
// cooldown time // cooldown time
time.Sleep(time.Duration(cooldown) * time.Second) time.Sleep(time.Duration(cooldownTime) * time.Second)
// query target node // query target node
err = testTargetGetTransactions(api, txnHash) err = testTargetGetTransactions(api, txnHash)
...@@ -59,7 +59,7 @@ func main() { ...@@ -59,7 +59,7 @@ func main() {
break break
} }
// query nodes node // query test nodes
err = testNodesGetTransactions(txnHash) err = testNodesGetTransactions(txnHash)
if err != nil { if err != nil {
fmt.Printf("%s\n", err) fmt.Printf("%s\n", err)
......
...@@ -5,19 +5,19 @@ import ( ...@@ -5,19 +5,19 @@ import (
) )
const ( const (
CFG_TARGET_NODE = "relaycheck.targetNode" CFG_TARGET_NODE = "relayChecker.targetNode"
CFG_TEST_NODES = "relaycheck.nodes" CFG_TEST_NODES = "relayChecker.testNodes"
CFG_TXN_ADDRESS = "relaycheck.txnAddress" CFG_TX_ADDRESS = "relayChecker.txAddress"
CFG_DATA = "relaycheck.data" CFG_DATA = "relayChecker.data"
CFG_COOL_DOWN_TIME = "relaycheck.cooldownTime" CFG_COOLDOWN_TIME = "relayChecker.cooldownTime"
CFG_MAX_QUERY = "relaycheck.maxQuery" CFG_REPEAT = "relayChecker.repeat"
) )
func init() { func init() {
flag.StringSlice(CFG_TEST_NODES, []string{""}, "list of trusted entry nodes for auto peering") flag.StringSlice(CFG_TEST_NODES, []string{""}, "the list of nodes to check after the cooldown")
flag.String(CFG_TARGET_NODE, "http://127.0.0.1:8080", "target node to test") flag.String(CFG_TARGET_NODE, "http://127.0.0.1:8080", "the target node from the which transaction will be broadcasted from")
flag.String(CFG_TXN_ADDRESS, "SHIMMER99TEST99999999999999999999999999999999999999999999999999999999999999999999", "transaction address") flag.String(CFG_TX_ADDRESS, "SHIMMER99TEST99999999999999999999999999999999999999999999999999999999999999999999", "the transaction address")
flag.String(CFG_DATA, "TEST99BROADCAST99DATA", "data to broadcast") flag.String(CFG_DATA, "TEST99BROADCAST99DATA", "data to broadcast")
flag.Int(CFG_COOL_DOWN_TIME, 10, "cooldown time after broadcast data") flag.Int(CFG_COOLDOWN_TIME, 10, "the cooldown time after broadcasting the data on the specified target node")
flag.Int(CFG_MAX_QUERY, 1, "the repeat times of relay-checker") flag.Int(CFG_REPEAT, 1, "the amount of times to repeat the relay-checker queries")
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment