mirror of
				https://github.com/0glabs/0g-chain.git
				synced 2025-11-04 06:48:03 +00:00 
			
		
		
		
	remove unecessary codec tests
This commit is contained in:
		
							parent
							
								
									447e7579a8
								
							
						
					
					
						commit
						307ecd54e2
					
				@ -1,57 +0,0 @@
 | 
				
			|||||||
package types
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import (
 | 
					 | 
				
			||||||
	"time"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	"github.com/cosmos/cosmos-sdk/codec"
 | 
					 | 
				
			||||||
	sdk "github.com/cosmos/cosmos-sdk/types"
 | 
					 | 
				
			||||||
	govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (suite *TypesTestSuite) TestCommitteeChangeProposalMarshals() {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	ccp := CommitteeChangeProposal{
 | 
					 | 
				
			||||||
		Title:       "A Title",
 | 
					 | 
				
			||||||
		Description: "A description for this committee.",
 | 
					 | 
				
			||||||
		NewCommittee: Committee{
 | 
					 | 
				
			||||||
			ID:               12,
 | 
					 | 
				
			||||||
			Description:      "This committee is for testing.",
 | 
					 | 
				
			||||||
			Members:          nil,
 | 
					 | 
				
			||||||
			Permissions:      []Permission{ParamChangePermission{}},
 | 
					 | 
				
			||||||
			VoteThreshold:    d("0.667"),
 | 
					 | 
				
			||||||
			ProposalDuration: time.Hour * 24 * 7,
 | 
					 | 
				
			||||||
		},
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	appCdc := codec.New()
 | 
					 | 
				
			||||||
	// register sdk types in case their needed
 | 
					 | 
				
			||||||
	sdk.RegisterCodec(appCdc)
 | 
					 | 
				
			||||||
	codec.RegisterCrypto(appCdc)
 | 
					 | 
				
			||||||
	codec.RegisterEvidences(appCdc)
 | 
					 | 
				
			||||||
	// register committee types
 | 
					 | 
				
			||||||
	RegisterCodec(appCdc)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	var ppModuleCdc PubProposal
 | 
					 | 
				
			||||||
	suite.NotPanics(func() {
 | 
					 | 
				
			||||||
		ModuleCdc.MustUnmarshalBinaryBare(
 | 
					 | 
				
			||||||
			ModuleCdc.MustMarshalBinaryBare(PubProposal(ccp)),
 | 
					 | 
				
			||||||
			&ppModuleCdc,
 | 
					 | 
				
			||||||
		)
 | 
					 | 
				
			||||||
	})
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	var ppAppCdc PubProposal
 | 
					 | 
				
			||||||
	suite.NotPanics(func() {
 | 
					 | 
				
			||||||
		appCdc.MustUnmarshalBinaryBare(
 | 
					 | 
				
			||||||
			appCdc.MustMarshalBinaryBare(PubProposal(ccp)),
 | 
					 | 
				
			||||||
			&ppAppCdc,
 | 
					 | 
				
			||||||
		)
 | 
					 | 
				
			||||||
	})
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	var ppGovCdc govtypes.Content
 | 
					 | 
				
			||||||
	suite.NotPanics(func() {
 | 
					 | 
				
			||||||
		govtypes.ModuleCdc.MustUnmarshalBinaryBare(
 | 
					 | 
				
			||||||
			govtypes.ModuleCdc.MustMarshalBinaryBare(govtypes.Content(ccp)),
 | 
					 | 
				
			||||||
			&ppGovCdc,
 | 
					 | 
				
			||||||
		)
 | 
					 | 
				
			||||||
	})
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,64 +0,0 @@
 | 
				
			|||||||
package types
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import (
 | 
					 | 
				
			||||||
	"fmt"
 | 
					 | 
				
			||||||
	"testing"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	"github.com/cosmos/cosmos-sdk/codec"
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
type InterA interface {
 | 
					 | 
				
			||||||
	GetTitle() string
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
type InterB InterA
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// interface {
 | 
					 | 
				
			||||||
// 	GetDescription() string
 | 
					 | 
				
			||||||
// }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
type Prop1 struct{}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (p Prop1) GetTitle() string       { return "prop1 title" }
 | 
					 | 
				
			||||||
func (p Prop1) GetDescription() string { return "prop1 description" }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
type Prop2 struct{}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (p Prop2) GetTitle() string       { return "prop2 title" }
 | 
					 | 
				
			||||||
func (p Prop2) GetDescription() string { return "prop2 description" }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func TestTest(t *testing.T) {
 | 
					 | 
				
			||||||
	/*
 | 
					 | 
				
			||||||
		register content, register new pubproposal
 | 
					 | 
				
			||||||
		register concrete types (should satisfy both of them)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		try marshalling and unmarshalling all 4 combinations
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
	cdc := codec.New()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cdc.RegisterInterface((*InterA)(nil), nil)
 | 
					 | 
				
			||||||
	cdc.RegisterConcrete(Prop1{}, "test/prop1", nil)
 | 
					 | 
				
			||||||
	cdc.RegisterInterface((*InterB)(nil), nil)
 | 
					 | 
				
			||||||
	cdc.RegisterConcrete(Prop2{}, "test/prop2", nil)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	p1ia := InterA(Prop1{})
 | 
					 | 
				
			||||||
	p2ia := InterA(Prop2{})
 | 
					 | 
				
			||||||
	p1ib := InterB(Prop1{})
 | 
					 | 
				
			||||||
	p2ib := InterB(Prop2{})
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	var iap1 InterA
 | 
					 | 
				
			||||||
	cdc.MustUnmarshalBinaryBare(cdc.MustMarshalBinaryBare(p1ia), &iap1)
 | 
					 | 
				
			||||||
	fmt.Printf("%T, %T\n", p1ia, iap1)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	var iap2 InterA
 | 
					 | 
				
			||||||
	cdc.MustUnmarshalBinaryBare(cdc.MustMarshalBinaryBare(p2ia), &iap2)
 | 
					 | 
				
			||||||
	fmt.Printf("%T, %T\n", p2ia, iap2)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	var ibp1 InterB
 | 
					 | 
				
			||||||
	cdc.MustUnmarshalBinaryBare(cdc.MustMarshalBinaryBare(p1ib), &ibp1)
 | 
					 | 
				
			||||||
	fmt.Printf("%T, %T\n", p1ib, ibp1)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	var ibp2 InterB
 | 
					 | 
				
			||||||
	cdc.MustUnmarshalBinaryBare(cdc.MustMarshalBinaryBare(p2ib), &ibp2)
 | 
					 | 
				
			||||||
	fmt.Printf("%T, %T\n", p2ib, ibp2)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user