github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/engine/verification/test/happypath_test.go (about) 1 package test 2 3 import ( 4 "testing" 5 6 vertestutils "github.com/onflow/flow-go/engine/verification/utils/unittest" 7 "github.com/onflow/flow-go/module/metrics" 8 ) 9 10 // TestVerificationHappyPath evaluates behavior of the pipeline of verification node engines as: 11 // block reader -> block consumer -> assigner engine -> chunks queue -> chunks consumer -> fetcher engine -> verifier engine 12 // block reader receives (container) finalized blocks that contain execution receipts preceding (reference) blocks. 13 // some receipts have duplicate results. 14 // - in a authorized verification node: 15 // -- in assigner engine, for each distinct result it receives: 16 // --- it does the chunk assignment. 17 // --- it passes the chunk locators of assigned chunks to chunk queue. 18 // --- the chunk queue in turn delivers the assigned chunk to the fetcher engine. 19 // -- in fetcher engine, for each arriving chunk locator: 20 // --- it asks the chunk data pack from requester engine. 21 // --- requester engine asks and retrieves chunk data pack from (mocked) execution node. 22 // --- once chunk data pack arrives, forms a verifiable chunk and passes it to verifier node. 23 // -- in verifier engine, for each arriving verifiable chunk: 24 // --- it verifies the chunk, shapes a result approval, and emits it to (mock) consensus node. 25 // -- the test is passed if (mock) consensus node receives a single result approval per assigned chunk in a timely manner. 26 // - in an unauthorized verification node: 27 // -- execution results are discarded. 28 // -- the test is passed if no result approval is emitted for any of the chunks in a timely manner. 29 func TestVerificationHappyPath(t *testing.T) { 30 t.Parallel() 31 32 testcases := []struct { 33 blockCount int 34 opts []vertestutils.CompleteExecutionReceiptBuilderOpt 35 msg string 36 authorized bool 37 trials int 38 eventRepetition int // accounts for consumer being notified of a certain finalized block more than once. 39 }{ 40 { 41 /* 42 Read this test case in this way: 43 One block is passed to block reader. The block contains one 44 execution result that is not duplicate (single copy). 45 The result has only one chunk. 46 Each chunk data request is replied upon the first try. 47 The verification node is authorized. 48 */ 49 blockCount: 1, 50 opts: []vertestutils.CompleteExecutionReceiptBuilderOpt{ 51 vertestutils.WithResults(1), 52 vertestutils.WithChunksCount(1), 53 vertestutils.WithCopies(1), 54 }, 55 authorized: true, 56 eventRepetition: 1, 57 trials: 1, 58 msg: "1 block, 1 result, 1 chunk, no duplicate, authorized, no event repetition", 59 }, 60 { 61 blockCount: 1, 62 opts: []vertestutils.CompleteExecutionReceiptBuilderOpt{ 63 vertestutils.WithResults(1), 64 vertestutils.WithChunksCount(1), 65 vertestutils.WithCopies(1), 66 }, 67 authorized: false, // unauthorized 68 eventRepetition: 1, 69 trials: 1, 70 msg: "1 block, 1 result, 1 chunk, no duplicate, unauthorized, no event repetition", 71 }, 72 { 73 blockCount: 1, 74 opts: []vertestutils.CompleteExecutionReceiptBuilderOpt{ 75 vertestutils.WithResults(5), 76 vertestutils.WithChunksCount(5), 77 vertestutils.WithCopies(1), 78 }, 79 authorized: true, 80 eventRepetition: 1, 81 trials: 1, 82 msg: "1 block, 5 result, 5 chunks, no duplicate, authorized, no event repetition", 83 }, 84 { 85 blockCount: 10, 86 opts: []vertestutils.CompleteExecutionReceiptBuilderOpt{ 87 vertestutils.WithResults(2), 88 vertestutils.WithChunksCount(2), 89 vertestutils.WithCopies(2), 90 }, 91 authorized: true, 92 eventRepetition: 1, 93 trials: 1, 94 msg: "10 block, 5 result, 5 chunks, 1 duplicates, authorized, no event repetition", 95 }, 96 { 97 blockCount: 10, 98 opts: []vertestutils.CompleteExecutionReceiptBuilderOpt{ 99 vertestutils.WithResults(2), 100 vertestutils.WithChunksCount(2), 101 vertestutils.WithCopies(2), 102 }, 103 authorized: true, 104 eventRepetition: 3, // notifies consumer 3 times for each finalized block. 105 trials: 1, 106 msg: "10 block, 5 result, 5 chunks, 1 duplicates, authorized, with event repetition", 107 }, 108 { 109 blockCount: 1, 110 opts: []vertestutils.CompleteExecutionReceiptBuilderOpt{ 111 vertestutils.WithResults(1), 112 vertestutils.WithChunksCount(10), 113 vertestutils.WithCopies(1), 114 }, 115 authorized: true, 116 eventRepetition: 1, 117 trials: 3, 118 msg: "1 block, 1 result, 10 chunks, no duplicates, authorized, no event repetition, 3 retries", 119 }, 120 } 121 122 for _, tc := range testcases { 123 t.Run(tc.msg, func(t *testing.T) { 124 collector := &metrics.NoopCollector{} 125 126 vertestutils.NewVerificationHappyPathTest(t, 127 tc.authorized, 128 tc.blockCount, 129 tc.eventRepetition, 130 collector, 131 collector, 132 tc.trials, 133 tc.opts...) 134 }) 135 } 136 }