Skip to content

Commit

Permalink
add test for base64+zstd decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinheavey committed Jan 1, 2024
1 parent ecd2610 commit 74e8ca1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/test_rpc_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,16 @@ def test_get_account_info() -> None:
assert isinstance(parsed2, GetAccountInfoMaybeJsonParsedResp)
assert parsed.value == parsed2.value

def test_get_account_info_base64_zstd() -> None:
raw_base64 = '{"jsonrpc":"2.0","result":{"context":{"apiVersion":"1.16.21","slot":239322946},"value":{"data":["AQAAABzjWe1aAS4E+hQrnHUaHF6Hz9CgFhuchf/TG3jN/Nj2NjtW5UDjEQAGAQEAAAAqnl7btTwEZ5CY/3sSZRcUQ0/AjFYqmjuGEQXmctQicw==","base64"],"executable":false,"lamports":225456886647,"owner":"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA","rentEpoch":361,"space":82}},"id":0}'
raw_base64_zstd = '{"jsonrpc":"2.0","result":{"context":{"apiVersion":"1.16.21","slot":239322949},"value":{"data":["KLUv/QBYkQIAAQAAABzjWe1aAS4E+hQrnHUaHF6Hz9CgFhuchf/TG3jN/Nj2NjtW5UDjEQAGAQEAAAAqnl7btTwEZ5CY/3sSZRcUQ0/AjFYqmjuGEQXmctQicw==","base64+zstd"],"executable":false,"lamports":225456886647,"owner":"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA","rentEpoch":361,"space":82}},"id":0}'
parsed_base64 = GetAccountInfoResp.from_json(raw_base64)
parsed_base64_zstd = GetAccountInfoResp.from_json(raw_base64_zstd)
parsed_base64_value = parsed_base64.value
parsed_base64_zstd_value = parsed_base64_zstd.value
assert parsed_base64_value is not None
assert parsed_base64_zstd_value is not None
assert parsed_base64_value.data == parsed_base64_zstd_value.data

def test_get_account_info_null() -> None:
raw = '{"jsonrpc":"2.0","result":{"context":{"apiVersion":"1.10.26","slot":146423291},"value":null},"id":1}'
Expand Down

0 comments on commit 74e8ca1

Please sign in to comment.