Skip to content

Commit

Permalink
fix democ tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sainoe committed Sep 23, 2024
1 parent 27eaaff commit d6a6068
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/e2e/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ func (tr Chain) UpdateConsumer(providerChain ChainID, validator ValidatorID, upd
bz, err = cmd.CombinedOutput()
if err != nil {
fmt.Println("command failed: ", cmd)
log.Fatal("update consumer failed error: %w, output: %s", err, string(bz))
log.Fatalf("update consumer failed error: %s, output: %s", err, string(bz))
}

// Check transaction
Expand Down
25 changes: 21 additions & 4 deletions tests/e2e/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"regexp"
"sort"
"strconv"
"strings"
"time"

clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
Expand Down Expand Up @@ -285,12 +286,28 @@ func (tr Commands) GetReward(chain ChainID, validator ValidatorID, blockHeight u
log.Fatal("failed getting rewards: ", err, "\n", string(bz))
}

denomCondition := `total.#(denom!="stake").amount`
if isNativeDenom {
denomCondition = `total.#(denom=="stake").amount`
denom := "stake"
if !isNativeDenom {
denom = "ibc"
}

return gjson.Get(string(bz), denomCondition).Float()
denomCondition := fmt.Sprintf(`total.#(%%"*%s*")`, denom)
amount := strings.Split(gjson.Get(string(bz), denomCondition).String(), denom)[0]

fmt.Println("denomCondition:", denomCondition)
fmt.Println("json:", gjson.Parse(string(bz)))

res := float64(0)
if amount != "" {
res, err = strconv.ParseFloat(amount, 64)
if err != nil {
log.Fatal("failed parsing consumer reward:", err)
}
}

fmt.Println("res", res)

return res
}

// interchain-securityd query gov proposals
Expand Down

0 comments on commit d6a6068

Please sign in to comment.