-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Context
Follow-up from PR #315 and this comment.
Description
Add comprehensive automated tests for the new claim_token
endpoint and its dependent logic in src/faucet/server_api.rs
.
Test Coverage Needed
Unit Tests
parse_and_validate_address
: Test valid and invalid address parsing- Invalid address format → assert
BAD_REQUEST (400)
- Valid addresses for different networks
- Invalid address format → assert
Integration/Endpoint Tests
- Mainnet branch: Request with
FaucetInfo::MainnetFIL
→ assertIM_A_TEAPOT (418)
response - Rate limiting: Trigger rate limit → assert
TOO_MANY_REQUESTS (429)
response with proper retry-after message - CalibnetFIL success path: Mock
Provider
and test native token claim → assert success and valid transaction ID returned - CalibnetUSDFC success path: Mock
Provider
and test ERC-20 token claim → assert success and valid transaction ID returned
Implementation Notes
- Mock or stub
Provider::from_network
andfaucet_address
for deterministic test execution - Consider using mockall or test-only implementations for RPC/provider behavior
- Ensure tests assert both HTTP status codes and
ServerFnError
variants appropriately - Add focused unit tests for
handle_native_claim
andhandle_erc20_claim
Related
- PR: Calibnet token claim api #315
- Requested by: @sudo-shashank
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
In review