Skip to content

Commit

Permalink
Adjust roundtrip property
Browse files Browse the repository at this point in the history
  • Loading branch information
Anviking committed May 4, 2021
1 parent 6a80ad3 commit d273f94
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Expand Up @@ -182,8 +182,6 @@ data Cert
| DeRegisterKey RewardAccount
deriving (Eq, Show, Generic)



--
--
-- a portfolio of 3 keys:
Expand Down Expand Up @@ -224,7 +222,13 @@ setPortfolioOf s isReg n =
then [Delegate (acct ix)]
else [RegisterKey (acct ix), Delegate (acct ix)]
)
dereg = map $ \ix -> DeRegisterKey (acct ix)
dereg ixs =
[ DeRegisterKey (acct ix)
| ix <- ixs
, isReg . acct $ ix
-- We need to /at least/ check @isReg (key 0)@, because the user could
-- have deregistered it using old wallet software.
]
acct = toRewardAccount . keyAtIx s

applyTx
Expand Down
Expand Up @@ -134,10 +134,11 @@ spec = do
let usableKeys' = usableKeys . fst . fst . applyCmds
usableKeys' cmds
=== usableKeys' (filter (not . isAdversarial) cmds)
it "chainFromCmds (cmdsFromChain (chainFromCmds cmds)) == chainFromCmds cmds"
it "cmds and (cmdsFromChain (chainFromCmds cmds)) produce the same state"
$ property $ \cmds -> do
chainFromCmds (cmdsFromChain (chainFromCmds cmds))
=== chainFromCmds (filter (not . isAdversarial) cmds)
let ((s, _ledger), txs) = applyCmds (filter (not . isAdversarial) cmds)
let ((s', _ledger), _txs) = applyCmds $ cmdsFromChain txs
s' === s
it "(apply (cmds <> CmdSetPortfolioOf 0) s0) === s0"
$ property $ \cmds -> do
let ((s, _ledger), _chain) = applyCmds (cmds ++ [CmdSetPortfolioOf 0])
Expand Down

0 comments on commit d273f94

Please sign in to comment.