Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix review issues, add UTs
  • Loading branch information
ivanl committed Nov 17, 2021
commit 1051445fa51c390dbfc6a7f94034955aafdb561c
13 changes: 8 additions & 5 deletions proxy/plugin/solana_rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,14 @@ def eth_getStorageAt(self, account, position, block_identifier):
Currently supports only 'latest' block
'''
if block_identifier != "latest":
print(f"Block type '{block_identifier}' is not supported yet")
raise RuntimeError("Not supported block")
value = neon_cli().call('get-ether-storage-at', account, position)
print(f"eth_getStorageAt >> '{value}'")
return value
logger.debug(f"Block type '{block_identifier}' is not supported yet")
raise RuntimeError(f"Not supported block identifier: {block_identifier}")

try:
value = neon_cli().call('get-storage-at', account, position)
return value
except:
return '0x0'

def eth_getBlockByHash(self, trx_hash, full):
"""Returns information about a block by hash.
Expand Down
15 changes: 13 additions & 2 deletions proxy/test_eth_sendRawTransaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,10 +440,21 @@ def test_get_storage_at(self):
print('trx_store_hash:', trx_store_hash.hex())
trx_store_receipt = proxy.eth.wait_for_transaction_receipt(trx_store_hash)
print('trx_store_receipt:', trx_store_receipt)
value_received = proxy.eth.get_storage_at(self.storage_contract.address, 0, "latest")
print('eth_getStorageAt return:', value_received.hex())

number_pos = 0
value_received = proxy.eth.get_storage_at(self.storage_contract.address, number_pos, "latest")
print('eth_getStorageAt existing address and index => ', value_received.hex())
self.assertEqual(int.from_bytes(value_received, byteorder='big'), value_to_store)

non_existing_pos = 12
value_received = proxy.eth.get_storage_at(self.storage_contract.address, non_existing_pos, "latest")
print('eth_getStorageAt existing address and non-existing index => ', value_received.hex())
self.assertEqual(int.from_bytes(value_received, byteorder='big'), 0)

non_exising_address = b'\xe1\xda\xb7\xa6\x17\x6f\x87\x68\xF5\x3a\x42\x5f\x29\x61\x73\x60\x5e\xd5\x08\x32'
value_received = proxy.eth.get_storage_at(non_exising_address, non_existing_pos, "latest")
print('eth_getStorageAt non-existing address => ', value_received.hex())
self.assertEqual(int.from_bytes(value_received, byteorder='big'), 0)

if __name__ == '__main__':
unittest.main()