github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/consensus/hotstuff/helper/quorum_certificate.go (about) 1 package helper 2 3 import ( 4 "math/rand" 5 6 "github.com/onflow/flow-go/consensus/hotstuff/model" 7 "github.com/onflow/flow-go/model/flow" 8 "github.com/onflow/flow-go/utils/unittest" 9 ) 10 11 func MakeQC(options ...func(*flow.QuorumCertificate)) *flow.QuorumCertificate { 12 qc := flow.QuorumCertificate{ 13 View: rand.Uint64(), 14 BlockID: unittest.IdentifierFixture(), 15 SignerIndices: unittest.SignerIndicesFixture(3), 16 SigData: unittest.SignatureFixture(), 17 } 18 for _, option := range options { 19 option(&qc) 20 } 21 return &qc 22 } 23 24 func WithQCBlock(block *model.Block) func(*flow.QuorumCertificate) { 25 return func(qc *flow.QuorumCertificate) { 26 qc.View = block.View 27 qc.BlockID = block.BlockID 28 } 29 } 30 31 func WithQCSigners(signerIndices []byte) func(*flow.QuorumCertificate) { 32 return func(qc *flow.QuorumCertificate) { 33 qc.SignerIndices = signerIndices 34 } 35 } 36 37 func WithQCView(view uint64) func(*flow.QuorumCertificate) { 38 return func(qc *flow.QuorumCertificate) { 39 qc.View = view 40 } 41 }