@@ -42,14 +42,36 @@ def test_stake_delegation(self):
4242 )
4343 stake_registration = StakeRegistration (stake_credential )
4444 pool_hash = PoolKeyHash (bytes .fromhex (os .environ .get ("POOL_ID" ).strip ()))
45- stake_delegation = StakeDelegation (stake_credential , pool_keyhash = pool_hash )
45+ # stake_delegation = StakeDelegation(stake_credential, pool_keyhash=pool_hash)
46+
47+ drep = DRep (
48+ DRepKind .VERIFICATION_KEY_HASH ,
49+ self .stake_key_pair .verification_key .hash (),
50+ )
51+
52+ drep_credential = DRepCredential (
53+ self .stake_key_pair .verification_key .hash ()
54+ )
55+
56+ anchor = Anchor (
57+ url = "https://drep.com" ,
58+ data_hash = AnchorDataHash ((bytes .fromhex ("0" * 64 ))),
59+ )
60+
61+ drep_registration = RegDRepCert (
62+ drep_credential = drep_credential , coin = 500000000 , anchor = anchor
63+ )
64+
65+ all_in_one_cert = StakeRegistrationAndDelegationAndVoteDelegation (
66+ stake_credential , pool_hash , drep , 1000000
67+ )
4668
4769 builder = TransactionBuilder (self .chain_context )
4870
4971 builder .add_input_address (address )
5072 builder .add_output (TransactionOutput (address , 35000000 ))
5173
52- builder .certificates = [stake_registration , stake_delegation ]
74+ builder .certificates = [drep_registration , all_in_one_cert ]
5375
5476 signed_tx = builder .build_and_sign (
5577 [self .stake_key_pair .signing_key , self .payment_key_pair .signing_key ],
@@ -62,7 +84,7 @@ def test_stake_delegation(self):
6284 print ("############### Submitting transaction ###############" )
6385 self .chain_context .submit_tx (signed_tx )
6486
65- time .sleep (8 )
87+ time .sleep (120 )
6688
6789 builder = TransactionBuilder (self .chain_context )
6890
@@ -73,7 +95,15 @@ def test_stake_delegation(self):
7395 network = self .NETWORK ,
7496 )
7597
76- builder .withdrawals = Withdrawals ({bytes (stake_address ): 0 })
98+ rewards = self .chain_context .query_account_reward_summaries (
99+ keys = [stake_address .encode ()]
100+ )
101+
102+ stake_address_reward = rewards [stake_address .staking_part .payload .hex ()][
103+ "rewards"
104+ ]["ada" ]["lovelace" ]
105+
106+ builder .withdrawals = Withdrawals ({bytes (stake_address ): stake_address_reward })
77107
78108 builder .add_output (TransactionOutput (address , 1000000 ))
79109
0 commit comments