Skip to content

Commit

Permalink
bugfix: CCIP-Read POST should send json data:
Browse files Browse the repository at this point in the history
- send ccip-read post request with json payload
- update _mock_specific_request util for ccip-read post requests
- lint, remove additional header since it's added when payload sent with json arg
  • Loading branch information
mdtanrikulu authored and fselmo committed Oct 15, 2024
1 parent 934a46b commit cce32db
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion web3/_utils/module_testing/module_testing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def _mock_specific_request(
if url_from_args == mocked_request_url:
assert kwargs["timeout"] == DEFAULT_HTTP_TIMEOUT
if http_method.upper() == "POST":
assert kwargs["data"] == {"data": calldata, "sender": sender}
assert kwargs["json"] == {"data": calldata, "sender": sender}
return MockedResponse()

# else, make a normal request (no mocking)
Expand Down
9 changes: 5 additions & 4 deletions web3/utils/exception_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,13 @@ def handle_offchain_lookup(
if "{data}" in url and "{sender}" in url:
response = session.get(formatted_url, timeout=DEFAULT_HTTP_TIMEOUT)
else:
payload = {
"data": formatted_data,
"sender": formatted_sender,
}
response = session.post(
formatted_url,
data={
"data": formatted_data,
"sender": formatted_sender,
},
json=payload,
timeout=DEFAULT_HTTP_TIMEOUT,
)
except Exception:
Expand Down

0 comments on commit cce32db

Please sign in to comment.