From 8f13e992c18cadf4af426e63d41919ba8474cb6b Mon Sep 17 00:00:00 2001 From: Amaury M <1293565+amaurym@users.noreply.github.com> Date: Mon, 17 Jan 2022 18:23:13 +0100 Subject: [PATCH] Add test with nested anys --- x/gov/types/v1beta2/proposals_test.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/x/gov/types/v1beta2/proposals_test.go b/x/gov/types/v1beta2/proposals_test.go index f038ebfaf663..8055c5cac9dc 100644 --- a/x/gov/types/v1beta2/proposals_test.go +++ b/x/gov/types/v1beta2/proposals_test.go @@ -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) { @@ -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()) +}