Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
5984c19
cherrypick part of changes
Dec 1, 2021
613a469
create indexer.py
Dec 1, 2021
c0d0e6c
remove solana_receipts_update.py
Dec 1, 2021
3f6b5c4
Cherry pick files from old branch
Dec 1, 2021
0790298
add requirement
Dec 1, 2021
340c854
fix refactoring issues
Dec 1, 2021
7449b38
Fix inspection issues
Dec 1, 2021
b3dacfa
fix last issue
Dec 1, 2021
a50cd47
Merge branch '336_indexer_refactoring' into 337_сreate_base_airdroppe…
Dec 1, 2021
2b8f879
Merge remote-tracking branch 'origin/develop' into 337_сreate_base_ai…
Dec 2, 2021
f51f2ed
simplify tests
Dec 2, 2021
6678924
add test
Dec 2, 2021
5d454b7
Merge remote-tracking branch 'origin/develop' into 337_сreate_base_ai…
Dec 3, 2021
add136a
add price provider
Dec 1, 2021
9a4be44
fix PriceProvider, add test
Dec 1, 2021
07aaca8
Add tests. Check worn on all nets
Dec 1, 2021
7a46c12
refactoring
Dec 1, 2021
2fc1424
integrate price_provider into airdropper
Dec 2, 2021
d157d67
integrate price provider
Dec 2, 2021
8a6abfd
use new faucet method
Dec 3, 2021
3d4dec9
add new parameter to airdropper main
Dec 3, 2021
5c29832
Test discriptions for airdropper
Dec 3, 2021
6a4efdc
Comments for price provider tests
Dec 3, 2021
14aeeed
remove unnecessary comment
Dec 3, 2021
bd35791
Merge remote-tracking branch 'origin/develop' into 338_create_sol_pri…
Dec 3, 2021
ff1f557
Merge remote-tracking branch 'origin/develop' into 338_create_sol_pri…
Dec 6, 2021
c28ca8e
fix error
Dec 6, 2021
07dd112
copy from erc20 contract test
Dec 5, 2021
023993d
Merge remote-tracking branch 'origin/develop' into 344_сreate_integra…
Dec 7, 2021
8c68755
Merge remote-tracking branch 'origin/develop' into 338_create_sol_pri…
Dec 7, 2021
f372b08
Merge branch '338_create_sol_price_provider' into 344_сreate_integrat…
Dec 7, 2021
ae5bddb
create integration tests
Dec 7, 2021
7f4c62c
fix oneline
Dec 7, 2021
b9cf0a6
revert changes on test_neon_faucet
Dec 7, 2021
1012a6b
fix some errors
Dec 7, 2021
dab9c2a
not working
Dec 7, 2021
0a4a2a0
add old variant
Dec 8, 2021
941f5ba
add helper functions
Dec 8, 2021
e223c46
transaction works!
Dec 8, 2021
24bc1f1
prepare refactoring
Dec 8, 2021
2401784
remove unnecessary code
Dec 8, 2021
5325895
Merge remote-tracking branch 'origin/develop' into 338_create_sol_pri…
Dec 8, 2021
9743411
Merge branch '338_create_sol_price_provider' into 344_сreate_integrat…
Dec 8, 2021
0f5c559
add account creation methods
Dec 9, 2021
b3cda28
first test almost ready
Dec 9, 2021
8e74e86
fix tests
Dec 9, 2021
18d88c7
fir airdropper startup
Dec 9, 2021
9ec00c9
One test is completely ready!
Dec 9, 2021
89714f6
add complex test case
Dec 9, 2021
48a96e7
add services to docker-compose file
Dec 9, 2021
89b951a
improve tests
Dec 10, 2021
9acbb38
add price update interval parameter
Dec 10, 2021
726cb1c
remove unnecessary imports
Dec 10, 2021
a1cbad2
fix airdropper run
Dec 10, 2021
5167613
Merge branch '338_create_sol_price_provider' into 344_сreate_integrat…
Dec 10, 2021
34dcedf
prepare for CI
Dec 10, 2021
4ec437f
remove commented
Dec 10, 2021
5a03842
fix compose-file
Dec 10, 2021
6119fe5
create wrapper class
Dec 13, 2021
1ac8877
make tests work!
Dec 13, 2021
0f3d41b
fix naming
Dec 13, 2021
50faa45
refactor test_erc20_wrapper_contract
Dec 13, 2021
4ed6d78
remove duplicated code
Dec 15, 2021
c3ce59b
Merge remote-tracking branch 'origin/develop' into 338_create_sol_pri…
Dec 15, 2021
e7d92fb
Merge branch '338_create_sol_price_provider' into 344_сreate_integrat…
Dec 15, 2021
090a7ec
Changes in base algorithm
Dec 16, 2021
ac839d6
simplify deployment
Dec 16, 2021
bbbf4d7
fix price estimation
Dec 16, 2021
36178d0
Merge remote-tracking branch 'origin/develop' into 344_сreate_integra…
Dec 16, 2021
768f33f
Merge branch '344_сreate_integration_tests_for_airdropper' into br_im…
Dec 16, 2021
ecad137
add test
Dec 17, 2021
c1b9ad9
edit assertions
Dec 17, 2021
d4b991d
fix tests
Dec 17, 2021
15e2505
comments
Dec 19, 2021
f57e474
Merge branch 'develop' into 390_improve_base_indexer_algorithm_perfor…
Dec 22, 2021
b06e55c
Merge branch 'develop' into 390_improve_base_indexer_algorithm_perfor…
Dec 23, 2021
6384d8d
Merge branch 'develop' into 390_improve_base_indexer_algorithm_perfor…
Jan 3, 2022
9b828cc
Fix after merge and rename methods
Jan 3, 2022
fc25fcb
remove unnecessary code
Jan 3, 2022
1d442d6
Fix tests
Jan 3, 2022
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 tests
  • Loading branch information
ivanl committed Dec 9, 2021
commit 8e74e8673d2d6d2d86c8ac7bf57c01edaa8d4caf
49 changes: 27 additions & 22 deletions proxy/testing/test_airdropper_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,33 @@
}
'''

# Helper function calculating solana address and nonce from given NEON(Ethereum) address
def get_evm_loader_account_address(eth_address: str):
eth_addressbytes = bytes.fromhex(eth_address[2:])
return PublicKey.find_program_address([b"\1", eth_addressbytes], EVM_LOADER_ID)

# Helper function calculating ERC20 wallet solana address
def get_erc20_token_wallet_address(eth_address: str,
eth_contract_address: str,
mint_pubkey: PublicKey):
eth_contract_address_bytes = bytes.fromhex(eth_contract_address[2:])
eth_address_bytes = bytes.fromhex(eth_address[2:])
seeds = [b"\1", b"ERC20Balance", bytes(mint_pubkey), eth_contract_address_bytes, eth_address_bytes]
return PublicKey.find_program_address(seeds, EVM_LOADER_ID)[0]

class TestAirdropperIntegration(TestCase):
@classmethod
def setUpClass(cls) -> None:
cls.create_token_mint(cls)
cls.deploy_erc20_wrapper_contract(cls)
cls.start_faucet(cls)
#cls.start_airdropper(cls)
cls.acc_num = 0


@classmethod
def tearDownClass(cls) -> None:
#cls.stop_airdropper(cls)
cls.stop_faucet(cls)


Expand Down Expand Up @@ -179,12 +195,13 @@ def deploy_erc20_wrapper_contract(self):


def start_airdropper(self):
contract_sol_address = self.get_evm_loader_account_address(self.contract_address)[0].to_base58()
contract_sol_address, nonce = get_evm_loader_account_address(self.contract_address)
self.airdropper = Process(target=run_airdropper,
args=(SOLANA_URL,
EVM_LOADER_ID,
f'http://localhost:{FAUCET_RPC_PORT}',
[contract_sol_address]))
[contract_sol_address.to_base58()],
'DEBUG'))
self.airdropper.start()


Expand Down Expand Up @@ -231,23 +248,8 @@ def get_token_balance(self, token_address, address):
return erc20.functions.balanceOf(address).call()



def get_evm_loader_account_address(self, eth_address: str):
eth_addressbytes = bytes.fromhex(eth_address[2:])
return PublicKey.find_program_address([b"\1", eth_addressbytes], EVM_LOADER_ID)


def get_erc20_token_wallet_address(self,
eth_address: str,
eth_contract_address: str,
mint_pubkey: PublicKey):
eth_contract_address_bytes = bytes.fromhex(eth_contract_address[2:])
eth_address_bytes = bytes.fromhex(eth_address[2:])
seeds = [b"\1", b"ERC20Balance", bytes(mint_pubkey), eth_contract_address_bytes, eth_address_bytes]
return PublicKey.find_program_address(seeds, EVM_LOADER_ID)[0]

def create_account_instruction(self, eth_address: str, payer: PublicKey):
dest_address_solana, nonce = self.get_evm_loader_account_address(eth_address)
dest_address_solana, nonce = get_evm_loader_account_address(eth_address)
neon_token_account = get_associated_token_address(dest_address_solana, ETH_TOKEN_MINT_ID)
return TransactionInstruction(
program_id=EVM_LOADER_ID,
Expand All @@ -268,9 +270,9 @@ def create_erc20_token_account_instruction(self,
eth_contract_address: str,
token_mint: PublicKey,
payer: PublicKey):
dest_address_solana, nonce = self.get_evm_loader_account_address(eth_address)
contract_address_solana = self.get_evm_loader_account_address(eth_contract_address)[0]
dest_token_wallet = self.get_erc20_token_wallet_address(eth_address, eth_contract_address, token_mint)
dest_address_solana, nonce = get_evm_loader_account_address(eth_address)
contract_address_solana = get_evm_loader_account_address(eth_contract_address)[0]
dest_token_wallet = get_erc20_token_wallet_address(eth_address, eth_contract_address, token_mint)
return TransactionInstruction(
program_id=EVM_LOADER_ID,
data=bytes.fromhex('0F'),
Expand All @@ -293,7 +295,7 @@ def create_input_liquidity_instruction(self,
eth_contract_address: str,
token_mint: PublicKey,
payer: PublicKey):
dest_token_wallet = self.get_erc20_token_wallet_address(eth_to_address, eth_contract_address, token_mint)
dest_token_wallet = get_erc20_token_wallet_address(eth_to_address, eth_contract_address, token_mint)
return TransactionInstruction(
program_id=TOKEN_PROGRAM_ID,
data=b'\3' + struct.pack('<Q', amount),
Expand Down Expand Up @@ -351,3 +353,6 @@ def test_success_airdrop_simple_case(self):
skip_confirmation=False))

self.assertEqual(self.get_token_balance(self.contract_address, to_eth_account.address), 123456)
sleep(10)
eth_balance = proxy.eth.get_balance(to_eth_account.address)
self.assertTrue(eth_balance > 0 and eth_balance < 10)