BFT: Block deliverer integration test style
tock-ibm opened this issue · 1 comments
This style of controlling the mock will only cover one use case.
We want to achieve the same goal with a more flexible API on the mock, not by setting a single private field mo.censorDataMode
.
I am thinking about the following:
on every mock you can have the following functions:
// will deliver either data/headers until this point "n" and will then wait for further instructions but NOT break the delivery loop. If a subsequent call DeliverUntil(n2 uint64) (n2>n) the mock will continue to deliver until n2.
DeliverUntil(number uint64)
// answers true if the mock was last requested to deliver data
IsDataDeliverer() bool
// answers true if the mock was last requested to deliver headers
IsHeaderDeliverer() bool
// stops the delivery of blocks but does not stop the mock server.
// If the mock was instructed to deliver until n=5, it will wait there, and then only when instructed to stop, it will exit the loop
StopDelivery()
With this, the "block censorship" test case can then be implemented by:
- mark all mocks by DeliverUntil(5)
- discover who IsDataDeliverer and who are IsHeaderDeliverer (with eventually)
- let the header deliverers continue until the end by marking them DeliverUntil(11)
- etc...
I hope you see how this style will allow us to test many more test cases with ease.
The "normal" case is just
- mark all mocks by DeliverUntil(11)
- etc...
PS - this refactoring can be done in a separate PR. Let's finish the important stuff first (Block censorship detected, etc) and do this after this PR is merged.
Originally posted by @tock-ibm in #4673 (comment)
done