#import, file "../src/app/sync_retry.zi"; #program_export Answer :: () -> s32 { expected_attempts: [5]s32 = .[1, 2, 3, 4, 4] expected_delays: [5]s32 = .[5, 15, 30, 60, 60] attempt: s32 = 0 while attempt < 5 { challenge: RetryDecision = sync_retry_decision(4, attempt) request: RetryDecision = sync_retry_decision(6, attempt) if challenge.attempt != expected_attempts[attempt] || challenge.delay != expected_delays[attempt] || challenge.needs_action != 0 { return 0 } if request.attempt != challenge.attempt || request.delay != challenge.delay || request.needs_action != challenge.needs_action { return 0 } attempt += 1 } reset: RetryDecision = sync_retry_decision(0, 4) if reset.attempt != 0 || reset.delay != 0 || reset.needs_action != 0 { return 0 } signin: RetryDecision = sync_retry_decision(7, 2) if signin.attempt != 3 || signin.delay != 30 || signin.needs_action != 0 { return 0 } stop: RetryDecision = sync_retry_decision(5, 2) if stop.attempt != 2 || stop.delay != 0 || stop.needs_action != 1 { return 0 } unknown: RetryDecision = sync_retry_decision(2147483647, 2147483647) if unknown.attempt != 4 || unknown.delay != 0 || unknown.needs_action != 1 { return 0 } if app_sync_failure_needs_action(-1) != 1 || app_sync_failure_needs_action(0) != 0 || app_sync_failure_needs_action(4) != 0 { return 0 } if app_sync_retry_delay(-1) != 5.0 || app_sync_retry_delay(1) != 5.0 || app_sync_retry_delay(2) != 15.0 || app_sync_retry_delay(3) != 30.0 || app_sync_retry_delay(2147483647) != 60.0 { return 0 } return 42 }