Skip to content

test: add unit tests for client/_utils.py (get_abi, get_bin, run_with_retry)#254

Open
crazywriter1 wants to merge 1 commit intoOpenGradient:mainfrom
crazywriter1:fix/add-utils-retry-tests
Open

test: add unit tests for client/_utils.py (get_abi, get_bin, run_with_retry)#254
crazywriter1 wants to merge 1 commit intoOpenGradient:mainfrom
crazywriter1:fix/add-utils-retry-tests

Conversation

@crazywriter1
Copy link
Copy Markdown

Summary

  • get_abi(), get_bin(), and run_with_retry() in src/opengradient/client/_utils.py had zero test coverage
  • run_with_retry() is critical infrastructure — it handles blockchain transaction retries on nonce conflicts, but its retry/abort logic was never tested
  • Added 17 unit tests across 3 test classes covering:
    • TestGetAbi (3 tests): valid JSON parsing, missing file, malformed JSON
    • TestGetBin (4 tests): with/without 0x prefix, whitespace stripping, missing file
    • TestRunWithRetry (10 tests): first-attempt success, invalid max_retries (0, negative), non-nonce errors raise immediately, retry on each nonce error type (nonce too low, nonce too high, invalid nonce), exhausted retries, max_retries=None default fallback, case-insensitive nonce matching

Test plan

  • All 17 new tests pass
  • All 138 existing tests still pass
  • No source code changes — test-only PR

@crazywriter1
Copy link
Copy Markdown
Author

@adambalogh

…_retry)

These three utility functions had zero test coverage. Added 17 tests
covering success paths, error handling, nonce retry logic, and edge cases.

Signed-off-by: crazywriter1 <crazywriter1@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant