(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestCertificateCheckBasic(t *testing.T) { |
| 14 | block := &Block{BlockHeader: &BlockHeader{Height: 1}} |
| 15 | _, err := block.BlockHeader.SetHash() |
| 16 | require.NoError(t, err) |
| 17 | blkBytes, _ := Marshal(block) |
| 18 | // predefine qc results |
| 19 | results := &CertificateResult{ |
| 20 | RewardRecipients: &RewardRecipients{ |
| 21 | PaymentPercents: []*PaymentPercents{ |
| 22 | { |
| 23 | Address: newTestAddressBytes(t), |
| 24 | ChainId: CanopyChainId, |
| 25 | Percent: 100, |
| 26 | }, |
| 27 | }, |
| 28 | }, |
| 29 | } |
| 30 | // define test cases |
| 31 | tests := []struct { |
| 32 | name string |
| 33 | detail string |
| 34 | qc *QuorumCertificate |
| 35 | error string |
| 36 | }{ |
| 37 | { |
| 38 | name: "empty", |
| 39 | detail: "the qc is nil or empty", |
| 40 | qc: nil, |
| 41 | error: "empty quorum certificate", |
| 42 | }, |
| 43 | { |
| 44 | name: "view empty", |
| 45 | detail: "the qc view is nil or empty", |
| 46 | qc: &QuorumCertificate{ |
| 47 | ProposerKey: newTestPublicKeyBytes(t), |
| 48 | }, |
| 49 | error: "empty view", |
| 50 | }, |
| 51 | { |
| 52 | name: "invalid block hash", |
| 53 | detail: "the block hash is an invalid length", |
| 54 | qc: &QuorumCertificate{ |
| 55 | Header: &View{}, |
| 56 | ResultsHash: crypto.Hash([]byte("hash")), |
| 57 | ProposerKey: newTestPublicKeyBytes(t), |
| 58 | }, |
| 59 | error: "invalid block hash", |
| 60 | }, |
| 61 | { |
| 62 | name: "invalid results hash", |
| 63 | detail: "the results hash is an invalid length", |
| 64 | qc: &QuorumCertificate{ |
| 65 | Header: &View{}, |
| 66 | BlockHash: crypto.Hash([]byte("h")), |
| 67 | ResultsHash: []byte("wrong_length"), |
| 68 | ProposerKey: newTestPublicKeyBytes(t), |
| 69 | }, |
| 70 | error: "invalid results hash", |
nothing calls this directly
no test coverage detected