Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
atheeshp committed Feb 22, 2024
1 parent 4206c71 commit 1467cbb
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
16 changes: 16 additions & 0 deletions tests/integration/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,19 @@ func QueryResourceCollection(collectionID string) (resourcetypes.QueryCollection

return resp, nil
}

func QueryTxn(hash string) (sdk.TxResponse, error) {
res, err := Query("tx", hash)
if err != nil {
return sdk.TxResponse{}, err
}

var resp sdk.TxResponse
err = helpers.Codec.UnmarshalJSON([]byte(res), &resp)

Check failure on line 128 in tests/integration/cli/query.go

View workflow job for this annotation

GitHub Actions / Lint / Golang

File is not `gofumpt`-ed (gofumpt)
if err != nil {
return sdk.TxResponse{}, err
}

return resp, nil
}
15 changes: 12 additions & 3 deletions tests/integration/cli_resource_pricing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ var _ = Describe("cheqd cli - positive resource pricing", func() {
Expect(diff).To(Equal(tax.Amount))

By("exporting a readable tx event log")
events := helpers.ReadableEvents(res.Events)
txResp, err := cli.QueryTxn(res.TxHash)
Expect(err).To(BeNil())

events := helpers.ReadableEvents(txResp.Events)

By("ensuring the events contain the expected tax event")
Expect(events).To(ContainElement(
Expand Down Expand Up @@ -187,7 +190,10 @@ var _ = Describe("cheqd cli - positive resource pricing", func() {
Expect(diff).To(Equal(tax.Amount))

By("exporting a readable tx event log")
events := helpers.ReadableEvents(res.Events)
txResp, err := cli.QueryTxn(res.TxHash)
Expect(err).To(BeNil())

events := helpers.ReadableEvents(txResp.Events)

By("ensuring the events contain the expected tax event")
Expect(events).To(ContainElement(
Expand Down Expand Up @@ -262,7 +268,10 @@ var _ = Describe("cheqd cli - positive resource pricing", func() {
Expect(diff).To(Equal(tax.Amount))

By("exporting a readable tx event log")
events := helpers.ReadableEvents(res.Events)
txResp, err := cli.QueryTxn(res.TxHash)
Expect(err).To(BeNil())

events := helpers.ReadableEvents(txResp.Events)

By("ensuring the events contain the expected tax event")
Expect(events).To(ContainElement(
Expand Down
7 changes: 7 additions & 0 deletions tests/integration/helpers/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ package helpers

import (
"github.com/cheqd/cheqd-node/app/params"
didtypes "github.com/cheqd/cheqd-node/x/did/types"
resourcetypes "github.com/cheqd/cheqd-node/x/resource/types"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/std"
)

var (
Expand All @@ -13,6 +16,10 @@ var (

func init() {
encodingConfig := params.MakeEncodingConfig()
std.RegisterLegacyAminoCodec(encodingConfig.Amino)
std.RegisterInterfaces(encodingConfig.InterfaceRegistry)
resourcetypes.RegisterInterfaces(encodingConfig.InterfaceRegistry)
didtypes.RegisterInterfaces(encodingConfig.InterfaceRegistry)
Codec = encodingConfig.Codec
Registry = encodingConfig.InterfaceRegistry
}

0 comments on commit 1467cbb

Please sign in to comment.