Commit Graph

9 Commits

Author SHA1 Message Date
Eric 6523e70eaf
fix: `items(JsonNode)` symbol not found (#87)
* chore: export subscriptions

This has a knock-on effect of nim-serde not being imported into subscriptions when JsonRpcProvider.new is called from a consumer that does not export nim-serde.

* import/export serde

* Replace all instances of std/json with pkg/serde
2024-10-28 14:06:20 +11:00
Eric b68bea9909
fix: modify unsubscribe cleanup routine and tests (#84)
* fix: modify unsubscribe cleanup routine

Ignore exceptions (other than CancelledError) if uninstallation of the filter fails. If it's the last step in the subscription cleanup, then filter changes for this filter will no longer be polled so if the filter continues to live on in geth for whatever reason, then it doesn't matter.

This includes a number of fixes:
- `CancelledError` is now caught inside of `getChanges`. This was causing conditions during `subscriptions.close`, where the `CancelledError` would get consumed by the `except CatchableError`, if there was an ongoing `poll` happening at the time of close.
- After creating a new filter inside of `getChanges`, the new filter is polled for changes before returning.
- `getChanges` also does not swallow `CatchableError` by returning an empty array, and instead re-raises the error if it is not `filter not found`.
- The tests were simplified by accessing the private fields of `PollingSubscriptions`. That way, there wasn't a race condition for the `newFilterId` counter inside of the mock.
- The `MockRpcHttpServer` was simplified by keeping track of the active filters only, and invalidation simply removes the filter. The tests then only needed to rely on the fact that the filter id changed in the mapping.
- Because of the above changes, we no longer needed to sleep inside of the tests, so the sleeps were removed, and the polling interval could be changed to 1ms, which not only makes the tests faster, but would further highlight any race conditions if present.

* docs: rpc custom port documentation

---------

Co-authored-by: Adam Uhlíř <adam@uhlir.dev>
2024-10-25 14:58:45 +11:00
Mark Spanbroek 17c6e9a8c5 test for multiple error types on a function
Co-Authored-By: Eric Mastro <eric.mastro@gmail.com>
2024-05-21 13:19:24 +02:00
Mark Spanbroek ab10354910 wrap transaction response into Confirmable
This is a breaking change for the API of nim-ethers.
2024-05-21 13:19:24 +02:00
Mark Spanbroek cdb230d30f handle custom errors in confirm() calls 2024-05-21 13:19:24 +02:00
Mark Spanbroek a6f136afdd test custom arguments when sending transaction 2024-05-21 13:19:24 +02:00
Mark Spanbroek 6d6777e8c3 test custom errors with struct arguments 2024-05-21 13:19:24 +02:00
Mark Spanbroek 9c76803302 support custom errors with arguments 2024-05-21 13:19:24 +02:00
Mark Spanbroek 74f15fca9c support custom errors in contract calls
Currently only errors without arguments
2024-05-21 13:19:24 +02:00