(t *testing.T)
| 428 | } |
| 429 | |
| 430 | func TestStartPrecommitVotePhase(t *testing.T) { |
| 431 | tests := []struct { |
| 432 | name string |
| 433 | detail string |
| 434 | proposalReceived bool |
| 435 | validProposal bool |
| 436 | isProposer bool |
| 437 | }{ |
| 438 | { |
| 439 | name: "no proposal received", |
| 440 | detail: `no proposal was received`, |
| 441 | }, |
| 442 | { |
| 443 | name: "sender not proposer", |
| 444 | detail: `sender is not the set proposer`, |
| 445 | proposalReceived: true, |
| 446 | }, |
| 447 | { |
| 448 | name: "proposer sent invalid proposal", |
| 449 | detail: `the proposer sent a proposal that did not correspond with the block set in the propose phase`, |
| 450 | proposalReceived: true, |
| 451 | isProposer: true, |
| 452 | }, |
| 453 | { |
| 454 | name: "received +2/3 prop vote", |
| 455 | detail: `received +2/3 quorum on the propose votes from replicas`, |
| 456 | proposalReceived: true, |
| 457 | isProposer: true, |
| 458 | validProposal: true, |
| 459 | }, |
| 460 | } |
| 461 | for _, test := range tests { |
| 462 | t.Run(test.name, func(t *testing.T) { |
| 463 | // setup |
| 464 | c := newTestConsensus(t, PrecommitVote, 3) |
| 465 | var ( |
| 466 | block []byte |
| 467 | results *lib.CertificateResult |
| 468 | ) |
| 469 | if test.proposalReceived { |
| 470 | block, results = c.simPrecommitPhase(t, 0) |
| 471 | } |
| 472 | if !test.validProposal { |
| 473 | c.bft.Block = c.cont.NewTestBlock2() // mismatched proposals |
| 474 | c.bft.BlockHash = c.cont.NewTestBlockHash2() |
| 475 | } |
| 476 | if !test.isProposer { |
| 477 | c.bft.ProposerKey = []byte("some other proposer") |
| 478 | } |
| 479 | expectedView := lib.View{ |
| 480 | NetworkId: lib.CanopyMainnetNetworkId, |
| 481 | ChainId: lib.CanopyChainId, |
| 482 | Height: 1, |
| 483 | Round: 0, |
| 484 | RootHeight: 1, |
| 485 | Phase: PrecommitVote, |
| 486 | } |
| 487 | go c.bft.StartPrecommitVotePhase() |
nothing calls this directly
no test coverage detected