Skip to content

Commit

Permalink
Add test with nested anys
Browse files Browse the repository at this point in the history
  • Loading branch information
amaury1093 committed Jan 17, 2022
1 parent 11ba488 commit 8f13e99
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion x/gov/types/v1beta2/proposals_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ package v1beta2_test
import (
"fmt"
"testing"
"time"

"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta2"
"github.com/stretchr/testify/require"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta2"
)

func TestProposalStatus_Format(t *testing.T) {
Expand All @@ -23,3 +27,16 @@ func TestProposalStatus_Format(t *testing.T) {
require.Equal(t, tt.expectedStringOutput, got)
}
}

// TestNestedAnys tests that we can call .String() on a struct with nested Anys.
// Here, we're creating a proposal which has a Msg (1st any) with a legacy
// content (2nd any).
func TestNestedAnys(t *testing.T) {
testProposal := v1beta1.NewTextProposal("Proposal", "testing proposal")
msgContent, err := v1beta2.NewLegacyContent(testProposal, "cosmos1govacct")
require.NoError(t, err)
proposal, err := v1beta2.NewProposal([]sdk.Msg{msgContent}, 1, time.Now(), time.Now())
require.NoError(t, err)

require.Equal(t, "TODO Fix panic here", proposal.String())
}

0 comments on commit 8f13e99

Please sign in to comment.