Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test - Early Withdraw #18

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open

Conversation

gnumonik
Copy link

@gnumonik gnumonik commented Dec 13, 2022

Description

The tests generated in this PR modify the Happy path test generator such that a single randomly chosen withdrawal Tx in each generated Tx sequence attempts to withdraw vested funds from the contract before the deadline corresponding to the withdrawn amount.

The functions used to implement these tests are located in Generators.hs:

overRandomElem :: (a -> a) -> [a] -> Gen [a]
overRandomElem f as = do
  i <- chooseInt (0,length as - 1)
  let a  = as !! i
      a' = f a
  pure $ set (ix i) a' as

overRandomWithdrawConfig :: (WithdrawConfig -> WithdrawConfig) -> TestConfig -> Gen TestConfig
overRandomWithdrawConfig f (d,ws) = overRandomElem f ws >>= \ws' -> pure (d,ws')

withdrawTooEarly :: TestConfig -> Gen TestConfig
withdrawTooEarly = overRandomWithdrawConfig $ \w@WithdrawConfig{..} ->
  w {validStart = validStart - seconds 201}

As expected, each generated Tx sequence fails with a Not enough value remains locked to fulfill vesting schedule error.

These tests support our hypothesis that funds may only be unlocked after their vesting deadline has passed.

Conclusion

The above hypothesis holds, therefore no vulnerability was found.

@gnumonik gnumonik changed the title Random deadline too early Early Withdraw Dec 13, 2022
@cstml cstml mentioned this pull request Dec 13, 2022
6 tasks
@cstml cstml changed the title Early Withdraw Test - Early Withdraw Dec 14, 2022
@cstml cstml mentioned this pull request Dec 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants