Commit Graph

697 Commits

Author SHA1 Message Date
Eugene Kabanov b9fcf9962d
Refactor Future[T] test suite. (#359)
* Refactor testfut.nim.

* Fix location test lines.
2023-02-09 06:08:47 +02:00
Eugene Kabanov 8fcbe716b2
Add more verbose information about failure in basic auth test. (#351) 2023-01-24 01:48:31 +02:00
Tanguy 3d532b6d4a
Enable TCP client to enable TCP_NODELAY (#340)
* Enable TCP client to enable TCP_NODELAY

* add missing return

* fix
2023-01-23 11:18:12 +02:00
Jacek Sieka 40143f8798
remove lock file (#348)
The lock file breaks CI for nim devel - at minimum, there needs to be a
separate lock file for each nim version before lock files can be
introduced.
2023-01-19 17:20:26 +01:00
Tanguy f3b77d8661
Fix `async` `proc` types & small cleanups (#347)
* Fix `async` `proc` types & small cleanups

* review comments
2023-01-19 07:52:11 +01:00
Tanguy 4ada7fc0e1
Fix flaky token bucket CI (#338) 2023-01-18 16:02:00 +01:00
Jacek Sieka c65cc4c136
`async` `proc` types (#346)
Allow `type = proc(...) {.async.}` for pre-declaring async callback
types - in this case, the macro applies the correct transformation to
the return type and adds the appropriate exception / gcsafe annotations
2023-01-18 15:54:39 +01:00
Eugene Kabanov 945c304197
Address #329. (#330)
* Address #329.

* Refactor AsyncStreamReader/Writer `state` helper functions.
Fix some compilation warnings in `debugutils`.
Add multiple writes into test to check consistency.

* Fix Linux issue.
Fix warnings.
2023-01-10 18:08:54 +02:00
Bung e9f8baa6ee
fix int set (#341) 2022-12-29 12:12:12 +01:00
Bung 5d0c725463
fix int set construction (#335) 2022-12-16 10:40:33 +01:00
Tanguy 75d030ff71
Fix async macro "CannotRaise" warnings in nim >1.2 (#332) 2022-12-01 11:36:14 +01:00
Jacek Sieka 189f6e390c
normalise nimble file (#331)
* normalise nimble file

* abort redundant builds

* bump checkout
2022-11-23 06:54:10 +01:00
Eugene Kabanov 6525f4ce1d
Fix some warnings. (#310)
* Fix some warnings messages.

* More warning fixes.

* Address review comments.
Fix MacOS issues.

* More warning fixes.

* More Windows specific fixes.

* Fix macos and windows warnings.

* Fix warnings in timer.nim
Refactor to remove `result`.
Improve performance and behavior of timer to string procedure.
Add tests.
2022-11-02 08:09:15 +01:00
Tanguy 24146463a3
Token bucket (#279)
- A single sleepAsync per bucket
- Manual replenish with async
- Cancellation of consume

Co-authored-by: Jacek Sieka <jacek@status.im>
2022-11-02 08:03:19 +01:00
Eugene Kabanov 266e2c0ed2
HTTP client: Allow request connection management. (#323)
* Allow per-request connection management.
Fix NewConnectionAlways leak issue.

* Address review comment.
2022-10-13 10:18:13 +00:00
Eugene Kabanov 9df76c39df
Fix default content-type should not be sent if there is no body. (#315)
Make contentLength field publicly available.
2022-09-20 12:59:34 +00:00
Eugene Kabanov be2352027e
Fix nested waitFor (IndexError defect crash) bug. (#309)
Add IndexError crash test for Linux/MacOS.
Add Sentinel version of fix.
Add GetQueuedCompletionStatusEx() support for Windows, which allows to capture more then one event in single `poll()` call.
2022-09-16 22:34:18 +02:00
Eugene Kabanov 8e8263370b
Add more FutureBase helpers. (#304) 2022-09-12 12:11:13 +00:00
Jacek Sieka 396ed554f6
Update README.md 2022-09-06 18:50:12 +02:00
Jacek Sieka 746832384a
`Option` -> `Opt` (#307) 2022-09-05 11:08:52 +00:00
Miran 3e4b47e60a
switch CI to the supported versions of ubuntu and macos (#306)
* switch CI to the supported versions of ubuntu and macos

See:
- https://github.com/actions/runner-images/issues/6002
- https://github.com/actions/runner-images/issues/5583

* don't continue on error for Nim 1.6

* install openssl on macos for Nim devel

due to changes in https://github.com/nim-lang/Nim/pull/19814
2022-09-02 17:27:24 +02:00
Eugene Kabanov 1334cdfebd
getPreferredContentType() deprecate float math (#303)
* Deprecate float math.

* Remove unneeded helper procedures.

* Remove limitation of 99 types and comments.
2022-08-10 14:07:51 +03:00
Miran 93800879fd
make it more Nim 1.4+ compatible (#296) 2022-08-06 13:56:06 +03:00
Eugene Kabanov 15d7e0ebb7
Add optimized implementation for preferredContentType() which avoid sorting and double iteration. (#299)
Fix tests to use 80cpl.
2022-08-06 13:53:40 +03:00
Eugene Kabanov 939195626f
Use new Content-Type header value parser. (#302) 2022-08-05 19:59:26 +03:00
Eugene Kabanov 79c51914ae
Fix jigsaw test. (#301) 2022-07-30 23:16:30 +03:00
Eugene Kabanov e9d0e2d208
Apply fix for recent Nim devel changes. (#300) 2022-07-30 12:48:58 +03:00
Tanguy 41b82cdea3
Add test for nested finally transform issue (#295) 2022-07-18 23:30:27 +02:00
Jacek Sieka 2a19e4ca4c
bearssl: spelling (#294) 2022-07-16 20:46:19 +02:00
Eugene Kabanov f2e4d447d6
Workaround exception tracking issue. (#293)
* Workaround exception tracking issue.

* Fix SecureHttpServerRef too.
2022-07-04 12:31:18 +03:00
Ivan Yonchovski 59f611f0fc
Use unittest2 directly (#291) 2022-06-29 17:22:57 +03:00
Eugene Kabanov 377e197417
waitSignal() helper and tests for it. (#289)
* Add waitForSignal() implementation and tests.

* Fix compilation issues.

* Fix mistype.

* Rename to waitSignal().

* Fix Windows compilation issue.

* Re-export posix signals.

* Remove signal handler on continuation too.
2022-06-29 00:53:09 +03:00
Zahary Karadjov 84e32a3b69
Add high and low operators for Duration and Moment; Add Moment.epochSeconds and Moment.epochNanoSeconds 2022-06-28 16:47:59 +03:00
Jacek Sieka c6ce4d4fb2
bearssl: use split ABI (#282) 2022-06-17 12:39:14 +02:00
Eugene Kabanov 2a5095505f
Add headers argument to redirect() calls. (#287)
* Add headers argument to redirect() calls.

* Fix mistype.
2022-06-17 12:17:49 +03:00
Eugene Kabanov 61fbbc5512
asyncTest (#286)
* Initial commit.

* Change name to asynctests.
2022-06-16 14:35:24 +03:00
Eugene Kabanov f403b06de6
AsyncEventQueue (AsyncEventBus replacement). (#275)
* AsyncEventQueue (AsyncEventBus replacement) initial commit.

* Add closeWait() and remove assertion test.

* Fix "possible" memory leak.

* Add limits to AsyncEventQueue[T].
Add tests for AsyncEventQueue[T] limits.
Rebase AsyncSync errors to be children of AsyncError.

* Adopt AsyncEventQueue to garbage collect events on emit() too.
Add test from review comment.

* Remove AsyncEventBus test suite.

* Remove unneeded [T] usage.

* Optimize memory usage in 1m test.

* Lower number of events in test from 1m to 100k.

* Deprecate AsyncEventBus.
Add some GC debugging for tests.

* Fix mistype.

* One more attempt to fix crash.

* Add some echo debugging.

* More echo debugging.

* More closer debug echoes.

* Attempt to workaround crash place.

* More debugging echoes in exception handlers.

* Convert suspected test into async procedure.

* Make multiple consumers test async.

* Remove GC debugging.

* Disable added tests.

* Disable AsyncEventQueue tests to confirm that this is an issue.

* Enable all the tests.
2022-06-16 00:51:21 +03:00
Eugene Kabanov 623681e212
Add nimRawSetjmp define to config.nims (#285)
* Add nimRawSetjmp define to config.nims

* Add config to tests too.
2022-06-14 01:02:33 +03:00
Eugene Kabanov b3548583fc
Fix last connection state check. (#278) 2022-05-27 23:03:32 +03:00
Eugene Kabanov 728ab7faa7
Fix one more place of assertion for high concurrency requests. (#277) 2022-05-27 20:28:39 +03:00
Tanguy c5894bae1b
AsyncEventBus: fix multiple listeners (#271)
Co-authored-by: dbrignoli <dbrignoli@audioscience.com>
2022-05-20 11:57:37 +02:00
Derek 呆 1233f8fb4b
fix tiny typo in comment (#274) 2022-05-19 17:37:51 +02:00
zah 875d7d8e6e
Tentative fix for the HTTP client connection state assertion failures (#272)
* Tentative fix for the HTTP client connection state assertion failures

I've traced the problem to a HTTP connection being closed while there
are outstanding requests that still go through the motions (the crash
occurs when a requests reaches its `finish` processing step, but it
was already put in a Closed state by the connection that owns it).

* Use distinct error exception instead of cancellation error.

Co-authored-by: cheatfate <eugene.kabanov@status.im>
2022-05-14 11:08:13 +03:00
Etan Kissling dedd7cb1d0
Guarantee exclusive use of `HttpClientConnection`. (#273)
When calling the HTTP `send` / `open` functions, `acquireConnection` is
called to obtain a connection in state `Ready`. In the next code block,
the connection state is advanced to `RequestHeadersSending`. However,
returning from chronos `async` procs yields control, similar to `await`.
This means that a connection may be added to the pool in `Ready` state,
and then a different `acquireConnection` call may obtain a second ref.
Introducing a new `Acquired` state ensures consistency in this case.

No tests added due to this being scheduler dependent; ran manual tests
by adding a `doAssert item.state != HttpClientConnectionState.Acquired`
between `if not(isNil(conn)):` and `return conn`. Eventually, the assert
got hit after several hours of repeated tests, confirming the edge case
to be solved by applying this fix.

Not sure if it is by design that returning from an `async` proc yields.
Even if it's not, this should solve current HTTP issues in nimbus-eth2.
2022-05-13 02:54:34 +03:00
Tanguy ae19d5b6f0
Handle multiple childs for opensymchoice (#266)
And more tests. Follow up of #261
2022-05-05 11:05:04 +02:00
zah 5a906ad56c
nimble setup (#269) 2022-04-17 11:41:14 +02:00
Jacek Sieka bb4c3298f5
fix crash after reading from fd > 1024 (#267)
The socket selector holds a `seq` of per-descriptor data. When a reader
is registered, a pointer to a seq item is stored - when the `seq` grows,
this pointer becomes dangling and causes crashes like
https://github.com/status-im/nimbus-eth2/issues/3521.

It turns out that there already exist two mechanisms for passing user
data around - this PR simply removes one of them, saving on memory usage
and removing the need to store pointers to the `seq` data that become
dangling on resize.
2022-04-11 11:56:30 +02:00
cheatfate ae2a87778f
Fix missing connection flag. 2022-04-10 19:35:04 +03:00
Tanguy 64386b3112
Fix nimdoc for async procs (#260) 2022-04-05 12:16:00 +02:00
Tanguy 3621143c89
reenable auth test with other server 2022-03-30 17:09:43 +02:00