Skip to content

Commit

Permalink
fix lint issues (#394)
Browse files Browse the repository at this point in the history
* linter issues fixed

* lint issues fixed

* lint issues fixed

* name chain conflict resolved

* strat modified as start

* linter issues fixed

* character length issues resolved

* character length issues resolved

* character length issues resolved

* conflict resolved

* character length issues resolved

* character lengths resolved

* character lengths resolved

* conflict resolved

* character lengths resolved

* conflict resolved

* conflict resolved

* character lengths resolved

* character lengths resolved

* conflict  resolved

* conflict  resolved

* conflict  resolved

* conflict  resolved

* length character issuse resolved

* conflict resolved

* reundant return issue resolved

* error check added to retry.do function

* lint issues fixed

* redundant issue resolved

* lint issues fixed

* lint issues fixed

* lint issues fixed

* composite literal issue resolved

* character lenth issue solved

* Sprint issue resolved

* Sprint issue resolved

* start changed to sTrategy

* conflict resolved

* conflict resolved

* conflict resolved

* conflict resolved

* conflict resolved

* conflict resolved

* make file changed

* conflict resolved

* conflict resolved

* conflict resolved

* empty branch issue resolved

* empty branch issue resolved

* empty branch issue resolved

* empty branch issue resolved

* empty branch issue resolved

* interfacer issue resolved

* go lint issues fixed

* go lint issues fixed

* go lint issues fixed

* go lint issues fixed

* comments modified

* comments modified

* comments modified

* comments modified

* comments added

* comments added

* comments added

* comments deleted

* comments deleted

* comments deleted

* issues fixed

* issues fixed

* length issue resolved

* updated

* lint issues fixed

* conflict resolved

* conflict resolved

* conflict resolved

* conflict resolved

* issues fixed

* conflict resolved

* issues fixed

* conflicts resolved

* issues fixed

* issues fixed

* issues fixed

* issues fixed

* issue resolved

* issue resolved

* sTrategy changed to strategyType

* Changes done
  • Loading branch information
NagaTulasi authored Feb 2, 2021
1 parent cbedb3c commit f992aca
Show file tree
Hide file tree
Showing 33 changed files with 283 additions and 151 deletions.
3 changes: 3 additions & 0 deletions clib/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var clibPort = 0
var replies = map[int]chan goReturn{}
var lastReply = 0

//nolint:golint
//export RunClib
func RunClib(nodePort C.int, toNode C.sendFunc, clibArgs []*C.char) C.int {
if relayer.SendToController == nil {
Expand Down Expand Up @@ -75,6 +76,7 @@ func RunClib(nodePort C.int, toNode C.sendFunc, clibArgs []*C.char) C.int {
return C.int(clibPort)
}

//nolint:golint
//export ReplyToClib
func ReplyToClib(replyPort C.int, isError C.int, str C.Body) C.int {
goStr := C.GoString(str)
Expand All @@ -92,6 +94,7 @@ func ReplyToClib(replyPort C.int, isError C.int, str C.Body) C.int {
return C.int(0)
}

//nolint:golint
//export SendToClib
func SendToClib(port C.int, str C.Body) C.Body {
goStr := C.GoString(str)
Expand Down
5 changes: 4 additions & 1 deletion cmd/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
Package cmd includes relayer commands
Copyright © 2020 Jack Zampolin jack.zampolin@gmail.com
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -32,7 +33,9 @@ import (
)

const (
ORDERED = "ORDERED"
// ORDERED is exported channel type constant
ORDERED = "ORDERED"
// UNORDERED is exported channel type constant
UNORDERED = "UNORDERED"
defaultOrder = ORDERED
defaultVersion = "ics20-1"
Expand Down
5 changes: 3 additions & 2 deletions cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ var (
flagSkip = "skip"
flagStrategy = "strategy"
flagTimeout = "timeout"
flagConfig = "config"
flagJSON = "json"
flagYAML = "yaml"
flagFile = "file"
Expand Down Expand Up @@ -198,7 +197,9 @@ func versionFlag(cmd *cobra.Command) *cobra.Command {
}

func forceFlag(cmd *cobra.Command) *cobra.Command {
cmd.Flags().BoolP(flagForce, "f", false, "option to force non-standard behavior such as initialization of light client from configured chain or generation of new path") //nolint:lll
cmd.Flags().BoolP(flagForce, "f", false,
"option to force non-standard behavior such as initialization of light client from"+
"configured chain or generation of new path")
if err := viper.BindPFlag(flagForce, cmd.Flags().Lookup(flagForce)); err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/keys.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
Package cmd includes relayer commands
Copyright © 2020 Jack Zampolin jack.zampolin@gmail.com
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -133,7 +134,6 @@ $ %s k r ibc-1 faucet-key "[mnemonic-words]"`, appName, appName)),
}

coinType, _ := cmd.Flags().GetUint32(flagCoinType)

info, err := chain.Keybase.NewAccount(keyName, args[2], "", hd.CreateHDPath(coinType, 0, 0).String(), hd.Secp256k1)
if err != nil {
return err
Expand Down
8 changes: 5 additions & 3 deletions cmd/light.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
Package cmd includes relayer commands
Copyright © 2020 Jack Zampolin <jack.zampolin@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -86,7 +87,8 @@ $ %s l i ibc-2 --force`, appName, appName, appName)),
if err != nil {
return err
}
fmt.Printf("successfully created light client for %s by trusting endpoint %s...\n", chain.ChainID, chain.RPCAddr)
fmt.Printf("successfully created light client for %s by trusting endpoint %s...\n",
chain.ChainID, chain.RPCAddr)
case height > 0 && len(hash) > 0: // height and hash are given
_, err = chain.LightClientWithTrust(db, chain.TrustOptions(height, hash))
if err != nil {
Expand Down Expand Up @@ -127,8 +129,8 @@ $ %s l u ibc-1`, appName, appName)),
if err != nil {
return err
}

fmt.Printf("Updated light client for %s from height %d -> height %d\n", args[0], bh.Header.Height, ah.Header.Height)
fmt.Printf("Updated light client for %s from height %d -> height %d\n",
args[0], bh.Header.Height, ah.Header.Height)
return nil
},
}
Expand Down
8 changes: 5 additions & 3 deletions cmd/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ $ %s pth gen ibc-0 ibc-1 demo-path --unordered false --version ics20-2`, appName
dstClients, err = c[dst].QueryClients(0, 1000)
return err
})
if eg.Wait(); err != nil {
if err := eg.Wait(); err != nil {
return err
}

Expand Down Expand Up @@ -284,7 +284,8 @@ $ %s pth gen ibc-0 ibc-1 demo-path --unordered false --version ics20-2`, appName
dstOrder := dstChan.Ordering == path.Dst.GetOrder()
srcVersion := srcChan.Version == path.Src.Version
dstVersion := dstChan.Version == path.Dst.Version
if !(dstCpForSrc && srcCpForDst && srcOpen && dstOpen && srcPort && dstPort && srcOrder && dstOrder && srcVersion && dstVersion) {
if !(dstCpForSrc && srcCpForDst && srcOpen && dstOpen && srcPort && dstPort &&
srcOrder && dstOrder && srcVersion && dstVersion) {
path.GenSrcChanID()
path.GenDstChanID()
}
Expand Down Expand Up @@ -369,7 +370,8 @@ $ %s pth l`, appName, appName, appName)),
return err
}
stat := pth.QueryPathStatus(chains[pth.Src.ChainID], chains[pth.Dst.ChainID]).Status
printPath(i, k, pth, checkmark(stat.Chains), checkmark(stat.Clients), checkmark(stat.Connection), checkmark(stat.Channel))
printPath(i, k, pth, checkmark(stat.Chains), checkmark(stat.Clients),
checkmark(stat.Connection), checkmark(stat.Channel))
i++
}
return nil
Expand Down
13 changes: 8 additions & 5 deletions cmd/raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@ func chanInit() *cobra.Command {
Short: "chan-init",
Args: cobra.ExactArgs(11),
Example: strings.TrimSpace(fmt.Sprintf(`
$ %s tx raw chan-init ibc-0 ibc-1 ibczeroclient ibconeclient ibcconn1 ibcconn2 ibcchan1 ibcchan2 transfer transfer ordered`, appName)),
$ %s tx raw chan-init ibc-0 ibc-1 ibczeroclient ibconeclient
ibcconn1 ibcconn2 ibcchan1 ibcchan2 transfer transfer ordered`, appName)),
RunE: func(cmd *cobra.Command, args []string) error {
src, dst := args[0], args[1]
chains, err := config.Chains.Gets(args[0], args[1])
Expand Down Expand Up @@ -541,9 +542,10 @@ func createChannelStepCmd() *cobra.Command {
Short: "create the next step in creating a channel between chains with the passed identifiers",
Args: cobra.ExactArgs(11),
Example: strings.TrimSpace(fmt.Sprintf(`
$ %s transact raw chan-step ibc-0 ibc-1 ibczeroclient ibconeclient ibcconn1 ibcconn2 ibcchan1 ibcchan2 transfer transfer ordered
$ %s tx raw channel-step ibc-0 ibc-1 ibczeroclient ibconeclient ibcconn1 ibcconn2 ibcchan1 ibcchan2 transfer transfer ordered
`, appName, appName)),
$ %s transact raw chan-step ibc-0 ibc-1 ibczeroclient ibconeclient ibcconn1
ibcconn2 ibcchan1 ibcchan2 transfer transfer ordered
$ %s tx raw channel-step ibc-0 ibc-1 ibczeroclient ibconeclient ibcconn1
ibcconn2 ibcchan1 ibcchan2 transfer transfer ordered`, appName, appName)),
RunE: func(cmd *cobra.Command, args []string) error {
src, dst := args[0], args[1]
chains, err := config.Chains.Gets(src, dst)
Expand Down Expand Up @@ -654,7 +656,8 @@ func closeChannelStepCmd() *cobra.Command {
Short: "create the next step in closing a channel between chains with the passed identifiers",
Args: cobra.ExactArgs(10),
Example: strings.TrimSpace(fmt.Sprintf(`
$ %s tx raw close-channel-step ibc-0 ibc-1 ibczeroclient ibconeclient ibcconn1 ibcconn2 ibcchan1 ibcchan2 transfer transfer`, appName)),
$ %s tx raw close-channel-step ibc-0 ibc-1 ibczeroclient ibconeclient ibcconn1
ibcconn2 ibcchan1 ibcchan2 transfer transfer`, appName)),
RunE: func(cmd *cobra.Command, args []string) error {
src, dst := args[0], args[1]
chains, err := config.Chains.Gets(src, dst)
Expand Down
2 changes: 2 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
Package cmd includes relayer commands
Copyright © 2020 Jack Zampolin jack.zampolin@gmail.com
Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -25,6 +26,7 @@ import (
"github.com/spf13/viper"
)

// MB is a megabyte
const (
MB = 1048576 // in bytes
)
Expand Down
1 change: 1 addition & 0 deletions cmd/start.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
Package cmd includes relayer commands
Copyright © 2020 Jack Zampolin <jack.zampolin@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
16 changes: 8 additions & 8 deletions cmd/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,35 @@ import (

// GetStrategyWithOptions sets strategy specific fields.
func GetStrategyWithOptions(cmd *cobra.Command, strategy relayer.Strategy) (relayer.Strategy, error) {
switch strat := strategy.(type) {
switch strategyType := strategy.(type) {
case *relayer.NaiveStrategy:
maxTxSize, err := cmd.Flags().GetString(flagMaxTxSize)
if err != nil {
return strat, err
return strategyType, err
}

txSize, err := strconv.ParseUint(maxTxSize, 10, 64)
if err != nil {
return strat, err
return strategyType, err
}

// set max size of messages in a relay transaction
strat.MaxTxSize = txSize * MB // in MB
strategyType.MaxTxSize = txSize * MB // in MB

maxMsgLength, err := cmd.Flags().GetString(flagMaxMsgLength)
if err != nil {
return strat, err
return strategyType, err
}

msgLen, err := strconv.ParseUint(maxMsgLength, 10, 64)
if err != nil {
return strat, err
return strategyType, err
}

// set max length messages in relay transaction
strat.MaxMsgLength = msgLen
strategyType.MaxMsgLength = msgLen

return strat, nil
return strategyType, nil
default:
return strategy, nil
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/testnets.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ $ %s tst req ibc-0`, appName, appName, appName)),
if err != nil {
return err
}

body, err := json.Marshal(relayer.FaucetRequest{Address: info.GetAddress().String(), ChainID: chain.ChainID})
body, err := json.Marshal(relayer.FaucetRequest{Address: info.GetAddress().String(),
ChainID: chain.ChainID})
if err != nil {
return err
}
Expand Down
12 changes: 8 additions & 4 deletions cmd/tx.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
Package cmd includes relayer commands
Copyright © 2020 NAME HERE <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -348,7 +349,9 @@ $ %s tx pth demo-path`, appName, appName, appName, appName, appName)),
// create clients if they aren't already created
modified, err := c[src].CreateClients(c[dst])
if modified {
overWriteConfig(cmd, config)
if err := overWriteConfig(cmd, config); err != nil {
return err
}
}

if err != nil {
Expand Down Expand Up @@ -497,9 +500,10 @@ $ %s tx acks demo-path -l 3 -s 6`, appName, appName)),

func upgradeChainCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "upgrade-chain [path-name] [chain-id] [new-unbonding-period] [deposit] [path/to/upgradePlan.json]",
Short: "upgrade a chain by providing the chain-id of the chain being upgraded, the new unbonding period, the proposal deposit and the json file of the upgrade plan without the upgrade client state ",
Args: cobra.ExactArgs(5),
Use: "upgrade-chain [path-name] [chain-id] [new-unbonding-period] [deposit] [path/to/upgradePlan.json]",
Short: "upgrade a chain by providing the chain-id of the chain being upgraded, the new unbonding period," +
"the proposal deposit and the json file of the upgrade plan without the upgrade client state",
Args: cobra.ExactArgs(5),
RunE: func(cmd *cobra.Command, args []string) error {
c, src, dst, err := config.ChainsFromPath(args[0])
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions cmd/xfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ $ %s tx xfer ibc-0 ibc-1 100000stake cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39
$ %s tx xfer ibc-0 ibc-1 100000stake raw:non-bech32-address --path demo
$ %s tx txf ibc-0 ibc-1 100000stake cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk --path demo
$ %s tx raw send ibc-0 ibc-1 100000stake cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk --path demo -c 5
`, appName, appName, appName, appName)),
`, appName, appName, appName, appName, appName)),
RunE: func(cmd *cobra.Command, args []string) error {
src, dst := args[0], args[1]
c, err := config.Chains.Gets(src, dst)
Expand Down Expand Up @@ -124,7 +124,8 @@ func setPathsFromArgs(src, dst *relayer.Chain, name string) (*relayer.Path, erro
return path, err
}
case name == "" && len(paths) > 1:
return nil, fmt.Errorf("more than one path between %s and %s exists, pass in path name", src.ChainID, dst.ChainID)
return nil, fmt.Errorf("more than one path between %s and %s exists, pass in path name",
src.ChainID, dst.ChainID)
case name == "" && len(paths) == 1:
for _, v := range paths {
path = v
Expand Down
17 changes: 14 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,30 @@ require (
github.com/cosmos/cosmos-sdk v0.41.0
github.com/cosmos/go-bip39 v1.0.0
github.com/gogo/protobuf v1.3.3
github.com/google/go-cmp v0.5.4 // indirect
github.com/gorilla/mux v1.8.0
github.com/kr/text v0.2.0 // indirect
github.com/lib/pq v1.9.0 // indirect
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/moby/term v0.0.0-20201101162038-25d840ce174a // indirect
github.com/onsi/ginkgo v1.14.2 // indirect
github.com/onsi/gomega v1.10.4 // indirect
github.com/ory/dockertest/v3 v3.6.2
github.com/pelletier/go-toml v1.8.1 // indirect
github.com/sirupsen/logrus v1.7.0 // indirect
github.com/spf13/afero v1.5.1 // indirect
github.com/spf13/cobra v1.1.1
github.com/spf13/viper v1.7.1
github.com/stretchr/objx v0.3.0 // indirect
github.com/stretchr/testify v1.7.0
github.com/tendermint/tendermint v0.34.3
github.com/tendermint/tm-db v0.6.3
golang.org/x/net v0.0.0-20201031054903-ff519b6c9102 // indirect
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
golang.org/x/sys v0.0.0-20201101102859-da207088b7d1 // indirect
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c // indirect
golang.org/x/text v0.3.5 // indirect
gopkg.in/ini.v1 v1.62.0 // indirect
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)

replace github.com/keybase/go-keychain => github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4
Expand Down
Loading

0 comments on commit f992aca

Please sign in to comment.