Skip to content

Commit

Permalink
Updating solana web3py to get_transaction from get_confirmed_transact…
Browse files Browse the repository at this point in the history
…ion (#2843)

* Use updated RPC method as the currently consumed one is being deprecated https://docs.solana.com/developing/clients/jsonrpc-api#getconfirmedtransaction
  • Loading branch information
hareeshnagaraj committed Apr 5, 2022
1 parent ef4aeeb commit bdc5bea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion discovery-provider/src/solana/solana_client_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def handle_get_sol_tx_info(client, index):
logger.info(
f"solana_client_manager.py | get_sol_tx_info | Fetching tx {tx_sig} {endpoint}"
)
tx_info: ConfirmedTransaction = client.get_confirmed_transaction(
tx_info: ConfirmedTransaction = client.get_transaction(
tx_sig, encoding
)
logger.info(
Expand Down
14 changes: 7 additions & 7 deletions discovery-provider/src/solana/solana_client_manager_unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_get_sol_tx_info(_):
expected_response = {"result": "OK"}

# test that it returns the client call response
client_mocks[0].get_confirmed_transaction.return_value = expected_response
client_mocks[0].get_transaction.return_value = expected_response
assert (
solana_client_manager.get_sol_tx_info("transaction signature")
== expected_response
Expand All @@ -62,16 +62,16 @@ def test_get_sol_tx_info(_):
client_mocks[2].reset_mock()

num_retries = 2
client_mocks[0].get_confirmed_transaction.side_effect = Exception()
client_mocks[1].get_confirmed_transaction.side_effect = Exception()
client_mocks[2].get_confirmed_transaction.return_value = expected_response
client_mocks[0].get_transaction.side_effect = Exception()
client_mocks[1].get_transaction.side_effect = Exception()
client_mocks[2].get_transaction.return_value = expected_response
assert (
solana_client_manager.get_sol_tx_info("transaction signature", num_retries)
== expected_response
)
assert client_mocks[0].get_confirmed_transaction.call_count == 2
assert client_mocks[1].get_confirmed_transaction.call_count == 2
assert client_mocks[2].get_confirmed_transaction.call_count == 1
assert client_mocks[0].get_transaction.call_count == 2
assert client_mocks[1].get_transaction.call_count == 2
assert client_mocks[2].get_transaction.call_count == 1


@mock.patch("solana.rpc.api.Client")
Expand Down

0 comments on commit bdc5bea

Please sign in to comment.