Skip to content

Commit

Permalink
test(rpc): cfx_getAdmin tests
Browse files Browse the repository at this point in the history
  • Loading branch information
darwintree committed Sep 18, 2023
1 parent 5cdb62f commit 49bc5a6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions conflux_web3/_utils/method_formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def from_hex_to_drip(val: Any):
RPC.cfx_getBalance: apply_formatter_at_index(to_hex_if_integer, 1),
RPC.cfx_getStakingBalance: apply_formatter_at_index(to_hex_if_integer, 1),
RPC.cfx_getNextNonce: apply_formatter_at_index(to_hex_if_integer, 1),
RPC.cfx_getAdmin: apply_formatter_at_index(to_hex_if_integer, 1),

RPC.cfx_getBlockByEpochNumber: apply_formatter_at_index(to_hex_if_integer, 0),
RPC.cfx_getBlockByBlockNumber: apply_formatter_at_index(to_hex_if_integer, 0),
Expand Down Expand Up @@ -467,6 +468,7 @@ def create_dict_result_formatter(typed_dict_class: Type[TypedDict]) -> Callable[
RPC.cfx_getFilterChanges: filter_result_formatter,

RPC.cfx_getCode: HexBytes,
RPC.cfx_getAdmin: apply_formatter_if(is_not_null, from_trust_to_base32),
RPC.cfx_getStorageAt: apply_formatter_if(is_not_null, to_hash32),
RPC.cfx_getStorageRoot: apply_formatter_if(is_not_null, storage_root_formatter),
RPC.cfx_getCollateralForStorage: to_integer_if_hex,
Expand Down
3 changes: 2 additions & 1 deletion tests/rpcs/test_cfx_rpcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ def test_get_admin(self, w3: Web3, contract_address: Base32Address):
contract_code = w3.cfx.get_admin(contract_address, w3.cfx.epoch_number_by_tag("latest_state"))
assert isinstance(contract_code, Base32Address) # reorg might happen, so we only assert the variable type

user_admin = w3.cfx.get_code(w3.cfx.account.create().address)
random_contract_address = w3.address(w3.cfx.account.create().address.replace("0x8", "0x1"))
user_admin = w3.cfx.get_admin(random_contract_address)
assert user_admin is None

def test_get_storage_at(self, w3: Web3, contract_address: Base32Address, use_testnet: bool):
Expand Down

0 comments on commit 49bc5a6

Please sign in to comment.