Timeline for sending an http request in unit tests?
Current License: CC BY-SA 4.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 7, 2023 at 6:32 | history | edited | Arunjot Singh | CC BY-SA 4.0 |
added 2 characters in body
|
Jul 3, 2023 at 14:19 | comment | added | Yury Yukhananov |
@Alex Bean thank you for prompt reply. I adopted the suggested test for running under externalities, still it yields exactly the same result: the request is not sent and the /primitives/core/src/offchain/testing.rs/http_request_start calls for a panic!. Even if it would succeed, still my underlying problem is that my pallet uses offchain worker that implements a protocol based on http and, at this point, it looks like I would need to modify the working code in order to just adapt it for testing. I'm more inclined to try to modify relevant code in Substrate itself, could you give hints?
|
|
Jul 3, 2023 at 7:34 | comment | added | Alex Bean | This test might help you: github.com/paritytech/substrate/blob/master/client/executor/… | |
Jul 2, 2023 at 21:46 | comment | added | Yury Yukhananov |
I adopted should_send_a_basic_request_and_get_response test from /primitives/runtime/src/offchain/http.rs which manipulates the state and fullfills the request, unfortunately, it seems to pass always, no matter what the port number is and even if the local server is down.
|
|
Jul 1, 2023 at 18:45 | comment | added | Yury Yukhananov |
I looked at it a little bit more and it seems that the PendingRequest in /primitives/core/src/offchain/testing.rs is created and inserted into the offchain state directly without the Request being sent in the function fn http_request_start . At least I was unable to found a code equivalent to Request::sent(...) which normally creates a PendingRequest instance.
|
|
Jun 29, 2023 at 22:03 | history | asked | Yury Yukhananov | CC BY-SA 4.0 |