MCPcopy Create free account
hub / github.com/tendermint/tendermint / TestBlockIDValidateBasic

Function TestBlockIDValidateBasic

types/block_test.go:606–644  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

604}
605
606func TestBlockIDValidateBasic(t *testing.T) {
607 validBlockID := BlockID{
608 Hash: bytes.HexBytes{},
609 PartSetHeader: PartSetHeader{
610 Total: 1,
611 Hash: bytes.HexBytes{},
612 },
613 }
614
615 invalidBlockID := BlockID{
616 Hash: []byte{0},
617 PartSetHeader: PartSetHeader{
618 Total: 1,
619 Hash: []byte{0},
620 },
621 }
622
623 testCases := []struct {
624 testName string
625 blockIDHash bytes.HexBytes
626 blockIDPartSetHeader PartSetHeader
627 expectErr bool
628 }{
629 {"Valid BlockID", validBlockID.Hash, validBlockID.PartSetHeader, false},
630 {"Invalid BlockID", invalidBlockID.Hash, validBlockID.PartSetHeader, true},
631 {"Invalid BlockID", validBlockID.Hash, invalidBlockID.PartSetHeader, true},
632 }
633
634 for _, tc := range testCases {
635 tc := tc
636 t.Run(tc.testName, func(t *testing.T) {
637 blockID := BlockID{
638 Hash: tc.blockIDHash,
639 PartSetHeader: tc.blockIDPartSetHeader,
640 }
641 assert.Equal(t, tc.expectErr, blockID.ValidateBasic() != nil, "Validate Basic had an unexpected result")
642 })
643 }
644}
645
646func TestBlockProtoBuf(t *testing.T) {
647 h := mrand.Int63()

Callers

nothing calls this directly

Calls 3

ValidateBasicMethod · 0.95
RunMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…