3
3
from solana .rpc .commitment import Confirmed
4
4
from spl .token .instructions import get_associated_token_address
5
5
6
- from stake .constants import STAKE_LEN
7
- from stake_pool .state import StakePool , ValidatorList
6
+ from stake .constants import STAKE_LEN , LAMPORTS_PER_SOL
8
7
from stake_pool .actions import deposit_sol
8
+ from stake_pool .constants import MINIMUM_ACTIVE_STAKE , MINIMUM_RESERVE_LAMPORTS
9
+ from stake_pool .state import StakePool , ValidatorList
9
10
10
11
from bot .rebalance import rebalance
11
12
@@ -18,7 +19,7 @@ async def test_rebalance_this_is_very_slow(async_client, validators, payer, stak
18
19
(stake_pool_address , validator_list_address ) = stake_pool_addresses
19
20
resp = await async_client .get_minimum_balance_for_rent_exemption (STAKE_LEN )
20
21
stake_rent_exemption = resp ['result' ]
21
- increase_amount = 100_000_000
22
+ increase_amount = MINIMUM_ACTIVE_STAKE
22
23
deposit_amount = (increase_amount + stake_rent_exemption ) * len (validators )
23
24
24
25
resp = await async_client .get_account_info (stake_pool_address , commitment = Confirmed )
@@ -32,7 +33,7 @@ async def test_rebalance_this_is_very_slow(async_client, validators, payer, stak
32
33
33
34
# should only have minimum left
34
35
resp = await async_client .get_account_info (stake_pool .reserve_stake , commitment = Confirmed )
35
- assert resp ['result' ]['value' ]['lamports' ] == stake_rent_exemption + 1
36
+ assert resp ['result' ]['value' ]['lamports' ] == stake_rent_exemption + MINIMUM_RESERVE_LAMPORTS
36
37
37
38
# should all be the same
38
39
resp = await async_client .get_account_info (validator_list_address , commitment = Confirmed )
@@ -45,12 +46,12 @@ async def test_rebalance_this_is_very_slow(async_client, validators, payer, stak
45
46
# Test case 2: Decrease
46
47
print ('Waiting for next epoch' )
47
48
await waiter .wait_for_next_epoch (async_client )
48
- await rebalance (ENDPOINT , stake_pool_address , payer , deposit_amount / 1_000_000_000 )
49
+ await rebalance (ENDPOINT , stake_pool_address , payer , deposit_amount / LAMPORTS_PER_SOL )
49
50
50
51
# should still only have minimum left + rent exemptions from increase
51
52
resp = await async_client .get_account_info (stake_pool .reserve_stake , commitment = Confirmed )
52
53
reserve_lamports = resp ['result' ]['value' ]['lamports' ]
53
- assert reserve_lamports == stake_rent_exemption * (1 + len (validator_list .validators )) + 1
54
+ assert reserve_lamports == stake_rent_exemption * (1 + len (validator_list .validators )) + MINIMUM_RESERVE_LAMPORTS
54
55
55
56
# should all be decreasing now
56
57
resp = await async_client .get_account_info (validator_list_address , commitment = Confirmed )
@@ -63,12 +64,12 @@ async def test_rebalance_this_is_very_slow(async_client, validators, payer, stak
63
64
# Test case 3: Do nothing
64
65
print ('Waiting for next epoch' )
65
66
await waiter .wait_for_next_epoch (async_client )
66
- await rebalance (ENDPOINT , stake_pool_address , payer , deposit_amount / 1_000_000_000 )
67
+ await rebalance (ENDPOINT , stake_pool_address , payer , deposit_amount / LAMPORTS_PER_SOL )
67
68
68
69
# should still only have minimum left + rent exemptions from increase
69
70
resp = await async_client .get_account_info (stake_pool .reserve_stake , commitment = Confirmed )
70
71
reserve_lamports = resp ['result' ]['value' ]['lamports' ]
71
- assert reserve_lamports == stake_rent_exemption + deposit_amount + 1
72
+ assert reserve_lamports == stake_rent_exemption + deposit_amount + MINIMUM_RESERVE_LAMPORTS
72
73
73
74
# should all be decreasing now
74
75
resp = await async_client .get_account_info (validator_list_address , commitment = Confirmed )
0 commit comments