Skip to content

Commit b1c8790

Browse files
authored
Merge pull request #2818 from IntersectMBO/publish_metadata
Make metadata URLs accessible on localhost
2 parents 3f3be2d + 794050c commit b1c8790

17 files changed

+334
-178
lines changed

cardano_node_tests/cluster_scripts/conway/start-cluster

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,8 +1328,6 @@ if [ -n "${PV10:-""}" ]; then
13281328
--governance-action-tx-id "$ACTION_TXID" \
13291329
--governance-action-index 0 \
13301330
--cc-hot-verification-key-file "$f" \
1331-
--anchor-url "http://www.cc-vote${INDEX}-hf-pv10.com" \
1332-
--anchor-data-hash 5d372dca1a4cc90d7d16d966c48270e33e3aa0abcb0e78f0d5ca7ff330d2245d \
13331331
--out-file "${PV10_ACTION}_cc${INDEX}.vote"
13341332
done
13351333

@@ -1341,8 +1339,6 @@ if [ -n "${PV10:-""}" ]; then
13411339
--governance-action-tx-id "$ACTION_TXID" \
13421340
--governance-action-index 0 \
13431341
--cold-verification-key-file "$f" \
1344-
--anchor-url "http://www.spo-vote${INDEX}-hf-pv10.com" \
1345-
--anchor-data-hash 5d372dca1a4cc90d7d16d966c48270e33e3aa0abcb0e78f0d5ca7ff330d2245d \
13461342
--out-file "${PV10_ACTION}_spo${INDEX}.vote"
13471343
done
13481344

cardano_node_tests/tests/test_node_upgrade.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,12 @@ def _propose_pparams_update(
153153
name_template: str,
154154
proposals: list[clusterlib_utils.UpdateProposal],
155155
) -> conway_common.PParamPropRec:
156-
anchor_url = f"http://www.pparam-action-{clusterlib.get_rand_str(4)}.com"
157-
anchor_data_hash = cluster.g_conway_governance.get_anchor_data_hash(text=anchor_url)
156+
anchor_data = governance_utils.get_default_anchor_data()
158157
return conway_common.propose_pparams_update(
159158
cluster_obj=cluster,
160159
name_template=name_template,
161-
anchor_url=anchor_url,
162-
anchor_data_hash=anchor_data_hash,
160+
anchor_url=anchor_data.url,
161+
anchor_data_hash=anchor_data.hash,
163162
pool_user=pool_user_singleton,
164163
proposals=proposals,
165164
prev_action_rec=prev_action_rec,
@@ -232,8 +231,7 @@ def test_hardfork(
232231

233232
# Create an action
234233
deposit_amt = cluster.conway_genesis["govActionDeposit"]
235-
anchor_url = "http://www.hardfork-upgrade-pv10.com"
236-
anchor_data_hash = "5d372dca1a4cc90d7d16d966c48270e33e3aa0abcb0e78f0d5ca7ff330d2245d"
234+
anchor_data = governance_utils.get_default_anchor_data()
237235
prev_action_rec = governance_utils.get_prev_action(
238236
action_type=governance_utils.PrevGovActionIds.HARDFORK,
239237
gov_state=cluster.g_conway_governance.query.gov_state(),
@@ -242,8 +240,8 @@ def test_hardfork(
242240
hardfork_action = cluster.g_conway_governance.action.create_hardfork(
243241
action_name=temp_template,
244242
deposit_amt=deposit_amt,
245-
anchor_url=anchor_url,
246-
anchor_data_hash=anchor_data_hash,
243+
anchor_url=anchor_data.url,
244+
anchor_data_hash=anchor_data.hash,
247245
protocol_major_version=10,
248246
protocol_minor_version=0,
249247
prev_action_txid=prev_action_rec.txid,

cardano_node_tests/tests/test_pools.py

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from cardano_node_tests.utils import locking
3232
from cardano_node_tests.utils import temptools
3333
from cardano_node_tests.utils import tx_view
34+
from cardano_node_tests.utils import web
3435

3536
DATA_DIR = pl.Path(__file__).parent / "data"
3637
LOGGER = logging.getLogger(__name__)
@@ -723,16 +724,19 @@ def test_stake_pool_not_avail_metadata(
723724
"ticker": "QA1",
724725
"homepage": "www.test1.com",
725726
}
726-
pool_metadata_file = helpers.write_json(
727-
out_file=f"{pool_name}_registration_metadata.json", content=pool_metadata
727+
pool_metadata_file = pl.Path(
728+
helpers.write_json(
729+
out_file=f"{pool_name}_registration_metadata.json", content=pool_metadata
730+
)
728731
)
732+
pool_metadata_url = web.publish(file_path=pool_metadata_file)
729733

730734
pool_data = clusterlib.PoolData(
731735
pool_name=pool_name,
732736
pool_pledge=1_000,
733737
pool_cost=cluster.g_query.get_protocol_params().get("minPoolCost", 500),
734738
pool_margin=0.2,
735-
pool_metadata_url="https://www.where_metadata_file_is_located.com",
739+
pool_metadata_url=pool_metadata_url,
736740
pool_metadata_hash=cluster.g_stake_pool.gen_pool_metadata_hash(pool_metadata_file),
737741
)
738742

@@ -858,16 +862,19 @@ def test_deregister_stake_pool(
858862
"ticker": "QA1",
859863
"homepage": "www.test1.com",
860864
}
861-
pool_metadata_file = helpers.write_json(
862-
out_file=f"{pool_name}_registration_metadata.json", content=pool_metadata
865+
pool_metadata_file = pl.Path(
866+
helpers.write_json(
867+
out_file=f"{pool_name}_registration_metadata.json", content=pool_metadata
868+
)
863869
)
870+
pool_metadata_url = web.publish(file_path=pool_metadata_file)
864871

865872
pool_data = clusterlib.PoolData(
866873
pool_name=pool_name,
867874
pool_pledge=222,
868875
pool_cost=cluster.g_query.get_protocol_params().get("minPoolCost", 500),
869876
pool_margin=0.512,
870-
pool_metadata_url="https://www.where_metadata_file_is_located.com",
877+
pool_metadata_url=pool_metadata_url,
871878
pool_metadata_hash=cluster.g_stake_pool.gen_pool_metadata_hash(pool_metadata_file),
872879
)
873880

@@ -1001,16 +1008,19 @@ def test_reregister_stake_pool(
10011008
"ticker": "QA1",
10021009
"homepage": "www.test1.com",
10031010
}
1004-
pool_metadata_file = helpers.write_json(
1005-
out_file=f"{pool_name}_registration_metadata.json", content=pool_metadata
1011+
pool_metadata_file = pl.Path(
1012+
helpers.write_json(
1013+
out_file=f"{pool_name}_registration_metadata.json", content=pool_metadata
1014+
)
10061015
)
1016+
pool_metadata_url = web.publish(file_path=pool_metadata_file)
10071017

10081018
pool_data = clusterlib.PoolData(
10091019
pool_name=pool_name,
10101020
pool_pledge=222,
10111021
pool_cost=cluster.g_query.get_protocol_params().get("minPoolCost", 500),
10121022
pool_margin=0.512,
1013-
pool_metadata_url="https://www.where_metadata_file_is_located.com",
1023+
pool_metadata_url=pool_metadata_url,
10141024
pool_metadata_hash=cluster.g_stake_pool.gen_pool_metadata_hash(pool_metadata_file),
10151025
)
10161026

@@ -1162,16 +1172,19 @@ def test_cancel_stake_pool_deregistration(
11621172
"ticker": "QA1",
11631173
"homepage": "www.test1.com",
11641174
}
1165-
pool_metadata_file = helpers.write_json(
1166-
out_file=f"{pool_name}_registration_metadata.json", content=pool_metadata
1175+
pool_metadata_file = pl.Path(
1176+
helpers.write_json(
1177+
out_file=f"{pool_name}_registration_metadata.json", content=pool_metadata
1178+
)
11671179
)
1180+
pool_metadata_url = web.publish(file_path=pool_metadata_file)
11681181

11691182
pool_data = clusterlib.PoolData(
11701183
pool_name=pool_name,
11711184
pool_pledge=222,
11721185
pool_cost=cluster.g_query.get_protocol_params().get("minPoolCost", 500),
11731186
pool_margin=0.512,
1174-
pool_metadata_url="https://www.where_metadata_file_is_located.com",
1187+
pool_metadata_url=pool_metadata_url,
11751188
pool_metadata_hash=cluster.g_stake_pool.gen_pool_metadata_hash(pool_metadata_file),
11761189
)
11771190

@@ -1306,33 +1319,37 @@ def test_update_stake_pool_metadata(
13061319
"ticker": "QA1",
13071320
"homepage": "www.test1.com",
13081321
}
1309-
pool_metadata_file = helpers.write_json(
1310-
out_file=f"{pool_name}_registration_metadata.json", content=pool_metadata
1322+
pool_metadata_file = pl.Path(
1323+
helpers.write_json(out_file=f"{pool_name}_reg_metadata.json", content=pool_metadata)
13111324
)
1325+
pool_metadata_url = web.publish(file_path=pool_metadata_file)
13121326

13131327
pool_metadata_updated = {
13141328
"name": f"{pool_name}_U",
13151329
"description": "pool description update",
13161330
"ticker": "QA22",
13171331
"homepage": "www.qa22.com",
13181332
}
1319-
pool_metadata_updated_file = helpers.write_json(
1320-
out_file=f"{pool_name}_registration_metadata_updated.json",
1321-
content=pool_metadata_updated,
1333+
pool_metadata_updated_file = pl.Path(
1334+
helpers.write_json(
1335+
out_file=f"{pool_name}_reg_metadata_updtd.json",
1336+
content=pool_metadata_updated,
1337+
)
13221338
)
1339+
pool_metadata_updated_url = web.publish(file_path=pool_metadata_updated_file)
13231340

13241341
pool_data = clusterlib.PoolData(
13251342
pool_name=pool_name,
13261343
pool_pledge=4567,
13271344
pool_cost=cluster.g_query.get_protocol_params().get("minPoolCost", 500),
13281345
pool_margin=0.01,
1329-
pool_metadata_url="https://init_location.com",
1346+
pool_metadata_url=pool_metadata_url,
13301347
pool_metadata_hash=cluster.g_stake_pool.gen_pool_metadata_hash(pool_metadata_file),
13311348
)
13321349

13331350
pool_data_updated = dataclasses.replace(
13341351
pool_data,
1335-
pool_metadata_url="https://www.updated_location.com",
1352+
pool_metadata_url=pool_metadata_updated_url,
13361353
pool_metadata_hash=cluster.g_stake_pool.gen_pool_metadata_hash(
13371354
pool_metadata_updated_file
13381355
),
@@ -1438,9 +1455,12 @@ def test_update_stake_pool_parameters(
14381455
"ticker": "QA1",
14391456
"homepage": "www.test1.com",
14401457
}
1441-
pool_metadata_file = helpers.write_json(
1442-
out_file=f"{pool_name}_registration_metadata.json", content=pool_metadata
1458+
pool_metadata_file = pl.Path(
1459+
helpers.write_json(
1460+
out_file=f"{pool_name}_registration_metadata.json", content=pool_metadata
1461+
)
14431462
)
1463+
pool_metadata_url = web.publish(file_path=pool_metadata_file)
14441464

14451465
min_pool_cost = cluster.g_query.get_protocol_params().get("minPoolCost", 500)
14461466

@@ -1449,7 +1469,7 @@ def test_update_stake_pool_parameters(
14491469
pool_pledge=4_567,
14501470
pool_cost=min_pool_cost,
14511471
pool_margin=0.01,
1452-
pool_metadata_url="https://www.where_metadata_file_is_located.com",
1472+
pool_metadata_url=pool_metadata_url,
14531473
pool_metadata_hash=cluster.g_stake_pool.gen_pool_metadata_hash(pool_metadata_file),
14541474
)
14551475

@@ -2461,7 +2481,7 @@ def test_stake_pool_long_metadata_url(
24612481
pool_pledge=1_000,
24622482
pool_cost=500_000_000,
24632483
pool_margin=0.2,
2464-
pool_metadata_url=(f"https://gist.githubusercontent.com/{metadata_url}.json"),
2484+
pool_metadata_url=f"https://gist.githubusercontent.com/{metadata_url}.json",
24652485
pool_metadata_hash=pool_metadata_hash,
24662486
)
24672487

cardano_node_tests/tests/test_tx_fees.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import itertools
44
import logging
5+
import pathlib as pl
56

67
import allure
78
import hypothesis
@@ -14,6 +15,7 @@
1415
from cardano_node_tests.tests import common
1516
from cardano_node_tests.utils import clusterlib_utils
1617
from cardano_node_tests.utils import helpers
18+
from cardano_node_tests.utils import web
1719
from cardano_node_tests.utils.versions import VERSIONS
1820

1921
LOGGER = logging.getLogger(__name__)
@@ -338,16 +340,19 @@ def test_pool_registration_fees(
338340
"ticker": "QA1",
339341
"homepage": "www.test1.com",
340342
}
341-
pool_metadata_file = helpers.write_json(
342-
out_file=f"{pool_name}_registration_metadata.json", content=pool_metadata
343+
pool_metadata_file = pl.Path(
344+
helpers.write_json(
345+
out_file=f"{pool_name}_registration_metadata.json", content=pool_metadata
346+
)
343347
)
348+
pool_metadata_url = web.publish(file_path=pool_metadata_file)
344349

345350
pool_data = clusterlib.PoolData(
346351
pool_name=pool_name,
347352
pool_pledge=1_000,
348353
pool_cost=15,
349354
pool_margin=0.2,
350-
pool_metadata_url="https://www.where_metadata_file_is_located.com",
355+
pool_metadata_url=pool_metadata_url,
351356
pool_metadata_hash=cluster.g_stake_pool.gen_pool_metadata_hash(pool_metadata_file),
352357
)
353358

@@ -392,16 +397,19 @@ def test_pool_deregistration_fees(
392397
"ticker": "QA1",
393398
"homepage": "www.test1.com",
394399
}
395-
pool_metadata_file = helpers.write_json(
396-
out_file=f"{pool_name}_registration_metadata.json", content=pool_metadata
400+
pool_metadata_file = pl.Path(
401+
helpers.write_json(
402+
out_file=f"{pool_name}_registration_metadata.json", content=pool_metadata
403+
)
397404
)
405+
pool_metadata_url = web.publish(file_path=pool_metadata_file)
398406

399407
pool_data = clusterlib.PoolData(
400408
pool_name=pool_name,
401409
pool_pledge=222,
402410
pool_cost=123,
403411
pool_margin=0.512,
404-
pool_metadata_url="https://www.where_metadata_file_is_located.com",
412+
pool_metadata_url=pool_metadata_url,
405413
pool_metadata_hash=cluster.g_stake_pool.gen_pool_metadata_hash(pool_metadata_file),
406414
)
407415

cardano_node_tests/tests/tests_conway/conway_common.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import itertools
55
import json
66
import logging
7+
import pathlib as pl
78
import typing as tp
89

910
from cardano_clusterlib import clusterlib
@@ -12,6 +13,8 @@
1213
from cardano_node_tests.tests import common
1314
from cardano_node_tests.utils import clusterlib_utils
1415
from cardano_node_tests.utils import governance_utils
16+
from cardano_node_tests.utils import helpers
17+
from cardano_node_tests.utils import web
1518

1619
LOGGER = logging.getLogger(__name__)
1720

@@ -233,6 +236,7 @@ def cast_vote(
233236
votes_drep_keys = [] # DRep votes with key
234237
votes_drep_scripts = [] # DRep votes with script
235238
votes_spo = []
239+
anchor_data = governance_utils.get_default_anchor_data()
236240

237241
if approve_cc is not None:
238242
_votes_cc = [
@@ -244,8 +248,8 @@ def cast_vote(
244248
action_ix=action_ix,
245249
vote=get_yes_abstain_vote(i) if approve_cc else get_no_abstain_vote(i),
246250
cc_hot_vkey_file=m.hot_keys.hot_vkey_file,
247-
anchor_url=f"http://www.cc-vote{i}.com",
248-
anchor_data_hash="5d372dca1a4cc90d7d16d966c48270e33e3aa0abcb0e78f0d5ca7ff330d2245d",
251+
anchor_url=anchor_data.url,
252+
anchor_data_hash=anchor_data.hash,
249253
)
250254
for i, m in enumerate(governance_data.cc_key_members, start=1)
251255
]
@@ -261,8 +265,8 @@ def cast_vote(
261265
action_ix=action_ix,
262266
vote=get_yes_abstain_vote(i) if approve_drep else get_no_abstain_vote(i),
263267
drep_vkey_file=d.key_pair.vkey_file,
264-
anchor_url=f"http://www.drep-vote{i}.com",
265-
anchor_data_hash="5d372dca1a4cc90d7d16d966c48270e33e3aa0abcb0e78f0d5ca7ff330d2245d",
268+
anchor_url=anchor_data.url,
269+
anchor_data_hash=anchor_data.hash,
266270
)
267271
for i, d in enumerate(governance_data.dreps_reg, start=1)
268272
]
@@ -275,8 +279,8 @@ def cast_vote(
275279
action_ix=action_ix,
276280
vote=get_yes_abstain_vote(i) if approve_drep else get_no_abstain_vote(i),
277281
drep_script_hash=d.script_hash,
278-
anchor_url=f"http://www.sdrep-vote{i}.com",
279-
anchor_data_hash="5d372dca1a4cc90d7d16d966c48270e33e3aa0abcb0e78f0d5ca7ff330d2245d",
282+
anchor_url=anchor_data.url,
283+
anchor_data_hash=anchor_data.hash,
280284
)
281285
for i, d in enumerate(governance_data.drep_scripts_reg, start=1)
282286
]
@@ -294,8 +298,8 @@ def cast_vote(
294298
action_ix=action_ix,
295299
vote=get_yes_abstain_vote(i) if approve_spo else get_no_abstain_vote(i),
296300
cold_vkey_file=p.vkey_file,
297-
anchor_url=f"http://www.spo-vote{i}.com",
298-
anchor_data_hash="5d372dca1a4cc90d7d16d966c48270e33e3aa0abcb0e78f0d5ca7ff330d2245d",
301+
anchor_url=anchor_data.url,
302+
anchor_data_hash=anchor_data.hash,
299303
)
300304
for i, p in enumerate(governance_data.pools_cold, start=1)
301305
]
@@ -368,12 +372,19 @@ def resign_ccs(
368372
payment_addr: clusterlib.AddressRecord,
369373
) -> clusterlib.TxRawOutput:
370374
"""Resign multiple CC Members."""
375+
res_metadata_file = pl.Path(f"{name_template}_res_metadata.json")
376+
res_metadata_content = {"name": "Resigned CC member"}
377+
helpers.write_json(out_file=res_metadata_file, content=res_metadata_content)
378+
res_metadata_hash = cluster_obj.g_conway_governance.get_anchor_data_hash(
379+
file_text=res_metadata_file
380+
)
381+
res_metadata_url = web.publish(file_path=res_metadata_file)
371382
res_certs = [
372383
cluster_obj.g_conway_governance.committee.gen_cold_key_resignation_cert(
373384
key_name=f"{name_template}_{i}",
374385
cold_vkey_file=r.cold_vkey_file,
375-
resignation_metadata_url=f"http://www.cc-resign{i}.com",
376-
resignation_metadata_hash="5d372dca1a4cc90d7d16d966c48270e33e3aa0abcb0e78f0d5ca7ff330d2245d",
386+
resignation_metadata_url=res_metadata_url,
387+
resignation_metadata_hash=res_metadata_hash,
377388
)
378389
for i, r in enumerate(ccs_to_resign, start=1)
379390
]

0 commit comments

Comments
 (0)