You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the staking pool is created on an account with balance = 1_000_000_000_000, then total_stake_shares is 0, and several view functions start to panic
Note: I'm preparing a PR to handle this edge case
To reproduce, add this unit test: (the 4th parameter is the account initial balance)
#[test]
fn test_low_staked_balance() {
let mut emulator = Emulator::new(
owner(),
"KuTCtARNzxZQ3YvXDeLjx83FDqxv2SdQTSbiq876zR7".to_string(),
zero_fee(),
STAKE_SHARE_PRICE_GUARANTEE_FUND, //account initial balance, minimum, edge case
);
//bob deposits 1M
let deposit_amount = ntoy(1_000_000);
emulator.update_context(bob(), deposit_amount);
emulator.contract.deposit();
emulator.amount += deposit_amount;
//bob wants to know how much unstaked balance he has
emulator.update_context(bob(), 0);
assert_eq!(
emulator.contract.get_account_unstaked_balance(bob()).0,
deposit_amount
);
//panic!
//thread 'tests::test_low_staked_balance' panicked at 'The total number of stake shares can't be 0', src/internal.rs:297:9
}
The text was updated successfully, but these errors were encountered:
luciotato
changed the title
edge case bug - contract account with low balance
bug: (staking-pool) edge case bug - contract account with low balance
Sep 7, 2020
If the staking pool is created on an account with balance = 1_000_000_000_000, then total_stake_shares is 0, and several view functions start to panic
Note: I'm preparing a PR to handle this edge case
To reproduce, add this unit test: (the 4th parameter is the account initial balance)
The text was updated successfully, but these errors were encountered: