market: Errorf->Fatalf, and eliminate not-a-race#427
Conversation
|
Can no longer trigger any timing related errors with |
| ctx, cancel := context.WithCancel(context.Background()) | ||
| startEpochIdx := 1 + encode.UnixMilli(time.Now())/epochDurationMSec | ||
| defer cancel() | ||
| startEpochIdx := 2 + encode.UnixMilli(time.Now())/epochDurationMSec |
There was a problem hiding this comment.
The first part of this test is submitting and order to a market that hasn't hit it's start epoch yet, and if the code between here and SubmitOrder here takes too long, the market will be running and the expected error won't be hit. So 1 -> 2 for some extra time.
| err = mkt.SubmitOrder(oRecord) | ||
| if err != nil { | ||
| t.Error(err) | ||
| t.Fatal(err) |
There was a problem hiding this comment.
All of these Errors needed to be Fatals because the rest of the test won't work (and the channel receives a couple lines down may hang).
| <-auth.handlePreimageDone | ||
| // and for matching to complete (in processReadyEpoch). | ||
| <-storage.epochInserted | ||
| storage.epochInserted = nil |
There was a problem hiding this comment.
That's the last epoch with this test market anyway, so there are no more sends from TArchivist on this channel anyway. Remove this since it was unguarded and technically a race.
This resolves a test timeout seen in https://github.com/decred/dcrdex/runs/715296974 for PR #372, although it's still unclear why the market wasn't running.
The unguarded set of a channel was also technically a race but it couldn't ever be hit. It wasn't necessary to nil it out, so don't.