@@ -8,26 +8,21 @@ module Test.Cardano.Db.Mock.Unit.Conway.Governance (
8
8
) where
9
9
10
10
import Cardano.DbSync.Era.Shelley.Generic.Util (unCredentialHash )
11
- import Cardano.Ledger.Address (Withdrawals (.. ))
12
- import Cardano.Ledger.Alonzo.Tx (AlonzoTx )
13
11
import Cardano.Ledger.Conway.Governance (GovActionId (.. ), GovActionIx (.. ), Voter (.. ))
14
- import Cardano.Ledger.Conway.TxCert (Delegatee (.. ))
15
12
import Cardano.Ledger.Core (txIdTx )
16
13
import Cardano.Ledger.Credential (Credential (.. ))
17
- import Cardano.Ledger.DRep (DRep (.. ))
18
- import Cardano.Ledger.Keys (KeyHash (.. ), KeyRole (.. ))
14
+ import Cardano.Ledger.Keys (KeyHash (.. ))
19
15
import Cardano.Mock.ChainSync.Server (IOManager )
20
16
import qualified Cardano.Mock.Forging.Tx.Conway as Conway
21
17
import qualified Cardano.Mock.Forging.Tx.Generic as Forging
22
18
import Cardano.Mock.Forging.Types
23
19
import qualified Cardano.Mock.Query as Query
24
20
import Cardano.Prelude
25
- import Ouroboros.Consensus.Shelley.Eras (StandardConway , StandardCrypto )
26
21
import Test.Cardano.Db.Mock.Config
27
22
import qualified Test.Cardano.Db.Mock.UnifiedApi as Api
28
23
import Test.Cardano.Db.Mock.Validate
29
24
import Test.Tasty.HUnit (Assertion )
30
- import Prelude ()
25
+ import qualified Prelude
31
26
32
27
drepDistr :: IOManager -> [(Text , Text )] -> Assertion
33
28
drepDistr =
@@ -37,14 +32,8 @@ drepDistr =
37
32
-- Add stake
38
33
void (Api. registerAllStakeCreds interpreter server)
39
34
40
- -- Register a DRep
41
- let drepHash = " 0d94e174732ef9aae73f395ab44507bfa983d65023c11a951f0c32e4"
42
- drepId = KeyHashObj (KeyHash drepHash)
43
-
44
35
-- Register DRep and delegate votes to it
45
- void $
46
- Api. withConwayFindLeaderAndSubmit interpreter server $ \ ledger ->
47
- registerDRepAndDelegateVotes drepId (StakeIndex 4 ) ledger
36
+ void (Api. registerDRepsAndDelegateVotes interpreter server)
48
37
49
38
-- DRep distribution is calculated at end of the current epoch
50
39
epoch1 <- Api. fillUntilNextEpoch interpreter server
@@ -53,6 +42,7 @@ drepDistr =
53
42
assertBlockNoBackoff dbSync (length epoch1 + 2 )
54
43
55
44
-- Should now have a DRep distribution
45
+ let drepId = Prelude. head Forging. unregisteredDRepIds
56
46
assertEqQuery
57
47
dbSync
58
48
(Query. queryDRepDistrAmount (unCredentialHash drepId) 1 )
@@ -69,14 +59,8 @@ newCommittee =
69
59
-- Add stake
70
60
void (Api. registerAllStakeCreds interpreter server)
71
61
72
- -- Register a DRep
73
- let drepHash = " 0d94e174732ef9aae73f395ab44507bfa983d65023c11a951f0c32e4"
74
- drepId = KeyHashObj (KeyHash drepHash)
75
-
76
- -- Register DRep and delegate votes to it
77
- void $
78
- Api. withConwayFindLeaderAndSubmit interpreter server $ \ ledger ->
79
- registerDRepAndDelegateVotes drepId (StakeIndex 4 ) ledger
62
+ -- Register a DRep and delegate votes to it
63
+ void (Api. registerDRepsAndDelegateVotes interpreter server)
80
64
81
65
-- Create and vote for gov action
82
66
let committeeHash = " e0a714319812c3f773ba04ec5d6b3ffcd5aad85006805b047b082541"
@@ -92,7 +76,7 @@ newCommittee =
92
76
addVoteTx =
93
77
Conway. mkGovVoteTx
94
78
govActionId
95
- [ DRepVoter drepId
79
+ [ DRepVoter ( Prelude. head Forging. unregisteredDRepIds)
96
80
, StakePoolVoter (Forging. resolvePool (PoolIndex 0 ) ledger)
97
81
, StakePoolVoter (Forging. resolvePool (PoolIndex 1 ) ledger)
98
82
, StakePoolVoter (Forging. resolvePool (PoolIndex 2 ) ledger)
@@ -120,21 +104,3 @@ newCommittee =
120
104
" Unexpected committee hashes"
121
105
where
122
106
testLabel = " conwayNewCommittee"
123
-
124
- registerDRepAndDelegateVotes ::
125
- Credential 'DRepRole StandardCrypto ->
126
- StakeIndex ->
127
- Conway. ConwayLedgerState ->
128
- Either ForgingError [AlonzoTx StandardConway ]
129
- registerDRepAndDelegateVotes drepId stakeIx ledger = do
130
- stakeCreds <- Forging. resolveStakeCreds stakeIx ledger
131
-
132
- let utxoStake = UTxOAddressNewWithStake 0 stakeIx
133
- regDelegCert =
134
- Conway. mkDelegTxCert (DelegVote $ DRepCredential drepId) stakeCreds
135
-
136
- paymentTx <- Conway. mkPaymentTx (UTxOIndex 0 ) utxoStake 10_000 500 ledger
137
- regTx <- Conway. mkRegisterDRepTx drepId
138
- delegTx <- Conway. mkDCertTx [regDelegCert] (Withdrawals mempty ) Nothing
139
-
140
- pure [paymentTx, regTx, delegTx]
0 commit comments