add some tests for Stake validator
This commit is contained in:
parent
4acc857bbd
commit
78d104c213
5 changed files with 194 additions and 17 deletions
|
|
@ -14,12 +14,13 @@ import Plutarch.Builtin (pforgetData)
|
|||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
import Agora.Stake (stakePolicy)
|
||||
import Agora.Stake (StakeDatum (StakeDatum), StakeRedeemer (DepositWithdraw), stakePolicy, stakeValidator)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
import Spec.Sample.Stake (DepositWithdrawExample (DepositWithdrawExample, delta, startAmount), signer)
|
||||
import Spec.Sample.Stake qualified as Stake
|
||||
import Spec.Util (policyFailsWith, policySucceedsWith)
|
||||
import Spec.Util (policyFailsWith, policySucceedsWith, toDatum, validatorFailsWith, validatorSucceedsWith)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -42,5 +43,23 @@ tests =
|
|||
(stakePolicy Stake.stake)
|
||||
(pforgetData (pconstantData ()))
|
||||
Stake.stakeCreationUnsigned
|
||||
, validatorSucceedsWith
|
||||
"stakeDepositWithdraw deposit"
|
||||
(stakeValidator Stake.stake)
|
||||
(pforgetData (pconstantData . toDatum $ StakeDatum 100_000 signer))
|
||||
(pforgetData (pconstantData . toDatum $ DepositWithdraw 100_000))
|
||||
(Stake.stakeDepositWithdraw $ DepositWithdrawExample {startAmount = 100_000, delta = 100_000})
|
||||
, validatorSucceedsWith
|
||||
"stakeDepositWithdraw withdraw"
|
||||
(stakeValidator Stake.stake)
|
||||
(pforgetData (pconstantData . toDatum $ StakeDatum 100_000 signer))
|
||||
(pforgetData (pconstantData . toDatum $ DepositWithdraw (negate 100_000)))
|
||||
(Stake.stakeDepositWithdraw $ DepositWithdrawExample {startAmount = 100_000, delta = negate 100_000})
|
||||
, validatorFailsWith
|
||||
"stakeDepositWithdraw negative GT"
|
||||
(stakeValidator Stake.stake)
|
||||
(pforgetData (pconstantData . toDatum $ StakeDatum 100_000 signer))
|
||||
(pforgetData (pconstantData . toDatum $ DepositWithdraw (negate 1_000_000)))
|
||||
(Stake.stakeDepositWithdraw $ DepositWithdrawExample {startAmount = 100_000, delta = negate 1_000_000})
|
||||
]
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue