github.com/project-88388/tendermint-v0.34.14-terra.2@v1.0.0/types/canonical_test.go (about) 1 package types 2 3 import ( 4 "reflect" 5 "testing" 6 7 "github.com/tendermint/tendermint/crypto/tmhash" 8 tmrand "github.com/tendermint/tendermint/libs/rand" 9 tmproto "github.com/tendermint/tendermint/proto/tendermint/types" 10 ) 11 12 func TestCanonicalizeBlockID(t *testing.T) { 13 randhash := tmrand.Bytes(tmhash.Size) 14 block1 := tmproto.BlockID{Hash: randhash, 15 PartSetHeader: tmproto.PartSetHeader{Total: 5, Hash: randhash}} 16 block2 := tmproto.BlockID{Hash: randhash, 17 PartSetHeader: tmproto.PartSetHeader{Total: 10, Hash: randhash}} 18 cblock1 := tmproto.CanonicalBlockID{Hash: randhash, 19 PartSetHeader: tmproto.CanonicalPartSetHeader{Total: 5, Hash: randhash}} 20 cblock2 := tmproto.CanonicalBlockID{Hash: randhash, 21 PartSetHeader: tmproto.CanonicalPartSetHeader{Total: 10, Hash: randhash}} 22 23 tests := []struct { 24 name string 25 args tmproto.BlockID 26 want *tmproto.CanonicalBlockID 27 }{ 28 {"first", block1, &cblock1}, 29 {"second", block2, &cblock2}, 30 } 31 for _, tt := range tests { 32 tt := tt 33 t.Run(tt.name, func(t *testing.T) { 34 if got := CanonicalizeBlockID(tt.args); !reflect.DeepEqual(got, tt.want) { 35 t.Errorf("CanonicalizeBlockID() = %v, want %v", got, tt.want) 36 } 37 }) 38 } 39 }