Skip to content

Commit 876db4b

Browse files
authored
[ADP-3430] Additional voting and delegation testing (#4774)
Adding integration test that realizes the following: (a) creates wallet with mnemonic and handle (b) votes no_confidence (c) reads wallet states and confirms it is only voting no_confidence (d) delete the wallet (e) restores wallet and reads it state showing it is only voting no_confidence (f) delegating to pool1 (g) reads wallet states and confirms it is voting no_confidence and delegating to pool1 (h) delete the wallet (i) restores wallet and reads it state showing it is voting no_confidence and delegating to pool1
2 parents 5847239 + f5ce77c commit 876db4b

File tree

1 file changed

+76
-0
lines changed
  • lib/integration/scenarios/Test/Integration/Scenario/API

1 file changed

+76
-0
lines changed

lib/integration/scenarios/Test/Integration/Scenario/API/Voting.hs

+76
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ import Test.Integration.Framework.DSL
8888
, expectResponseCode
8989
, expectSuccess
9090
, fixturePassphrase
91+
, fixtureShelleyWallet
9192
, fixtureWallet
9293
, getFromResponse
9394
, getResponse
@@ -101,6 +102,7 @@ import Test.Integration.Framework.DSL
101102
, notDelegating
102103
, notRetiringPools
103104
, onlyVoting
105+
, postWallet
104106
, quitStakePool
105107
, request
106108
, signTx
@@ -112,6 +114,9 @@ import Test.Integration.Framework.DSL
112114
, (.<)
113115
, (.>)
114116
)
117+
import Test.Integration.Framework.TestData
118+
( payloadWith
119+
)
115120

116121
import qualified Cardano.Wallet.Api.Link as Link
117122
import qualified Data.List.NonEmpty as NE
@@ -986,6 +991,77 @@ spec = describe "VOTING_TRANSACTIONS" $ do
986991
(`shouldBe` votingAndDelegating (ApiT pool2) (ApiT voting2) [])
987992
]
988993

994+
it "VOTING_01j - Delegation works in Conway in presence of voting after wallet delations and restoration"
995+
$ \ctx -> runResourceT $ do
996+
noBabbage ctx "voting can be checked only in Conway onwards"
997+
(w, mnemonic) <- fixtureShelleyWallet ctx
998+
999+
eventually "Initially wallet is neither delegating nor voting" $ do
1000+
getSrcWallet ctx w >>= flip verify
1001+
[ expectField #delegation
1002+
(`shouldBe` notDelegating [])
1003+
]
1004+
1005+
let voting = NoConfidence
1006+
rTx <- joinDRep @n ctx (SpecificDRep voting) (w, fixturePassphrase)
1007+
verify rTx
1008+
[ expectResponseCode HTTP.status202
1009+
]
1010+
1011+
eventually "Wallet is voting NoConfidence" $ do
1012+
getSrcWallet ctx w >>= flip verify
1013+
[ expectField #delegation
1014+
(`shouldBe` onlyVoting(ApiT voting) [])
1015+
]
1016+
1017+
-- delete the wallet
1018+
rDel1 <- request @ApiWallet ctx (Link.deleteWallet @'Shelley w) Default Empty
1019+
expectResponseCode HTTP.status204 rDel1
1020+
1021+
-- restoring the wallet
1022+
let payldCrt = payloadWith "Faucet Wallet" mnemonic
1023+
rRestore1 <- postWallet ctx payldCrt
1024+
verify rRestore1
1025+
[ expectResponseCode HTTP.status201
1026+
]
1027+
1028+
let w' = getFromResponse Prelude.id rRestore1
1029+
eventually "Wallet is voting NoConfidence after restoration" $ do
1030+
getSrcWallet ctx w' >>= flip verify
1031+
[ expectField #delegation
1032+
(`shouldBe` onlyVoting(ApiT voting) [])
1033+
]
1034+
1035+
pool1 : _ : _ <- map (view #id) <$> notRetiringPools ctx
1036+
1037+
-- Join Pool
1038+
rJoin <- joinStakePool @n ctx (SpecificPool pool1) (w', fixturePassphrase)
1039+
verify rJoin
1040+
[ expectResponseCode HTTP.status202
1041+
]
1042+
eventually "Wallet is voting NoConfidence and delegating to pool1" $ do
1043+
getSrcWallet ctx w' >>= flip verify
1044+
[ expectField #delegation
1045+
(`shouldBe` votingAndDelegating (ApiT pool1) (ApiT voting) [])
1046+
]
1047+
1048+
-- delete the wallet once again
1049+
rDel2 <- request @ApiWallet ctx (Link.deleteWallet @'Shelley w') Default Empty
1050+
expectResponseCode HTTP.status204 rDel2
1051+
1052+
-- restoring the wallet once again
1053+
rRestore2 <- postWallet ctx payldCrt
1054+
verify rRestore2
1055+
[ expectResponseCode HTTP.status201
1056+
]
1057+
1058+
let w'' = getFromResponse Prelude.id rRestore2
1059+
eventually "Wallet is voting NoConfidence and deleagting to pool1 after restoration" $ do
1060+
getSrcWallet ctx w'' >>= flip verify
1061+
[ expectField #delegation
1062+
(`shouldBe` votingAndDelegating (ApiT pool1) (ApiT voting) [])
1063+
]
1064+
9891065
where
9901066
stakeKeyDerPath = NE.fromList
9911067
[ ApiT (DerivationIndex 2_147_485_500)

0 commit comments

Comments
 (0)