From f26c56bbcbefe37c872c0db12fe88b560832c730 Mon Sep 17 00:00:00 2001
From: Youngtaek Yoon <noreply@yoon.anonaddy.me>
Date: Mon, 26 Dec 2022 02:04:46 +0000
Subject: [PATCH] fix: apply foundation audit (#834)

* Fix the field number

* Chore

* Fix RegisterInvariants

* Lint

* Use Run() in the tests

* Update CHANGELOG.md

* Revert breaking change

This reverts commit dba350954b4d7a5abd897a2c59b286ed22e64bec.
---
 CHANGELOG.md                           |   2 +
 x/foundation/authz_test.go             |  18 +-
 x/foundation/foundation_test.go        | 276 ++++++++++---------
 x/foundation/genesis.go                |   6 +-
 x/foundation/keeper/abci_test.go       |  28 +-
 x/foundation/keeper/invariants.go      |  10 +-
 x/foundation/keeper/invariants_test.go |  48 ++--
 x/foundation/keeper/keeper_test.go     |  29 +-
 x/foundation/msgs_test.go              | 366 +++++++++++++------------
 9 files changed, 423 insertions(+), 360 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0698be69d2..5918fe20fa 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -46,6 +46,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
 ### Bug Fixes
 * (client) [\#817](https://github.com/line/lbm-sdk/pull/817) remove support for composite (BLS) type
 
+* (x/foundation) [#834](https://github.com/line/lbm-sdk/pull/834) Apply foundation audit
+
 ### Breaking Changes
 * (rest) [\#807](https://github.com/line/lbm-sdk/pull/807) remove legacy REST API
 
diff --git a/x/foundation/authz_test.go b/x/foundation/authz_test.go
index 88b01fc893..92b29b2757 100644
--- a/x/foundation/authz_test.go
+++ b/x/foundation/authz_test.go
@@ -25,15 +25,17 @@ func TestReceiveFromTreasuryAuthorization(t *testing.T) {
 	}
 
 	for name, tc := range testCases {
-		authorization := &foundation.ReceiveFromTreasuryAuthorization{}
+		t.Run(name, func(t *testing.T) {
+			authorization := &foundation.ReceiveFromTreasuryAuthorization{}
 
-		resp, err := authorization.Accept(sdk.Context{}, tc.msg)
-		if !tc.valid {
-			require.Error(t, err, name)
-			continue
-		}
-		require.NoError(t, err, name)
+			resp, err := authorization.Accept(sdk.Context{}, tc.msg)
+			if !tc.valid {
+				require.Error(t, err)
+				return
+			}
+			require.NoError(t, err)
 
-		require.Equal(t, tc.accept, resp.Accept)
+			require.Equal(t, tc.accept, resp.Accept)
+		})
 	}
 }
diff --git a/x/foundation/foundation_test.go b/x/foundation/foundation_test.go
index ab1609b9dc..81a66ef4db 100644
--- a/x/foundation/foundation_test.go
+++ b/x/foundation/foundation_test.go
@@ -82,31 +82,33 @@ func TestThresholdDecisionPolicy(t *testing.T) {
 	}
 
 	for name, tc := range testCases {
-		policy := foundation.ThresholdDecisionPolicy{
-			Threshold: tc.threshold,
-			Windows: &foundation.DecisionPolicyWindows{
-				VotingPeriod:       tc.votingPeriod,
-				MinExecutionPeriod: tc.minExecutionPeriod,
-			},
-		}
-		require.Equal(t, tc.votingPeriod, policy.GetVotingPeriod())
-
-		err := policy.ValidateBasic()
-		if !tc.validBasic {
-			require.Error(t, err, name)
-			continue
-		}
-		require.NoError(t, err, name)
-
-		info := foundation.FoundationInfo{
-			TotalWeight: tc.totalWeight,
-		}
-		err = policy.Validate(info, config)
-		if !tc.valid {
-			require.Error(t, err, name)
-			continue
-		}
-		require.NoError(t, err, name)
+		t.Run(name, func(t *testing.T) {
+			policy := foundation.ThresholdDecisionPolicy{
+				Threshold: tc.threshold,
+				Windows: &foundation.DecisionPolicyWindows{
+					VotingPeriod:       tc.votingPeriod,
+					MinExecutionPeriod: tc.minExecutionPeriod,
+				},
+			}
+			require.Equal(t, tc.votingPeriod, policy.GetVotingPeriod())
+
+			err := policy.ValidateBasic()
+			if !tc.validBasic {
+				require.Error(t, err)
+				return
+			}
+			require.NoError(t, err)
+
+			info := foundation.FoundationInfo{
+				TotalWeight: tc.totalWeight,
+			}
+			err = policy.Validate(info, config)
+			if !tc.valid {
+				require.Error(t, err)
+				return
+			}
+			require.NoError(t, err)
+		})
 	}
 }
 
@@ -171,17 +173,19 @@ func TestThresholdDecisionPolicyAllow(t *testing.T) {
 	}
 
 	for name, tc := range testCases {
-		result, err := policy.Allow(tc.tally, tc.totalWeight, tc.sinceSubmission)
-		if !tc.valid {
-			require.Error(t, err, name)
-			continue
-		}
-		require.NoError(t, err, name)
-
-		require.Equal(t, tc.final, result.Final, name)
-		if tc.final {
-			require.Equal(t, tc.allow, result.Allow, name)
-		}
+		t.Run(name, func(t *testing.T) {
+			result, err := policy.Allow(tc.tally, tc.totalWeight, tc.sinceSubmission)
+			if !tc.valid {
+				require.Error(t, err)
+				return
+			}
+			require.NoError(t, err)
+
+			require.Equal(t, tc.final, result.Final)
+			if tc.final {
+				require.Equal(t, tc.allow, result.Allow)
+			}
+		})
 	}
 }
 
@@ -231,31 +235,33 @@ func TestPercentageDecisionPolicy(t *testing.T) {
 	}
 
 	for name, tc := range testCases {
-		policy := foundation.PercentageDecisionPolicy{
-			Percentage: tc.percentage,
-			Windows: &foundation.DecisionPolicyWindows{
-				VotingPeriod:       tc.votingPeriod,
-				MinExecutionPeriod: tc.minExecutionPeriod,
-			},
-		}
-		require.Equal(t, tc.votingPeriod, policy.GetVotingPeriod())
-
-		err := policy.ValidateBasic()
-		if !tc.validBasic {
-			require.Error(t, err, name)
-			continue
-		}
-		require.NoError(t, err, name)
-
-		info := foundation.FoundationInfo{
-			TotalWeight: tc.totalWeight,
-		}
-		err = policy.Validate(info, config)
-		if !tc.valid {
-			require.Error(t, err, name)
-			continue
-		}
-		require.NoError(t, err, name)
+		t.Run(name, func(t *testing.T) {
+			policy := foundation.PercentageDecisionPolicy{
+				Percentage: tc.percentage,
+				Windows: &foundation.DecisionPolicyWindows{
+					VotingPeriod:       tc.votingPeriod,
+					MinExecutionPeriod: tc.minExecutionPeriod,
+				},
+			}
+			require.Equal(t, tc.votingPeriod, policy.GetVotingPeriod())
+
+			err := policy.ValidateBasic()
+			if !tc.validBasic {
+				require.Error(t, err)
+				return
+			}
+			require.NoError(t, err)
+
+			info := foundation.FoundationInfo{
+				TotalWeight: tc.totalWeight,
+			}
+			err = policy.Validate(info, config)
+			if !tc.valid {
+				require.Error(t, err)
+				return
+			}
+			require.NoError(t, err)
+		})
 	}
 }
 
@@ -321,17 +327,19 @@ func TestPercentageDecisionPolicyAllow(t *testing.T) {
 	}
 
 	for name, tc := range testCases {
-		result, err := policy.Allow(tc.tally, totalWeight, tc.sinceSubmission)
-		if !tc.valid {
-			require.Error(t, err, name)
-			continue
-		}
-		require.NoError(t, err, name)
-
-		require.Equal(t, tc.final, result.Final, name)
-		if tc.final {
-			require.Equal(t, tc.allow, result.Allow, name)
-		}
+		t.Run(name, func(t *testing.T) {
+			result, err := policy.Allow(tc.tally, totalWeight, tc.sinceSubmission)
+			if !tc.valid {
+				require.Error(t, err)
+				return
+			}
+			require.NoError(t, err)
+
+			require.Equal(t, tc.final, result.Final)
+			if tc.final {
+				require.Equal(t, tc.allow, result.Allow)
+			}
+		})
 	}
 }
 
@@ -372,13 +380,15 @@ func TestMembers(t *testing.T) {
 	}
 
 	for name, tc := range testCases {
-		members := foundation.Members{tc.members}
-		err := members.ValidateBasic()
-		if !tc.valid {
-			require.Error(t, err, name)
-			continue
-		}
-		require.NoError(t, err, name)
+		t.Run(name, func(t *testing.T) {
+			members := foundation.Members{tc.members}
+			err := members.ValidateBasic()
+			if !tc.valid {
+				require.Error(t, err)
+				return
+			}
+			require.NoError(t, err)
+		})
 	}
 }
 
@@ -421,13 +431,15 @@ func TestMemberRequests(t *testing.T) {
 	}
 
 	for name, tc := range testCases {
-		requests := foundation.MemberRequests{tc.members}
-		err := requests.ValidateBasic()
-		if !tc.valid {
-			require.Error(t, err, name)
-			continue
-		}
-		require.NoError(t, err, name)
+		t.Run(name, func(t *testing.T) {
+			requests := foundation.MemberRequests{tc.members}
+			err := requests.ValidateBasic()
+			if !tc.valid {
+				require.Error(t, err)
+				return
+			}
+			require.NoError(t, err)
+		})
 	}
 }
 
@@ -524,19 +536,21 @@ func TestProposal(t *testing.T) {
 	}
 
 	for name, tc := range testCases {
-		proposal := foundation.Proposal{
-			Id:                tc.id,
-			Proposers:         tc.proposers,
-			FoundationVersion: tc.version,
-		}.WithMsgs(tc.msgs)
-		require.NotNil(t, proposal)
-
-		err := proposal.ValidateBasic()
-		if !tc.valid {
-			require.Error(t, err, name)
-			continue
-		}
-		require.NoError(t, err, name)
+		t.Run(name, func(t *testing.T) {
+			proposal := foundation.Proposal{
+				Id:                tc.id,
+				Proposers:         tc.proposers,
+				FoundationVersion: tc.version,
+			}.WithMsgs(tc.msgs)
+			require.NotNil(t, proposal)
+
+			err := proposal.ValidateBasic()
+			if !tc.valid {
+				require.Error(t, err)
+				return
+			}
+			require.NoError(t, err)
+		})
 	}
 }
 
@@ -555,25 +569,27 @@ func TestOutsourcingDecisionPolicy(t *testing.T) {
 	}
 
 	for name, tc := range testCases {
-		policy := foundation.OutsourcingDecisionPolicy{}
-		require.Zero(t, policy.GetVotingPeriod())
-
-		err := policy.ValidateBasic()
-		if !tc.validBasic {
-			require.Error(t, err, name)
-			continue
-		}
-		require.NoError(t, err, name)
-
-		info := foundation.FoundationInfo{
-			TotalWeight: tc.totalWeight,
-		}
-		err = policy.Validate(info, config)
-		if !tc.valid {
-			require.Error(t, err, name)
-			continue
-		}
-		require.NoError(t, err, name)
+		t.Run(name, func(t *testing.T) {
+			policy := foundation.OutsourcingDecisionPolicy{}
+			require.Zero(t, policy.GetVotingPeriod())
+
+			err := policy.ValidateBasic()
+			if !tc.validBasic {
+				require.Error(t, err)
+				return
+			}
+			require.NoError(t, err)
+
+			info := foundation.FoundationInfo{
+				TotalWeight: tc.totalWeight,
+			}
+			err = policy.Validate(info, config)
+			if !tc.valid {
+				require.Error(t, err)
+				return
+			}
+			require.NoError(t, err)
+		})
 	}
 }
 
@@ -604,16 +620,18 @@ func TestOutsourcingDecisionPolicyAllow(t *testing.T) {
 	}
 
 	for name, tc := range testCases {
-		result, err := policy.Allow(tc.tally, tc.totalWeight, tc.sinceSubmission)
-		if !tc.valid {
-			require.Error(t, err, name)
-			continue
-		}
-		require.NoError(t, err, name)
-
-		require.Equal(t, tc.final, result.Final, name)
-		if tc.final {
-			require.Equal(t, tc.allow, result.Allow, name)
-		}
+		t.Run(name, func(t *testing.T) {
+			result, err := policy.Allow(tc.tally, tc.totalWeight, tc.sinceSubmission)
+			if !tc.valid {
+				require.Error(t, err)
+				return
+			}
+			require.NoError(t, err)
+
+			require.Equal(t, tc.final, result.Final)
+			if tc.final {
+				require.Equal(t, tc.allow, result.Allow)
+			}
+		})
 	}
 }
diff --git a/x/foundation/genesis.go b/x/foundation/genesis.go
index 81497de1e8..f62c8a94a3 100644
--- a/x/foundation/genesis.go
+++ b/x/foundation/genesis.go
@@ -75,11 +75,11 @@ func (i FoundationInfo) ValidateBasic() error {
 
 	// Is foundation outsourcing the proposal feature
 	_, isOutsourcing := i.GetDecisionPolicy().(*OutsourcingDecisionPolicy)
-	memberExists := !i.TotalWeight.IsZero()
-	if isOutsourcing && memberExists {
+	memberNotExists := i.TotalWeight.IsZero()
+	if isOutsourcing && !memberNotExists {
 		return sdkerrors.ErrInvalidRequest.Wrap("outsourcing policy not allows members")
 	}
-	if !isOutsourcing && !memberExists {
+	if !isOutsourcing && memberNotExists {
 		return sdkerrors.ErrInvalidRequest.Wrap("one member must exist at least")
 	}
 
diff --git a/x/foundation/keeper/abci_test.go b/x/foundation/keeper/abci_test.go
index 80a7572024..b62a2b419c 100644
--- a/x/foundation/keeper/abci_test.go
+++ b/x/foundation/keeper/abci_test.go
@@ -54,10 +54,12 @@ func (s *KeeperTestSuite) TestEndBlocker() {
 			foundation.PROPOSAL_STATUS_SUBMITTED,
 		},
 	} {
-		proposal, err := s.keeper.GetProposal(ctx, tc.id)
-		s.Require().NoError(err, name)
-		s.Require().NotNil(proposal, name)
-		s.Require().Equal(tc.status, proposal.Status, name)
+		s.Run(name, func() {
+			proposal, err := s.keeper.GetProposal(ctx, tc.id)
+			s.Require().NoError(err)
+			s.Require().NotNil(proposal)
+			s.Require().Equal(tc.status, proposal.Status)
+		})
 	}
 
 	// voting periods end
@@ -87,14 +89,16 @@ func (s *KeeperTestSuite) TestEndBlocker() {
 			status: foundation.PROPOSAL_STATUS_ACCEPTED,
 		},
 	} {
-		proposal, err := s.keeper.GetProposal(ctx, tc.id)
-		if tc.removed {
-			s.Require().Error(err, name)
-			continue
-		}
-		s.Require().NoError(err, name)
-		s.Require().NotNil(proposal, name)
-		s.Require().Equal(tc.status, proposal.Status, name)
+		s.Run(name, func() {
+			proposal, err := s.keeper.GetProposal(ctx, tc.id)
+			if tc.removed {
+				s.Require().Error(err)
+				return
+			}
+			s.Require().NoError(err)
+			s.Require().NotNil(proposal)
+			s.Require().Equal(tc.status, proposal.Status)
+		})
 	}
 
 	// proposals expire
diff --git a/x/foundation/keeper/invariants.go b/x/foundation/keeper/invariants.go
index 1cd30e45d6..7c7d224666 100644
--- a/x/foundation/keeper/invariants.go
+++ b/x/foundation/keeper/invariants.go
@@ -14,9 +14,13 @@ const (
 )
 
 func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper) {
-	ir.RegisterRoute(foundation.ModuleName, moduleAccountInvariant, ModuleAccountInvariant(k))
-	ir.RegisterRoute(foundation.ModuleName, totalWeightInvariant, ProposalInvariant(k))
-	ir.RegisterRoute(foundation.ModuleName, proposalInvariant, ProposalInvariant(k))
+	for name, invariant := range map[string]func(k Keeper) sdk.Invariant{
+		moduleAccountInvariant: ModuleAccountInvariant,
+		totalWeightInvariant:   TotalWeightInvariant,
+		proposalInvariant:      ProposalInvariant,
+	} {
+		ir.RegisterRoute(foundation.ModuleName, name, invariant(k))
+	}
 }
 
 func ModuleAccountInvariant(k Keeper) sdk.Invariant {
diff --git a/x/foundation/keeper/invariants_test.go b/x/foundation/keeper/invariants_test.go
index 2a43c0302b..f7aee23d0b 100644
--- a/x/foundation/keeper/invariants_test.go
+++ b/x/foundation/keeper/invariants_test.go
@@ -25,14 +25,16 @@ func (s *KeeperTestSuite) TestModuleAccountInvariant() {
 	}
 
 	for name, tc := range testCases {
-		ctx, _ := s.ctx.CacheContext()
-		if tc.malleate != nil {
-			tc.malleate(ctx)
-		}
+		s.Run(name, func() {
+			ctx, _ := s.ctx.CacheContext()
+			if tc.malleate != nil {
+				tc.malleate(ctx)
+			}
 
-		invariant := keeper.ModuleAccountInvariant(s.keeper)
-		_, broken := invariant(ctx)
-		s.Require().Equal(!tc.valid, broken, name)
+			invariant := keeper.ModuleAccountInvariant(s.keeper)
+			_, broken := invariant(ctx)
+			s.Require().Equal(!tc.valid, broken)
+		})
 	}
 }
 
@@ -55,14 +57,16 @@ func (s *KeeperTestSuite) TestTotalWeightInvariant() {
 	}
 
 	for name, tc := range testCases {
-		ctx, _ := s.ctx.CacheContext()
-		if tc.malleate != nil {
-			tc.malleate(ctx)
-		}
+		s.Run(name, func() {
+			ctx, _ := s.ctx.CacheContext()
+			if tc.malleate != nil {
+				tc.malleate(ctx)
+			}
 
-		invariant := keeper.TotalWeightInvariant(s.keeper)
-		_, broken := invariant(ctx)
-		s.Require().Equal(!tc.valid, broken, name)
+			invariant := keeper.TotalWeightInvariant(s.keeper)
+			_, broken := invariant(ctx)
+			s.Require().Equal(!tc.valid, broken)
+		})
 	}
 }
 
@@ -84,13 +88,15 @@ func (s *KeeperTestSuite) TestProposalInvariant() {
 	}
 
 	for name, tc := range testCases {
-		ctx, _ := s.ctx.CacheContext()
-		if tc.malleate != nil {
-			tc.malleate(ctx)
-		}
+		s.Run(name, func() {
+			ctx, _ := s.ctx.CacheContext()
+			if tc.malleate != nil {
+				tc.malleate(ctx)
+			}
 
-		invariant := keeper.ProposalInvariant(s.keeper)
-		_, broken := invariant(ctx)
-		s.Require().Equal(!tc.valid, broken, name)
+			invariant := keeper.ProposalInvariant(s.keeper)
+			_, broken := invariant(ctx)
+			s.Require().Equal(!tc.valid, broken)
+		})
 	}
 }
diff --git a/x/foundation/keeper/keeper_test.go b/x/foundation/keeper/keeper_test.go
index 3ac7e0aa78..24a76d3ca4 100644
--- a/x/foundation/keeper/keeper_test.go
+++ b/x/foundation/keeper/keeper_test.go
@@ -222,19 +222,20 @@ func TestNewKeeper(t *testing.T) {
 
 	for name, tc := range testCases {
 		tc := tc
-
-		newKeeper := func() keeper.Keeper {
-			app := simapp.Setup(false)
-			return keeper.NewKeeper(app.AppCodec(), sdk.NewKVStoreKey(foundation.StoreKey), app.MsgServiceRouter(), app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, foundation.DefaultConfig(), tc.authority.String())
-		}
-
-		if tc.panics {
-			require.Panics(t, func() { newKeeper() }, name)
-			continue
-		}
-		require.NotPanics(t, func() { newKeeper() }, name)
-
-		k := newKeeper()
-		require.Equal(t, authority.String(), k.GetAuthority(), name)
+		t.Run(name, func(t *testing.T) {
+			newKeeper := func() keeper.Keeper {
+				app := simapp.Setup(false)
+				return keeper.NewKeeper(app.AppCodec(), sdk.NewKVStoreKey(foundation.StoreKey), app.MsgServiceRouter(), app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, foundation.DefaultConfig(), tc.authority.String())
+			}
+
+			if tc.panics {
+				require.Panics(t, func() { newKeeper() })
+				return
+			}
+			require.NotPanics(t, func() { newKeeper() })
+
+			k := newKeeper()
+			require.Equal(t, authority.String(), k.GetAuthority())
+		})
 	}
 }
diff --git a/x/foundation/msgs_test.go b/x/foundation/msgs_test.go
index f9e5e3f691..f2dafa44d2 100644
--- a/x/foundation/msgs_test.go
+++ b/x/foundation/msgs_test.go
@@ -44,19 +44,21 @@ func TestMsgUpdateParams(t *testing.T) {
 	}
 
 	for name, tc := range testCases {
-		msg := foundation.MsgUpdateParams{
-			Authority: tc.authority.String(),
-			Params:    tc.params,
-		}
+		t.Run(name, func(t *testing.T) {
+			msg := foundation.MsgUpdateParams{
+				Authority: tc.authority.String(),
+				Params:    tc.params,
+			}
 
-		err := msg.ValidateBasic()
-		if !tc.valid {
-			require.Error(t, err, name)
-			continue
-		}
-		require.NoError(t, err, name)
+			err := msg.ValidateBasic()
+			if !tc.valid {
+				require.Error(t, err)
+				return
+			}
+			require.NoError(t, err)
 
-		require.Equal(t, []sdk.AccAddress{tc.authority}, msg.GetSigners(), name)
+			require.Equal(t, []sdk.AccAddress{tc.authority}, msg.GetSigners())
+		})
 	}
 }
 
@@ -86,19 +88,21 @@ func TestMsgFundTreasury(t *testing.T) {
 	}
 
 	for name, tc := range testCases {
-		msg := foundation.MsgFundTreasury{
-			From:   tc.from.String(),
-			Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, tc.amount)),
-		}
+		t.Run(name, func(t *testing.T) {
+			msg := foundation.MsgFundTreasury{
+				From:   tc.from.String(),
+				Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, tc.amount)),
+			}
 
-		err := msg.ValidateBasic()
-		if !tc.valid {
-			require.Error(t, err, name)
-			continue
-		}
-		require.NoError(t, err, name)
+			err := msg.ValidateBasic()
+			if !tc.valid {
+				require.Error(t, err)
+				return
+			}
+			require.NoError(t, err)
 
-		require.Equal(t, []sdk.AccAddress{tc.from}, msg.GetSigners(), name)
+			require.Equal(t, []sdk.AccAddress{tc.from}, msg.GetSigners())
+		})
 	}
 }
 
@@ -136,20 +140,22 @@ func TestMsgWithdrawFromTreasury(t *testing.T) {
 	}
 
 	for name, tc := range testCases {
-		msg := foundation.MsgWithdrawFromTreasury{
-			Authority: tc.authority.String(),
-			To:        tc.to.String(),
-			Amount:    sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, tc.amount)),
-		}
+		t.Run(name, func(t *testing.T) {
+			msg := foundation.MsgWithdrawFromTreasury{
+				Authority: tc.authority.String(),
+				To:        tc.to.String(),
+				Amount:    sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, tc.amount)),
+			}
 
-		err := msg.ValidateBasic()
-		if !tc.valid {
-			require.Error(t, err, name)
-			continue
-		}
-		require.NoError(t, err, name)
+			err := msg.ValidateBasic()
+			if !tc.valid {
+				require.Error(t, err)
+				return
+			}
+			require.NoError(t, err)
 
-		require.Equal(t, []sdk.AccAddress{tc.authority}, msg.GetSigners(), name)
+			require.Equal(t, []sdk.AccAddress{tc.authority}, msg.GetSigners())
+		})
 	}
 }
 
@@ -186,19 +192,21 @@ func TestMsgUpdateMembers(t *testing.T) {
 	}
 
 	for name, tc := range testCases {
-		msg := foundation.MsgUpdateMembers{
-			Authority:     tc.authority.String(),
-			MemberUpdates: tc.members,
-		}
+		t.Run(name, func(t *testing.T) {
+			msg := foundation.MsgUpdateMembers{
+				Authority:     tc.authority.String(),
+				MemberUpdates: tc.members,
+			}
 
-		err := msg.ValidateBasic()
-		if !tc.valid {
-			require.Error(t, err, name)
-			continue
-		}
-		require.NoError(t, err, name)
+			err := msg.ValidateBasic()
+			if !tc.valid {
+				require.Error(t, err)
+				return
+			}
+			require.NoError(t, err)
 
-		require.Equal(t, []sdk.AccAddress{tc.authority}, msg.GetSigners(), name)
+			require.Equal(t, []sdk.AccAddress{tc.authority}, msg.GetSigners())
+		})
 	}
 }
 
@@ -272,22 +280,24 @@ func TestMsgUpdateDecisionPolicy(t *testing.T) {
 	}
 
 	for name, tc := range testCases {
-		msg := foundation.MsgUpdateDecisionPolicy{
-			Authority: tc.authority.String(),
-		}
-		if tc.policy != nil {
-			err := msg.SetDecisionPolicy(tc.policy)
-			require.NoError(t, err, name)
-		}
-
-		err := msg.ValidateBasic()
-		if !tc.valid {
-			require.Error(t, err, name)
-			continue
-		}
-		require.NoError(t, err, name)
-
-		require.Equal(t, []sdk.AccAddress{tc.authority}, msg.GetSigners(), name)
+		t.Run(name, func(t *testing.T) {
+			msg := foundation.MsgUpdateDecisionPolicy{
+				Authority: tc.authority.String(),
+			}
+			if tc.policy != nil {
+				err := msg.SetDecisionPolicy(tc.policy)
+				require.NoError(t, err)
+			}
+
+			err := msg.ValidateBasic()
+			if !tc.valid {
+				require.Error(t, err)
+				return
+			}
+			require.NoError(t, err)
+
+			require.Equal(t, []sdk.AccAddress{tc.authority}, msg.GetSigners())
+		})
 	}
 }
 
@@ -334,26 +344,28 @@ func TestMsgSubmitProposal(t *testing.T) {
 	}
 
 	for name, tc := range testCases {
-		var proposers []string
-		for _, proposer := range tc.proposers {
-			proposers = append(proposers, proposer.String())
-		}
-
-		msg := foundation.MsgSubmitProposal{
-			Proposers: proposers,
-			Exec:      tc.exec,
-		}
-		err := msg.SetMsgs(tc.msgs)
-		require.NoError(t, err, name)
-
-		err = msg.ValidateBasic()
-		if !tc.valid {
-			require.Error(t, err, name)
-			continue
-		}
-		require.NoError(t, err, name)
-
-		require.Equal(t, tc.proposers, msg.GetSigners(), name)
+		t.Run(name, func(t *testing.T) {
+			var proposers []string
+			for _, proposer := range tc.proposers {
+				proposers = append(proposers, proposer.String())
+			}
+
+			msg := foundation.MsgSubmitProposal{
+				Proposers: proposers,
+				Exec:      tc.exec,
+			}
+			err := msg.SetMsgs(tc.msgs)
+			require.NoError(t, err)
+
+			err = msg.ValidateBasic()
+			if !tc.valid {
+				require.Error(t, err)
+				return
+			}
+			require.NoError(t, err)
+
+			require.Equal(t, tc.proposers, msg.GetSigners())
+		})
 	}
 }
 
@@ -382,19 +394,21 @@ func TestMsgWithdrawProposal(t *testing.T) {
 	}
 
 	for name, tc := range testCases {
-		msg := foundation.MsgWithdrawProposal{
-			ProposalId: tc.id,
-			Address:    tc.address.String(),
-		}
+		t.Run(name, func(t *testing.T) {
+			msg := foundation.MsgWithdrawProposal{
+				ProposalId: tc.id,
+				Address:    tc.address.String(),
+			}
 
-		err := msg.ValidateBasic()
-		if !tc.valid {
-			require.Error(t, err, name)
-			continue
-		}
-		require.NoError(t, err, name)
+			err := msg.ValidateBasic()
+			if !tc.valid {
+				require.Error(t, err)
+				return
+			}
+			require.NoError(t, err)
 
-		require.Equal(t, []sdk.AccAddress{tc.address}, msg.GetSigners(), name)
+			require.Equal(t, []sdk.AccAddress{tc.address}, msg.GetSigners())
+		})
 	}
 }
 
@@ -443,21 +457,23 @@ func TestMsgVote(t *testing.T) {
 	}
 
 	for name, tc := range testCases {
-		msg := foundation.MsgVote{
-			ProposalId: tc.id,
-			Voter:      tc.voter.String(),
-			Option:     tc.option,
-			Exec:       tc.exec,
-		}
-
-		err := msg.ValidateBasic()
-		if !tc.valid {
-			require.Error(t, err, name)
-			continue
-		}
-		require.NoError(t, err, name)
-
-		require.Equal(t, []sdk.AccAddress{tc.voter}, msg.GetSigners(), name)
+		t.Run(name, func(t *testing.T) {
+			msg := foundation.MsgVote{
+				ProposalId: tc.id,
+				Voter:      tc.voter.String(),
+				Option:     tc.option,
+				Exec:       tc.exec,
+			}
+
+			err := msg.ValidateBasic()
+			if !tc.valid {
+				require.Error(t, err)
+				return
+			}
+			require.NoError(t, err)
+
+			require.Equal(t, []sdk.AccAddress{tc.voter}, msg.GetSigners())
+		})
 	}
 }
 
@@ -486,19 +502,21 @@ func TestMsgExec(t *testing.T) {
 	}
 
 	for name, tc := range testCases {
-		msg := foundation.MsgExec{
-			ProposalId: tc.id,
-			Signer:     tc.signer.String(),
-		}
+		t.Run(name, func(t *testing.T) {
+			msg := foundation.MsgExec{
+				ProposalId: tc.id,
+				Signer:     tc.signer.String(),
+			}
 
-		err := msg.ValidateBasic()
-		if !tc.valid {
-			require.Error(t, err, name)
-			continue
-		}
-		require.NoError(t, err, name)
+			err := msg.ValidateBasic()
+			if !tc.valid {
+				require.Error(t, err)
+				return
+			}
+			require.NoError(t, err)
 
-		require.Equal(t, []sdk.AccAddress{tc.signer}, msg.GetSigners(), name)
+			require.Equal(t, []sdk.AccAddress{tc.signer}, msg.GetSigners())
+		})
 	}
 }
 
@@ -520,18 +538,20 @@ func TestMsgLeaveFoundation(t *testing.T) {
 	}
 
 	for name, tc := range testCases {
-		msg := foundation.MsgLeaveFoundation{
-			Address: tc.address.String(),
-		}
+		t.Run(name, func(t *testing.T) {
+			msg := foundation.MsgLeaveFoundation{
+				Address: tc.address.String(),
+			}
 
-		err := msg.ValidateBasic()
-		if !tc.valid {
-			require.Error(t, err, name)
-			continue
-		}
-		require.NoError(t, err, name)
+			err := msg.ValidateBasic()
+			if !tc.valid {
+				require.Error(t, err)
+				return
+			}
+			require.NoError(t, err)
 
-		require.Equal(t, []sdk.AccAddress{tc.address}, msg.GetSigners(), name)
+			require.Equal(t, []sdk.AccAddress{tc.address}, msg.GetSigners())
+		})
 	}
 }
 
@@ -568,22 +588,24 @@ func TestMsgGrant(t *testing.T) {
 	}
 
 	for name, tc := range testCases {
-		msg := foundation.MsgGrant{
-			Authority: tc.authority.String(),
-			Grantee:   tc.grantee.String(),
-		}
-		if tc.authorization != nil {
-			msg.SetAuthorization(tc.authorization)
-		}
-
-		err := msg.ValidateBasic()
-		if !tc.valid {
-			require.Error(t, err, name)
-			continue
-		}
-		require.NoError(t, err, name)
-
-		require.Equal(t, []sdk.AccAddress{tc.authority}, msg.GetSigners(), name)
+		t.Run(name, func(t *testing.T) {
+			msg := foundation.MsgGrant{
+				Authority: tc.authority.String(),
+				Grantee:   tc.grantee.String(),
+			}
+			if tc.authorization != nil {
+				msg.SetAuthorization(tc.authorization)
+			}
+
+			err := msg.ValidateBasic()
+			if !tc.valid {
+				require.Error(t, err)
+				return
+			}
+			require.NoError(t, err)
+
+			require.Equal(t, []sdk.AccAddress{tc.authority}, msg.GetSigners())
+		})
 	}
 }
 
@@ -620,20 +642,22 @@ func TestMsgRevoke(t *testing.T) {
 	}
 
 	for name, tc := range testCases {
-		msg := foundation.MsgRevoke{
-			Authority:  tc.authority.String(),
-			Grantee:    tc.grantee.String(),
-			MsgTypeUrl: tc.msgTypeURL,
-		}
+		t.Run(name, func(t *testing.T) {
+			msg := foundation.MsgRevoke{
+				Authority:  tc.authority.String(),
+				Grantee:    tc.grantee.String(),
+				MsgTypeUrl: tc.msgTypeURL,
+			}
 
-		err := msg.ValidateBasic()
-		if !tc.valid {
-			require.Error(t, err, name)
-			continue
-		}
-		require.NoError(t, err, name)
+			err := msg.ValidateBasic()
+			if !tc.valid {
+				require.Error(t, err)
+				return
+			}
+			require.NoError(t, err)
 
-		require.Equal(t, []sdk.AccAddress{tc.authority}, msg.GetSigners(), name)
+			require.Equal(t, []sdk.AccAddress{tc.authority}, msg.GetSigners())
+		})
 	}
 }
 
@@ -671,19 +695,21 @@ func TestMsgGovMint(t *testing.T) {
 	}
 
 	for name, tc := range testCases {
-		msg := foundation.MsgGovMint{
-			Authority: tc.authority.String(),
-			Amount:    tc.amount,
-		}
+		t.Run(name, func(t *testing.T) {
+			msg := foundation.MsgGovMint{
+				Authority: tc.authority.String(),
+				Amount:    tc.amount,
+			}
 
-		err := msg.ValidateBasic()
-		if !tc.valid {
-			require.Error(t, err, name)
-			continue
-		}
-		require.NoError(t, err, name)
+			err := msg.ValidateBasic()
+			if !tc.valid {
+				require.Error(t, err)
+				return
+			}
+			require.NoError(t, err)
 
-		require.Equal(t, []sdk.AccAddress{tc.authority}, msg.GetSigners(), name)
+			require.Equal(t, []sdk.AccAddress{tc.authority}, msg.GetSigners())
+		})
 	}
 }
 
@@ -870,9 +896,9 @@ func TestMsgUpdateDecisionPolicyAminoJson(t *testing.T) {
 
 func TestMsgGrantAminoJson(t *testing.T) {
 	var (
-		operator      = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address())
-		grantee       = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address())
-		proposer      = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address())
+		operator = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address())
+		grantee  = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address())
+		proposer = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address())
 	)
 
 	testCases := map[string]struct {