-
Notifications
You must be signed in to change notification settings - Fork 953
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
testing(state/core_accessor): add async submitPFB test case #3387
testing(state/core_accessor): add async submitPFB test case #3387
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.
Lets improve the test, so in case when it breaks it is easier to identify the root cause.
hashCh := make(chan string) | ||
for _, tc := range testcases { | ||
if tc.asyncSubmission { | ||
t.Run(tc.name, func(t *testing.T) { | ||
go func() { | ||
resp, err := ca.SubmitPayForBlob(ctx, tc.fee, tc.gasLim, tc.blobs) | ||
if err == nil { | ||
hashCh <- resp.TxHash | ||
} | ||
}() | ||
|
||
ctx, cancel := context.WithTimeout(ctx, time.Second*3) | ||
resp, err := ca.signer.ConfirmTx(ctx, <-hashCh) | ||
cancel() | ||
require.NoError(t, err) | ||
require.EqualValues(t, 0, resp.Code) | ||
}) | ||
} | ||
} |
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.
If ca.SubmitPayForBlob
returns non nill error, the test will hang forever because of deadlock on reading from <-hashCh
and also no meaningful error will be logged or returned. To fix this lets do:
- use select with
ctx.Done
for reading from<-hashCh
so test can fail fast - use
reqiure.NoError
for error produced byca.SubmitPayForBlob
to know what happen if it failed.
Moving to draft until the app provides an async version of SubmitPFB method. |
N/A |
Additional test case checks whether tx was included in the block after async submission