1111from solana .rpc .api import Client as SolanaClient
1212
1313from ..plugin .solana_rest_api import EthereumModel
14- from ..plugin .solana_rest_api_tools import get_token_balance_gwei , EthereumAddress , ether2program
14+ from ..plugin .solana_rest_api_tools import get_token_balance_gwei , ether2program
1515
1616
1717class TestAirdroppingEthAccounts (unittest .TestCase ):
@@ -50,9 +50,15 @@ def test_airdrop_onto_wrapped_new_address(self):
5050 self .assertEqual (self ._EXPECTED_BALANCE_WEI , wrapper_actual_balance )
5151 self .assertEqual (self ._EXPECTED_BALANCE_WEI , nested_actual_balance )
5252
53- def test_raise_on_constructing (self ):
54- contract_owner : LocalAccount = self ._web3 .eth .account .create ()
55- contract = self ._compile_and_deploy_contract (contract_owner , self ._WRAPPER_CONTRACT_STORAGE_SOURCE )
53+ def test_airdrop_on_deploy_estimation (self ):
54+ owner_eth_account : LocalAccount = self ._web3 .eth .account .create ()
55+ compile_result = solcx .compile_source (self ._CONTRACT_STORAGE_SOURCE )
56+ _ , contract_interface = compile_result .popitem ()
57+ contract_data = contract_interface .get ("bin" )
58+ self .assertIsNotNone (contract_data )
59+ self ._web3 .eth .estimate_gas ({"from" : owner_eth_account .address , "data" : contract_data })
60+ owner_balance = self ._get_balance_wei (owner_eth_account .address )
61+ self .assertEqual (self ._EXPECTED_BALANCE_WEI , owner_balance )
5662
5763 def test_eth_call_array_constructable_contract (self ):
5864 compile_result = solcx .compile_source (self ._CONTRACT_LIST_CONSTRUCTABLE )
@@ -65,8 +71,8 @@ def test_eth_call_array_constructable_contract(self):
6571 self .assertEqual ("ListConstructable: empty list" , str (cm .exception ))
6672
6773 def _compile_and_deploy_contract (self , contract_owner : LocalAccount , source : str ) -> web3_eth .Contract :
68- compiled_sol = solcx .compile_source (source )
69- contract_id , contract_interface = compiled_sol .popitem ()
74+ compile_result = solcx .compile_source (source )
75+ contract_id , contract_interface = compile_result .popitem ()
7076 contract = self ._web3 .eth .contract (abi = contract_interface ['abi' ], bytecode = contract_interface ['bin' ])
7177 nonce = self ._web3 .eth .get_transaction_count (contract_owner .address )
7278 chain_id = self ._web3 .eth .chain_id
@@ -78,8 +84,8 @@ def _compile_and_deploy_contract(self, contract_owner: LocalAccount, source: str
7884 contract = self ._web3 .eth .contract (address = trx_receipt .contractAddress , abi = contract .abi )
7985 return contract
8086
81- def _get_balance_wei (self , eth_acc : str ) -> int :
82- token_owner_account , nonce = ether2program (eth_acc )
87+ def _get_balance_wei (self , eth_account : str ) -> int :
88+ token_owner_account , nonce = ether2program (eth_account )
8389 balance = get_token_balance_gwei (self ._solana_client , token_owner_account )
8490 self .assertIsNotNone (balance )
8591 self .assertIsInstance (balance , int )
0 commit comments