-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test main loop #6
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
ingester.Run(context.Background(), &wg) | ||
go func() { | ||
defer wg.Done() | ||
err := ingester.Run(context.Background(), cfg.BlockHeight, 0 /* maxCount */) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't realize /* */
was valid in Go!
@@ -12,7 +11,8 @@ import ( | |||
) | |||
|
|||
type Ingester interface { | |||
Run(ctx context.Context, wg *sync.WaitGroup) error | |||
// Run starts the ingester and blocks until the context is cancelled or maxCount blocks are ingested | |||
Run(ctx context.Context, startBlockNumber, maxCount int64) error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maxCount
🤔 EDIT: Nevermind, tests made it clear why we want this
inFlightChan := make(chan models.RPCBlock, i.cfg.MaxBatchSize) | ||
defer close(inFlightChan) | ||
|
||
var err error | ||
|
||
startBlockNumber := i.cfg.StartBlockHeight | ||
if startBlockNumber <= 0 { | ||
if startBlockNumber < 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good! We do indeed want block 0
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestBlockConsumptionLoopErrors(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not immediately clear to me what this test is testing. Is it testing that we exit the function cleanly under these scenarios + what blocks have been ingested? Or am I misunderstanding?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test is bogus right now, because I realized (while trying to get this test any decent) that the logic I created is just bad...
The problem is:
- we should be able to cancel execution (using the context) and have a good understanding if the execution was smooth, flaky, or we were under a busted scenario.
- for example, with everything broken, I think there should be an early return and just abort execution ? or should we just stay alive and keep trying?
- if execution is flaky, we should still consume blocks, but skip some, right ?
in short, this test just shows we're a bit confused on what to expect from the test.
} | ||
for _, testcase := range testcases { | ||
t.Run(testcase, func(t *testing.T) { | ||
t.Skip("not implemented") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a TODO?
} | ||
|
||
func TestRunLoop(t *testing.T) { | ||
t.Skip("not implemented") | ||
func TestRunLoopBaseCase(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
Obvious, creating tests found bugs and forced some changes :-)
but at least we validate some basic cases