diff --git a/src/lib.rs b/src/lib.rs index 328944b..46a3560 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -214,6 +214,11 @@ pub trait LifeBondingContract: require!(bond_cache.address == caller, ERR_BOND_NOT_FOUND); + require!( + self.lock_periods().contains(&bond_cache.lock_period), + ERR_INVALID_LOCK_PERIOD + ); + let current_timestamp = self.blockchain().get_block_timestamp(); bond_cache.unbound_timestamp = current_timestamp + bond_cache.lock_period; diff --git a/tests/endpoints/renew.rs b/tests/endpoints/renew.rs index 4c98044..44feb20 100644 --- a/tests/endpoints/renew.rs +++ b/tests/endpoints/renew.rs @@ -88,4 +88,14 @@ fn renew() { remaining_amount: managed_biguint!(100u64), }), ); + + state.remove_lock_period_and_bond(OWNER_BONDING_CONTRACT_ADDRESS_EXPR, 10u64, None); + state.set_lock_period_and_bond(OWNER_BONDING_CONTRACT_ADDRESS_EXPR, 20u64, 200u64, None); + + state.renew( + FIRST_USER_ADDRESS_EXPR, + DATA_NFT_IDENTIFIER, + 1u64, + Some(TxExpect::user_error("str:Invalid lock period")), + ); }