michaelhly / solana-py

Solana Python SDK
https://michaelhly.github.io/solana-py
MIT License
1.04k stars 273 forks source link

FIX simulate_transaction add parameters from new RPC API #389

Closed pyz4 closed 6 months ago

pyz4 commented 9 months ago

Incorporate new parameters from RPC API (https://docs.solana.com/api/http#simulatetransaction): replace_recent_blockhash, min_context_slot, and accounts.

michaelhly commented 9 months ago

@pyz4 would you mind taking a look at the broken integration test?

Morgandri1 commented 8 months ago

The check issues are from a TypeError in test_send_transaction_and_get_balance:

# transfer_tx needs to be a VersionedTransaction. 
transfer_tx = Transaction().add(
     sp.transfer(sp.TransferParams(from_pubkey=stubbed_sender.pubkey(), to_pubkey=stubbed_receiver, lamports=1000))
)
sim_resp = test_http_client.simulate_transaction(transfer_tx)

the test_send_raw_transaction_and_get_balance test in integration/test_http_client.py. The returned balance is 9999994000, but the assertion is against 9999988000. May be that your change is using less gas?

Same thing in test_send_raw_transaction_and_get_balance_using_latest_blockheight. Balance is slightly higher than it should be. Would love to get @michaelhly 's opinion on if gas is likely the culprit.

michaelhly commented 8 months ago

The check issues are from a TypeError in test_send_transaction_and_get_balance:

# transfer_tx needs to be a VersionedTransaction. 
transfer_tx = Transaction().add(
     sp.transfer(sp.TransferParams(from_pubkey=stubbed_sender.pubkey(), to_pubkey=stubbed_receiver, lamports=1000))
)
sim_resp = test_http_client.simulate_transaction(transfer_tx)

the test_send_raw_transaction_and_get_balance test in integration/test_http_client.py. The returned balance is 9999994000, but the assertion is against 9999988000. May be that your change is using less gas?

Same thing in test_send_raw_transaction_and_get_balance_using_latest_blockheight. Balance is slightly higher than it should be. Would love to get @michaelhly 's opinion on if gas is likely the culprit.

Yeah. We can change the hard-coded balance amounts but I think we still need to fix the TypeError:

FAILED tests/integration/test_http_client.py::test_send_transaction_and_get_balance - TypeError: argument 'tx': 'Transaction' object cannot be converted to 'VersionedTransaction'