alpha-wallet-ios icon indicating copy to clipboard operation
alpha-wallet-ios copied to clipboard

Verify Combine + retry works as expected

Open hboon opened this issue 3 years ago • 6 comments

I've pushed a branch to https://github.com/AlphaWallet/alpha-wallet-ios/tree/try-retry which modifies RetryPublisherTests.testRetryWithRandomDelay. Try running just that test case:

2022-09-20 15:44:48.666034+0800 AlphaWallet[31013:44728174] xxx in deferred which will return the future from: testRetryWithRandomDelay()
2022-09-20 15:44:48.668375+0800 AlphaWallet[31013:44728175] xxx in future from: testRetryWithRandomDelay()
2022-09-20 15:44:48.980830+0800 AlphaWallet[31013:44728176] xxx sabotage from: instrumentedAsyncAPICall(sabotage:completion:)
2022-09-20 15:44:48.999677+0800 AlphaWallet[31013:44728176] xxx in deferred which will return the future from: testRetryWithRandomDelay()
2022-09-20 15:44:49.013350+0800 AlphaWallet[31013:44728176] xxx in future from: testRetryWithRandomDelay()
2022-09-20 15:44:49.030854+0800 AlphaWallet[31013:44728176] xxx sabotage from: instrumentedAsyncAPICall(sabotage:completion:)
2022-09-20 15:44:49.037519+0800 AlphaWallet[31013:44728176] xxx in deferred which will return the future from: testRetryWithRandomDelay()
2022-09-20 15:44:49.044559+0800 AlphaWallet[31013:44728176] xxx in future from: testRetryWithRandomDelay()
2022-09-20 15:44:49.048357+0800 AlphaWallet[31013:44728176] xxx sabotage from: instrumentedAsyncAPICall(sabotage:completion:)
2022-09-20 15:44:49.059946+0800 AlphaWallet[31013:44728176] xxx in deferred which will return the future from: testRetryWithRandomDelay()
2022-09-20 15:44:49.061613+0800 AlphaWallet[31013:44728176] xxx in future from: testRetryWithRandomDelay()
2022-09-20 15:44:49.064682+0800 AlphaWallet[31013:44728176] xxx sabotage from: instrumentedAsyncAPICall(sabotage:completion:)
2022-09-20 15:44:49.065389+0800 AlphaWallet[31013:44728176] xxx in deferred which will return the future from: testRetryWithRandomDelay()
2022-09-20 15:44:49.089505+0800 AlphaWallet[31013:44728175] xxx in future from: testRetryWithRandomDelay()
2022-09-20 15:44:49.191926+0800 AlphaWallet[31013:44728175] xxx sabotage from: instrumentedAsyncAPICall(sabotage:completion:)

Note that the lines with "xxx sabotage" is within 1 second but the test case has been modified to retry like this:

let resultPublisher = upstreamPublisher.retry(.randomDelayed(retries: 4, delayBeforeRetry: 10, delayUpperRangeValueFrom0To: 100), scheduler: DispatchQueue.global())

Did I misunderstand how it should work?

hboon avatar Sep 20 '22 07:09 hboon

checking

oa-s avatar Sep 20 '22 08:09 oa-s

pushed wip commit, now it looks ok, check on your side. and if its ok, i will make cleanup

oa-s avatar Sep 20 '22 11:09 oa-s

@oa-s yeah, looks right as it's delayed now. The test case sometimes (always?) fails for me, but maybe because I tweaked the parameters?

hboon avatar Sep 20 '22 13:09 hboon

can u show error message?

oa-s avatar Sep 20 '22 13:09 oa-s

if its about expectation timeout, you can it depends from retry range, u can play with it, if its about calls count or something else that is code error.

oa-s avatar Sep 20 '22 13:09 oa-s

@oa-s seems to work now, no idea why. But looks like the delay is working. Thanks!

hboon avatar Sep 21 '22 03:09 hboon

Closed via https://github.com/AlphaWallet/alpha-wallet-ios/pull/5431

oa-s avatar Sep 24 '22 08:09 oa-s