Skip to content

Commit

Permalink
Add host zone proposal interchain test (#122)
Browse files Browse the repository at this point in the history
* test: add host zone proposal interchain test

* test: add workflow config

---------

Co-authored-by: Tien Nguyen <[email protected]>
  • Loading branch information
minhngoc274 and tnv1 authored Jan 17, 2024
1 parent 3a24c8e commit affd690
Show file tree
Hide file tree
Showing 9 changed files with 671 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .github/workflows/interchaintest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,19 @@ jobs:
- run: make ictest-packet-forward
env:
BRANCH_CI: 'latest'

test-host-zone-proposal:
runs-on: ubuntu-latest
needs: build-and-push-image
steps:
- name: Set up Go 1.21
uses: actions/setup-go@v3
with:
go-version: 1.21

- name: checkout code
uses: actions/checkout@v3

- run: make ictest-host-zone-proposal
env:
BRANCH_CI: 'latest'
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ ictest-ibc:
ictest-packet-forward:
cd tests/interchaintest && go test -timeout=25m -race -v -run TestPacketForwardMiddleware .

ictest-host-zone-proposal:
cd tests/interchaintest && go test -timeout=25m -race -v -run TestHostZoneProposal .

# Executes all tests via interchaintest after compling a local image as juno:local
ictest-all: ictest-basic ictest-ibc ictest-packet-forward

Expand Down
61 changes: 61 additions & 0 deletions tests/interchaintest/feeabs/proposal.go
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...)
}
34 changes: 34 additions & 0 deletions tests/interchaintest/feeabs/query.go
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
}
Loading

0 comments on commit affd690

Please sign in to comment.