Skip to content

Commit

Permalink
VotedSameLikeBefore -> VoteSameAsBefore
Browse files Browse the repository at this point in the history
  • Loading branch information
paweljakubas committed Apr 30, 2024
1 parent 81059e4 commit f7d9712
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions lib/unit/test/unit/Cardano/Wallet/DelegationSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ spec = describe "Cardano.Wallet.DelegationSpec" $ do
`shouldBe` Right ()
it "Cannot rejoin A, when active = A in Conway" $ do
let dlg = WalletDelegation {active = Delegating pidA, next = []}
WD.guardJoin Write.RecentEraConway knownPools dlg pidA noRetirementPlanned VotedSameLikeBefore
WD.guardJoin Write.RecentEraConway knownPools dlg pidA noRetirementPlanned VotedSameAsBefore
`shouldBe` Left (W.ErrAlreadyDelegatingVoting pidA)
it "Cannot join A, when next = [A] in Babbage" $ do
let next1 = WalletDelegationNext (EpochNo 1) (Delegating pidA)
Expand All @@ -152,7 +152,7 @@ spec = describe "Cardano.Wallet.DelegationSpec" $ do
it "Can join A, when next = [A] in Conway" $ do
let next1 = WalletDelegationNext (EpochNo 1) (Delegating pidA)
let dlg = WalletDelegation {active = NotDelegating, next = [next1]}
WD.guardJoin Write.RecentEraConway knownPools dlg pidA noRetirementPlanned VotedSameLikeBefore
WD.guardJoin Write.RecentEraConway knownPools dlg pidA noRetirementPlanned VotedSameAsBefore
`shouldBe` Left (W.ErrAlreadyDelegatingVoting pidA)
it "Can join A, when active = A, next = [B] in any era" $ do
let next1 = WalletDelegationNext (EpochNo 1) (Delegating pidB)
Expand All @@ -162,7 +162,7 @@ spec = describe "Cardano.Wallet.DelegationSpec" $ do
`shouldBe` Right ()
WD.guardJoin Write.RecentEraConway knownPools dlg pidA noRetirementPlanned VotedDifferently
`shouldBe` Right ()
WD.guardJoin Write.RecentEraConway knownPools dlg pidA noRetirementPlanned VotedSameLikeBefore
WD.guardJoin Write.RecentEraConway knownPools dlg pidA noRetirementPlanned VotedSameAsBefore
`shouldBe` Right ()
it "Cannot join A, when active = A, next = [B, A] in Babbage" $ do
let next1 = WalletDelegationNext (EpochNo 1) (Delegating pidB)
Expand All @@ -183,15 +183,15 @@ spec = describe "Cardano.Wallet.DelegationSpec" $ do
let next2 = WalletDelegationNext (EpochNo 2) (Delegating pidA)
let dlg = WalletDelegation
{active = Delegating pidA, next = [next1, next2]}
WD.guardJoin Write.RecentEraConway knownPools dlg pidA noRetirementPlanned VotedSameLikeBefore
WD.guardJoin Write.RecentEraConway knownPools dlg pidA noRetirementPlanned VotedSameAsBefore
`shouldBe` Left (W.ErrAlreadyDelegatingVoting pidA)
it "Cannot join when pool is unknown in any era" $ do
let dlg = WalletDelegation {active = NotDelegating, next = []}
WD.guardJoin Write.RecentEraBabbage knownPools dlg pidUnknown noRetirementPlanned NotVotedYet
`shouldBe` Left (W.ErrNoSuchPool pidUnknown)
WD.guardJoin Write.RecentEraConway knownPools dlg pidUnknown noRetirementPlanned VotedDifferently
`shouldBe` Left (W.ErrNoSuchPool pidUnknown)
WD.guardJoin Write.RecentEraConway knownPools dlg pidUnknown noRetirementPlanned VotedSameLikeBefore
WD.guardJoin Write.RecentEraConway knownPools dlg pidUnknown noRetirementPlanned VotedSameAsBefore
`shouldBe` Left (W.ErrNoSuchPool pidUnknown)
it "Cannot quit when active: not_delegating, next = []" $ do
let dlg = WalletDelegation {active = NotDelegating, next = []}
Expand Down
4 changes: 2 additions & 2 deletions lib/wallet/src/Cardano/Wallet/Delegation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ data DelegationRequest
-- ^ Stop delegating if the wallet is delegating.
deriving (Eq, Show)

data VoteRequest = NotVotedYet | VotedSameLikeBefore | VotedDifferently
data VoteRequest = NotVotedYet | VotedSameAsBefore | VotedDifferently
deriving (Eq, Show)

{-----------------------------------------------------------------------------
Expand Down Expand Up @@ -154,7 +154,7 @@ guardJoin era knownPools delegation pid mRetirementEpochInfo votedTheSameM = do
Left (ErrAlreadyDelegating pid)
(Write.RecentEraConway, NotVotedYet) ->
Left (ErrAlreadyDelegating pid)
(Write.RecentEraConway, VotedSameLikeBefore) ->
(Write.RecentEraConway, VotedSameAsBefore) ->
Left (ErrAlreadyDelegatingVoting pid)
(Write.RecentEraConway, VotedDifferently) ->
pure ()
Expand Down
6 changes: 3 additions & 3 deletions lib/wallet/src/Cardano/Wallet/IO/Delegation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ handleDelegationVoteRequest
pure (optionalDelegationAction, optionalVoteAction)
where
toDrepEnriched NotVotedYet = Nothing
toDrepEnriched VotedSameLikeBefore = Just (True, fromJust drepM)
toDrepEnriched VotedSameAsBefore = Just (True, fromJust drepM)
toDrepEnriched VotedDifferently = Just (False, fromJust drepM)

handleDelegationRequest
Expand Down Expand Up @@ -231,7 +231,7 @@ voteAction ctx action = do

sameWalletDelegation (WalletDelegation current coming) =
if isDRepSame current || any isSameNext coming then
VotedSameLikeBefore
VotedSameAsBefore
else
VotedDifferently

Expand Down Expand Up @@ -448,7 +448,7 @@ joinStakePool ctx wid pools poolId poolStatus passphrase = do

votingWalletDelegation (WalletDelegation current coming) =
if isVoting current || any isVotingNext coming then
VotedSameLikeBefore
VotedSameAsBefore
else
VotedDifferently
where
Expand Down

0 comments on commit f7d9712

Please sign in to comment.