Skip to content

Commit 6d68952

Browse files
committed
Fix certificates
1 parent ecf1b1a commit 6d68952

File tree

7 files changed

+224
-52
lines changed

7 files changed

+224
-52
lines changed

integration-test/test/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from pycardano import *
1010

11-
TEST_RETRIES = 1
11+
TEST_RETRIES = 8
1212

1313

1414
@retry(tries=10, delay=4)

integration-test/test/test_certificate.py

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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],
@@ -73,9 +95,13 @@ def test_stake_delegation(self):
7395
network=self.NETWORK,
7496
)
7597

76-
rewards = self.chain_context.query_account_reward_summaries(keys=[stake_address.encode()])
98+
rewards = self.chain_context.query_account_reward_summaries(
99+
keys=[stake_address.encode()]
100+
)
77101

78-
stake_address_reward = rewards[stake_address.staking_part.payload.hex()]["rewards"]["ada"]["lovelace"]
102+
stake_address_reward = rewards[stake_address.staking_part.payload.hex()][
103+
"rewards"
104+
]["ada"]["lovelace"]
79105

80106
builder.withdrawals = Withdrawals({bytes(stake_address): stake_address_reward})
81107

pycardano/backend/ogmios_v6.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,13 @@ def utxo_by_tx_id(self, tx_id: str, index: int) -> Optional[UTxO]:
307307
return self._utxo_from_ogmios_result(utxos[0])
308308
return None
309309

310-
def query_account_reward_summaries(self, scripts: List[str]=None, keys: List[str]=None) -> List[dict]:
310+
def query_account_reward_summaries(
311+
self, scripts: Optional[List[str]] = None, keys: Optional[List[str]] = None
312+
) -> List[dict]:
311313
with OgmiosClient(self.host, self.port, self.path, self.secure) as client:
312-
summaries, _ = client.query_reward_account_summaries.execute(scripts=scripts, keys=keys)
314+
summaries, _ = client.query_reward_account_summaries.execute(
315+
scripts=scripts, keys=keys
316+
)
313317
return summaries
314318

315319
def submit_tx_cbor(self, cbor: Union[bytes, str]):

0 commit comments

Comments
 (0)