Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
expertdicer committed Jan 28, 2024
1 parent 71e91c6 commit 31b2e55
Show file tree
Hide file tree
Showing 18 changed files with 100 additions and 99 deletions.
28 changes: 14 additions & 14 deletions tests/e2e/configurer/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (bc *baseConfigurer) RunValidators() error {
}

func (bc *baseConfigurer) runValidators(chainConfig *chain.Config) error {
bc.t.Logf("starting %s validator containers...", chainConfig.Id)
bc.t.Logf("starting %s validator containers...", chainConfig.ID)
for _, node := range chainConfig.NodeConfigs {
if err := node.Run(); err != nil {
return err
Expand Down Expand Up @@ -119,10 +119,10 @@ func (bc *baseConfigurer) runIBCRelayer1(chainConfigA *chain.Config, chainConfig
}

hermesResource, err := bc.containerManager.RunHermesResource1(
chainConfigA.Id,
chainConfigA.ID,
relayerNodeA.Name,
filepath.Join("/root/hermes", "mnemonicA.json"),
chainConfigB.Id,
chainConfigB.ID,
relayerNodeB.Name,
filepath.Join("/root/hermes", "mnemonicB.json"),
hermesCfgPath)
Expand All @@ -133,7 +133,7 @@ func (bc *baseConfigurer) runIBCRelayer1(chainConfigA *chain.Config, chainConfig
endpoint := fmt.Sprintf("http://%s/state", hermesResource.GetHostPort("3031/tcp"))

require.Eventually(bc.t, func() bool {
resp, err := http.Get(endpoint)
resp, err := http.Get(endpoint) //nolint
if err != nil {
return false
}
Expand Down Expand Up @@ -209,10 +209,10 @@ func (bc *baseConfigurer) runIBCRelayer2(chainConfigA *chain.Config, chainConfig
}

hermesResource, err := bc.containerManager.RunHermesResource2(
chainConfigA.Id,
chainConfigA.ID,
relayerNodeA.Name,
filepath.Join("/root/hermes", "mnemonicA.json"),
chainConfigB.Id,
chainConfigB.ID,
relayerNodeB.Name,
filepath.Join("/root/hermes", "mnemonicB.json"),
hermesCfgPath)
Expand All @@ -223,7 +223,7 @@ func (bc *baseConfigurer) runIBCRelayer2(chainConfigA *chain.Config, chainConfig
endpoint := fmt.Sprintf("http://%s/state", hermesResource.GetHostPort("3031/tcp"))

require.Eventually(bc.t, func() bool {
resp, err := http.Get(endpoint)
resp, err := http.Get(endpoint) //nolint
if err != nil {
return false
}
Expand Down Expand Up @@ -265,28 +265,28 @@ func (bc *baseConfigurer) runIBCRelayer2(chainConfigA *chain.Config, chainConfig
}

func (bc *baseConfigurer) connectIBCChains(chainA *chain.Config, chainB *chain.Config) error {
bc.t.Logf("connecting %s and %s chains via IBC", chainA.ChainMeta.Id, chainB.ChainMeta.Id)
bc.t.Logf("connecting %s and %s chains via IBC", chainA.ChainMeta.ID, chainB.ChainMeta.ID)

cmd := []string{"hermes", "create", "channel", "--a-chain", chainA.ChainMeta.Id, "--b-chain", chainB.ChainMeta.Id, "--a-port", "transfer", "--b-port", "transfer", "--new-client-connection", "--yes"}
cmd := []string{"hermes", "create", "channel", "--a-chain", chainA.ChainMeta.ID, "--b-chain", chainB.ChainMeta.ID, "--a-port", "transfer", "--b-port", "transfer", "--new-client-connection", "--yes"}
bc.t.Log(cmd)
_, _, err := bc.containerManager.ExecHermesCmd1(bc.t, cmd, "SUCCESS")
if err != nil {
return err
}
bc.t.Logf("connected %s and %s chains via IBC", chainA.ChainMeta.Id, chainB.ChainMeta.Id)
bc.t.Logf("connected %s and %s chains via IBC", chainA.ChainMeta.ID, chainB.ChainMeta.ID)
return nil
}

func (bc *baseConfigurer) connectIBCChains2(chainA *chain.Config, chainB *chain.Config) error {
bc.t.Logf("connecting %s and %s chains via IBC", chainA.ChainMeta.Id, chainB.ChainMeta.Id)
bc.t.Logf("connecting %s and %s chains via IBC", chainA.ChainMeta.ID, chainB.ChainMeta.ID)

cmd := []string{"hermes", "create", "channel", "--a-chain", chainA.ChainMeta.Id, "--b-chain", chainB.ChainMeta.Id, "--a-port", "transfer", "--b-port", "transfer", "--new-client-connection", "--yes"}
cmd := []string{"hermes", "create", "channel", "--a-chain", chainA.ChainMeta.ID, "--b-chain", chainB.ChainMeta.ID, "--a-port", "transfer", "--b-port", "transfer", "--new-client-connection", "--yes"}
bc.t.Log(cmd)
_, _, err := bc.containerManager.ExecHermesCmd2(bc.t, cmd, "SUCCESS")
if err != nil {
return err
}
bc.t.Logf("connected %s and %s chains via IBC", chainA.ChainMeta.Id, chainB.ChainMeta.Id)
bc.t.Logf("connected %s and %s chains via IBC", chainA.ChainMeta.ID, chainB.ChainMeta.ID)
return nil
}

Expand All @@ -295,7 +295,7 @@ func (bc *baseConfigurer) initializeChainConfigFromInitChain(initializedChain *i
chainConfig.NodeConfigs = make([]*chain.NodeConfig, 0, len(initializedChain.Nodes))
setupTime := time.Now()
for i, validator := range initializedChain.Nodes {
conf := chain.NewNodeConfig(bc.t, validator, chainConfig.ValidatorInitConfigs[i], chainConfig.Id, bc.containerManager).WithSetupTime(setupTime)
conf := chain.NewNodeConfig(bc.t, validator, chainConfig.ValidatorInitConfigs[i], chainConfig.ID, bc.containerManager).WithSetupTime(setupTime)
chainConfig.NodeConfigs = append(chainConfig.NodeConfigs, conf)
}
}
27 changes: 13 additions & 14 deletions tests/e2e/configurer/chain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type Config struct {
LatestLockNumber int
NodeConfigs []*NodeConfig

LatestCodeId int
LatestCodeID int

t *testing.T
containerManager *containers.Manager
Expand All @@ -51,7 +51,7 @@ func New(t *testing.T, containerManager *containers.Manager, id string, initVali
numVal := float32(len(initValidatorConfigs))
return &Config{
ChainMeta: initialization.ChainMeta{
Id: id,
ID: id,
},
ValidatorInitConfigs: initValidatorConfigs,
VotingPeriod: config.PropDepositBlocks + numVal*config.PropVoteBlocks + config.PropBufferBlocks,
Expand All @@ -65,7 +65,7 @@ func New(t *testing.T, containerManager *containers.Manager, id string, initVali
func (c *Config) CreateNode(initNode *initialization.Node) *NodeConfig {
nodeConfig := &NodeConfig{
Node: *initNode,
chainID: c.Id,
chainID: c.ID,
containerManager: c.containerManager,
t: c.t,
}
Expand Down Expand Up @@ -115,15 +115,15 @@ func (c *Config) WaitForNumHeights(heightsToWait int64) {
}

func (c *Config) SendIBC(dstChain *Config, recipient string, token sdk.Coin) {
c.t.Logf("IBC sending %s from %s to %s (%s)", token, c.Id, dstChain.Id, recipient)
c.t.Logf("IBC sending %s from %s to %s (%s)", token, c.ID, dstChain.ID, recipient)

dstNode, err := dstChain.GetDefaultNode()
require.NoError(c.t, err)

balancesDstPre, err := dstNode.QueryBalances(recipient)
require.NoError(c.t, err)

cmd := []string{"hermes", "tx", "raw", "ft-transfer", dstChain.Id, c.Id, "transfer", "channel-0", token.Amount.String(), fmt.Sprintf("--denom=%s", token.Denom), fmt.Sprintf("--receiver=%s", recipient), "--timeout-height-offset=1000"}
cmd := []string{"hermes", "tx", "raw", "ft-transfer", dstChain.ID, c.ID, "transfer", "channel-0", token.Amount.String(), fmt.Sprintf("--denom=%s", token.Denom), fmt.Sprintf("--receiver=%s", recipient), "--timeout-height-offset=1000"}
_, _, err = c.containerManager.ExecHermesCmd2(c.t, cmd, "Success")
require.NoError(c.t, err)

Expand All @@ -139,9 +139,8 @@ func (c *Config) SendIBC(dstChain *Config, recipient string, token sdk.Coin) {
resPre := token.Amount
resPost := tokenPost.Sub(tokenPre)
return resPost.Uint64() == resPre.Uint64()
} else {
return false
}
return false
},
5*time.Minute,
time.Second,
Expand All @@ -152,15 +151,15 @@ func (c *Config) SendIBC(dstChain *Config, recipient string, token sdk.Coin) {
}

func (c *Config) SendIBC2(dstChain *Config, recipient string, token sdk.Coin) {
c.t.Logf("IBC sending %s from %s to %s (%s)", token, c.Id, dstChain.Id, recipient)
c.t.Logf("IBC sending %s from %s to %s (%s)", token, c.ID, dstChain.ID, recipient)

dstNode, err := dstChain.GetDefaultNode()
require.NoError(c.t, err)

balancesDstPre, err := dstNode.QueryBalances(recipient)
require.NoError(c.t, err)

cmd := []string{"hermes", "tx", "raw", "ft-transfer", dstChain.Id, c.Id, "transfer", "channel-0", token.Amount.String(), fmt.Sprintf("--denom=%s", token.Denom), fmt.Sprintf("--receiver=%s", recipient), "--timeout-height-offset=1000"}
cmd := []string{"hermes", "tx", "raw", "ft-transfer", dstChain.ID, c.ID, "transfer", "channel-0", token.Amount.String(), fmt.Sprintf("--denom=%s", token.Denom), fmt.Sprintf("--receiver=%s", recipient), "--timeout-height-offset=1000"}
_, _, err = c.containerManager.ExecHermesCmd2(c.t, cmd, "Success")
require.NoError(c.t, err)

Expand All @@ -176,9 +175,9 @@ func (c *Config) SendIBC2(dstChain *Config, recipient string, token sdk.Coin) {
resPre := token.Amount
resPost := tokenPost.Sub(tokenPre)
return resPost.Uint64() == resPre.Uint64()
} else {
return false
}

return false
},
5*time.Minute,
time.Second,
Expand All @@ -197,7 +196,7 @@ func (c *Config) GetDefaultNode() (*NodeConfig, error) {
func (c *Config) GetPersistentPeers() []string {
peers := make([]string, len(c.NodeConfigs))
for i, node := range c.NodeConfigs {
peers[i] = node.PeerId
peers[i] = node.PeerID
}
return peers
}
Expand All @@ -215,15 +214,15 @@ func (c *Config) AddBurnTaxExemptionAddressProposal(chainANode *NodeConfig, addr
Description: fmt.Sprintf("Add %s to the burn tax exemption address list", strings.Join(addresses, ",")),
Addresses: addresses,
}
proposalJson, err := json.Marshal(proposal)
proposalJSON, err := json.Marshal(proposal)
require.NoError(c.t, err)

wd, err := os.Getwd()
require.NoError(c.t, err)
localProposalFile := wd + "/scripts/add_burn_tax_exemption_address_proposal.json"
f, err := os.Create(localProposalFile)
require.NoError(c.t, err)
_, err = f.WriteString(string(proposalJson))
_, err = f.WriteString(string(proposalJSON))
require.NoError(c.t, err)
err = f.Close()
require.NoError(c.t, err)
Expand Down
26 changes: 13 additions & 13 deletions tests/e2e/configurer/chain/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ func (n *NodeConfig) StoreWasmCode(wasmFile, from string) {
n.LogActionF("successfully stored")
}

func (n *NodeConfig) InstantiateWasmContract(codeId, initMsg, amount, from string) {
n.LogActionF("instantiating wasm contract %s with %s", codeId, initMsg)
cmd := []string{"terrad", "tx", "wasm", "instantiate", codeId, initMsg, fmt.Sprintf("--from=%s", from), "--no-admin", "--label=ratelimit", "--gas=auto", "--gas-prices=0.0uluna", "--gas-adjustment=1.3"}
func (n *NodeConfig) InstantiateWasmContract(codeID, initMsg, amount, from string) {
n.LogActionF("instantiating wasm contract %s with %s", codeID, initMsg)
cmd := []string{"terrad", "tx", "wasm", "instantiate", codeID, initMsg, fmt.Sprintf("--from=%s", from), "--no-admin", "--label=ratelimit", "--gas=auto", "--gas-prices=0.0uluna", "--gas-adjustment=1.3"}
if amount != "" {
cmd = append(cmd, fmt.Sprintf("--amount=%s", amount))
}
Expand All @@ -44,11 +44,11 @@ func (n *NodeConfig) InstantiateWasmContract(codeId, initMsg, amount, from strin
n.LogActionF("successfully initialized")
}

func (n *NodeConfig) Instantiate2WasmContract(codeId, initMsg, salt, amount, fee, from string) {
n.LogActionF("instantiating wasm contract %s with %s", codeId, initMsg)
func (n *NodeConfig) Instantiate2WasmContract(codeID, initMsg, salt, amount, fee, from string) {
n.LogActionF("instantiating wasm contract %s with %s", codeID, initMsg)
encodedSalt := make([]byte, hex.EncodedLen(len([]byte(salt))))
hex.Encode(encodedSalt, []byte(salt))
cmd := []string{"terrad", "tx", "wasm", "instantiate2", codeId, initMsg, string(encodedSalt), fmt.Sprintf("--from=%s", from), "--no-admin", "--label=ratelimit", "--gas=auto", "--gas-prices=0.0uluna", "--gas-adjustment=1.3"}
cmd := []string{"terrad", "tx", "wasm", "instantiate2", codeID, initMsg, string(encodedSalt), fmt.Sprintf("--from=%s", from), "--no-admin", "--label=ratelimit", "--gas=auto", "--gas-prices=0.0uluna", "--gas-adjustment=1.3"}
if amount != "" {
cmd = append(cmd, fmt.Sprintf("--amount=%s", amount))
}
Expand Down Expand Up @@ -88,15 +88,15 @@ func (n *NodeConfig) QueryParams(subspace, key string, result any) {
require.NoError(n.t, err)
}

func (n *NodeConfig) SubmitParamChangeProposal(proposalJson, from string) {
n.LogActionF("submitting param change proposal %s", proposalJson)
func (n *NodeConfig) SubmitParamChangeProposal(proposalJSON, from string) {
n.LogActionF("submitting param change proposal %s", proposalJSON)
// ToDo: Is there a better way to do this?
wd, err := os.Getwd()
require.NoError(n.t, err)
localProposalFile := wd + "/scripts/param_change_proposal.json"
f, err := os.Create(localProposalFile)
require.NoError(n.t, err)
_, err = f.WriteString(proposalJson)
_, err = f.WriteString(proposalJSON)
require.NoError(n.t, err)
err = f.Close()
require.NoError(n.t, err)
Expand Down Expand Up @@ -126,11 +126,11 @@ func (n *NodeConfig) SubmitAddBurnTaxExemptionAddressProposal(addresses []string
resp, _, err := n.containerManager.ExecTxCmd(n.t, n.chainID, n.Name, cmd)
require.NoError(n.t, err)

proposalId, err := extractProposalIdFromResponse(resp.String())
proposalID, err := extractProposalIDFromResponse(resp.String())
require.NoError(n.t, err)

n.LogActionF("successfully submitted add burn tax exemption address proposal")
return proposalId
return proposalID
}

func (n *NodeConfig) FailIBCTransfer(from, recipient, amount string) {
Expand Down Expand Up @@ -208,7 +208,7 @@ func AllValsVoteOnProposal(chain *Config, propNumber int) {
}
}

func extractProposalIdFromResponse(response string) (int, error) {
func extractProposalIDFromResponse(response string) (int, error) {
// Extract the proposal ID from the response
startIndex := strings.Index(response, `[{"key":"proposal_id","value":"`) + len(`[{"key":"proposal_id","value":"`)
endIndex := strings.Index(response[startIndex:], `"`)
Expand Down Expand Up @@ -306,7 +306,7 @@ type resultStatus struct {
ValidatorInfo validatorInfo
}

func (n *NodeConfig) Status() (resultStatus, error) {
func (n *NodeConfig) Status() (resultStatus, error) { //nolint
cmd := []string{"terrad", "status"}
_, errBuf, err := n.containerManager.ExecCmd(n.t, n.Name, cmd, "")
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/configurer/chain/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ func (n *NodeConfig) extractOperatorAddressIfValidator() error {
return nil
}

func (n *NodeConfig) GetHostPort(portId string) (string, error) {
return n.containerManager.GetHostPort(n.Name, portId)
func (n *NodeConfig) GetHostPort(portID string) (string, error) {
return n.containerManager.GetHostPort(n.Name, portID)
}

func (n *NodeConfig) WithSetupTime(t time.Time) *NodeConfig {
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/configurer/chain/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ func (n *NodeConfig) QueryBurnTaxExemptionList() ([]string, error) {
return taxRateResp.Addresses, nil
}

func (n *NodeConfig) QueryContractsFromId(codeId int) ([]string, error) {
path := fmt.Sprintf("/cosmwasm/wasm/v1/code/%d/contracts", codeId)
func (n *NodeConfig) QueryContractsFromID(codeID int) ([]string, error) {
path := fmt.Sprintf("/cosmwasm/wasm/v1/code/%d/contracts", codeID)
bz, err := n.QueryGRPCGateway(path)

require.NoError(n.t, err)
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/configurer/current.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ func (cb *CurrentBranchConfigurer) ConfigureChains() error {
}

func (cb *CurrentBranchConfigurer) ConfigureChain(chainConfig *chain.Config) error {
cb.t.Logf("starting e2e infrastructure from current branch for chain-id: %s", chainConfig.Id)
cb.t.Logf("starting e2e infrastructure from current branch for chain-id: %s", chainConfig.ID)
tmpDir, err := os.MkdirTemp("", "terra-e2e-testnet-")
if err != nil {
return err
}
cb.t.Logf("temp directory for chain-id %v: %v", chainConfig.Id, tmpDir)
cb.t.Logf("temp directory for chain-id %v: %v", chainConfig.ID, tmpDir)

initializedChain, err := initialization.InitChain(chainConfig.Id, tmpDir, chainConfig.ValidatorInitConfigs, 0)
initializedChain, err := initialization.InitChain(chainConfig.ID, tmpDir, chainConfig.ValidatorInitConfigs, 0)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/configurer/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func New(t *testing.T, isIBCEnabled, isDebugLogEnabled bool, upgradeSettings Upg
if err != nil {
return nil, err
}
if isIBCEnabled && upgradeSettings.IsEnabled {
if isIBCEnabled && upgradeSettings.IsEnabled { //nolint
// skip none - configure two chains via Docker
// to utilize the older version of Terra to upgrade from
return NewUpgradeConfigurer(t,
Expand Down
Loading

0 comments on commit 31b2e55

Please sign in to comment.