-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update to coin selection and tx build strategy to incorporate u…
…pdate of certificates and withdrawals Related to #294.
- Loading branch information
1 parent
28e9059
commit cbd2aa5
Showing
6 changed files
with
92 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
module GeniusYield.Test.Privnet.Stake ( | ||
tests, | ||
) where | ||
|
||
import Data.Maybe (fromJust) | ||
import GeniusYield.Imports | ||
import GeniusYield.Test.Privnet.Ctx | ||
import GeniusYield.Test.Privnet.Setup | ||
import GeniusYield.TxBuilder (mustHaveCertificate) | ||
import GeniusYield.Types | ||
import Test.Tasty (TestTree, testGroup) | ||
import Test.Tasty.HUnit (testCaseSteps) | ||
|
||
-- This will check if we are able to register a stake credential without it's signature. | ||
registerStakeCredentialSteps :: (String -> IO ()) -> Ctx -> IO User | ||
registerStakeCredentialSteps info ctx = do | ||
newUser <- newTempUserCtx ctx (ctxUserF ctx) (valueFromLovelace 1_000_000_000) (CreateUserConfig {cucGenerateCollateral = False, cucGenerateStakeKey = True}) | ||
pp <- ctxGetParams ctx & gyGetProtocolParameters' | ||
info $ "-- Protocol parameters --\n" <> show pp <> "\n-- x --\n" | ||
txBodyReg <- ctxRunI ctx newUser $ do | ||
return $ mustHaveCertificate (mkStakeAddressRegistrationCertificate (userStakePkh newUser & fromJust & GYStakeCredentialByKey)) | ||
info $ "-- Tx body --\n" <> show txBodyReg <> "\n-- x --\n" | ||
void $ submitTx ctx newUser txBodyReg | ||
pure newUser | ||
|
||
deregisterStakeCredentialSteps :: User -> (String -> IO ()) -> Ctx -> IO () | ||
deregisterStakeCredentialSteps user@User{..} info ctx = do | ||
txBodyDereg <- ctxRunI ctx user $ do | ||
return $ mustHaveCertificate (mkStakeAddressDeregistrationCertificate (userStakePkh user & fromJust & GYStakeCredentialByKey) GYTxCertWitnessKey) | ||
info $ "-- Tx body --\n" <> show txBodyDereg <> "\n-- x --\n" | ||
void $ submitTx' ctx $ signGYTxBody txBodyDereg [GYSomeSigningKey userPaymentSKey, userStakeSKey & fromJust & GYSomeSigningKey] | ||
|
||
tests :: IO Setup -> TestTree | ||
tests setup = testGroup "stake" | ||
[ testCaseSteps "able to deregister a registered stake credential" $ \info -> withSetup setup info $ \ctx -> do | ||
newUser <- registerStakeCredentialSteps info ctx | ||
deregisterStakeCredentialSteps newUser info ctx | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters