-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add host zone proposal interchain test (#122)
* test: add host zone proposal interchain test * test: add workflow config --------- Co-authored-by: Tien Nguyen <[email protected]>
- Loading branch information
1 parent
3a24c8e
commit affd690
Showing
9 changed files
with
671 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package feeabs | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"github.com/strangelove-ventures/interchaintest/v7/chain/cosmos" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
func DeleteHostZoneProposal(c *cosmos.CosmosChain, ctx context.Context, keyName string, fileLocation string) (string, error) { | ||
tn := c.Validators[0] | ||
if len(c.FullNodes) > 0 { | ||
tn = c.FullNodes[0] | ||
} | ||
dat, err := os.ReadFile(fileLocation) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to read file: %w", err) | ||
} | ||
|
||
fileName := "delete-hostzone.json" | ||
|
||
err = tn.WriteFile(ctx, dat, fileName) | ||
if err != nil { | ||
return "", fmt.Errorf("writing delete host zone proposal: %w", err) | ||
} | ||
|
||
filePath := filepath.Join(tn.HomeDir(), fileName) | ||
|
||
command := []string{ | ||
"gov", "submit-legacy-proposal", | ||
"delete-hostzone-config", filePath, | ||
} | ||
return tn.ExecTx(ctx, keyName, command...) | ||
} | ||
|
||
func SetHostZoneProposal(c *cosmos.CosmosChain, ctx context.Context, keyName string, fileLocation string) (string, error) { | ||
tn := c.Validators[0] | ||
if len(c.FullNodes) > 0 { | ||
tn = c.FullNodes[0] | ||
} | ||
dat, err := os.ReadFile(fileLocation) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to read file: %w", err) | ||
} | ||
|
||
fileName := "set-hostzone.json" | ||
|
||
err = tn.WriteFile(ctx, dat, fileName) | ||
if err != nil { | ||
return "", fmt.Errorf("writing set host zone proposal: %w", err) | ||
} | ||
|
||
filePath := filepath.Join(tn.HomeDir(), fileName) | ||
|
||
command := []string{ | ||
"gov", "submit-legacy-proposal", | ||
"set-hostzone-config", filePath, | ||
} | ||
return tn.ExecTx(ctx, keyName, command...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package feeabs | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"github.com/strangelove-ventures/interchaintest/v7/chain/cosmos" | ||
) | ||
|
||
type HostChainFeeAbsConfigResponse struct { | ||
HostChainConfig HostChainFeeAbsConfig `json:"host_chain_config"` | ||
} | ||
|
||
type HostChainFeeAbsConfig struct { | ||
IbcDenom string `json:"ibc_denom"` | ||
OsmosisPoolTokenDenomIn string `json:"osmosis_pool_token_denom_in"` | ||
PoolId string `json:"pool_id"` | ||
Frozen bool `json:"frozen"` | ||
} | ||
|
||
func QueryFeeabsHostZoneConfigWithDenom(c *cosmos.CosmosChain, ctx context.Context, denom string) (*HostChainFeeAbsConfigResponse, error) { | ||
cmd := []string{"feeabs", "host-chain-config", denom} | ||
stdout, _, err := c.ExecQuery(ctx, cmd) | ||
if err != nil { | ||
return &HostChainFeeAbsConfigResponse{}, err | ||
} | ||
|
||
var hostZoneConfig HostChainFeeAbsConfigResponse | ||
err = json.Unmarshal(stdout, &hostZoneConfig) | ||
if err != nil { | ||
return &HostChainFeeAbsConfigResponse{}, err | ||
} | ||
|
||
return &hostZoneConfig, nil | ||
} |
Oops, something went wrong.