1313from cardano_node_tests .tests import common
1414from cardano_node_tests .utils import cluster_nodes
1515from cardano_node_tests .utils import configuration
16- from cardano_node_tests .utils import dbsync_queries
1716from cardano_node_tests .utils import dbsync_service_manager as db_sync
1817from cardano_node_tests .utils import dbsync_utils
1918from cardano_node_tests .utils import helpers
@@ -46,8 +45,31 @@ class ColumnCondition(str, enum.Enum):
4645 IS_NULL = "column_condition:IS NULL"
4746
4847
48+ GOVERNANCE_TABLES = (
49+ db_sync .Table .COMMITTEE_DE_REGISTRATION ,
50+ db_sync .Table .COMMITTEE_MEMBER ,
51+ db_sync .Table .COMMITTEE_REGISTRATION ,
52+ db_sync .Table .COMMITTEE ,
53+ db_sync .Table .CONSTITUTION ,
54+ db_sync .Table .DELEGATION_VOTE ,
55+ db_sync .Table .DREP_DISTR ,
56+ db_sync .Table .DREP_REGISTRATION ,
57+ db_sync .Table .EPOCH_STATE ,
58+ db_sync .Table .GOV_ACTION_PROPOSAL ,
59+ db_sync .Table .OFF_CHAIN_VOTE_DATA ,
60+ db_sync .Table .OFF_CHAIN_VOTE_DREP_DATA ,
61+ db_sync .Table .OFF_CHAIN_VOTE_EXTERNAL_UPDATE ,
62+ db_sync .Table .OFF_CHAIN_VOTE_FETCH_ERROR ,
63+ db_sync .Table .OFF_CHAIN_VOTE_GOV_ACTION_DATA ,
64+ db_sync .Table .OFF_CHAIN_VOTE_REFERENCE ,
65+ db_sync .Table .VOTING_ANCHOR ,
66+ db_sync .Table .VOTING_PROCEDURE ,
67+ db_sync .Table .TREASURY_WITHDRAWAL ,
68+ )
69+
70+
4971def check_dbsync_state (
50- expected_state : dict [tp . Union [ str , db_sync .Table ] , TableCondition | ColumnCondition ],
72+ expected_state : dict [str | db_sync .Table , TableCondition | ColumnCondition ],
5173) -> None :
5274 """Check the state of db-sync tables and columns against expected conditions.
5375
@@ -190,31 +212,8 @@ def governance(
190212
191213 # Off-chain data is inserted into the DB a few minutes after the restart of db-sync
192214 def _query_func ():
193- tables_to_check = [
194- db_sync .Table .COMMITTEE_DE_REGISTRATION ,
195- db_sync .Table .COMMITTEE_MEMBER ,
196- db_sync .Table .COMMITTEE_REGISTRATION ,
197- db_sync .Table .COMMITTEE ,
198- db_sync .Table .CONSTITUTION ,
199- db_sync .Table .DELEGATION_VOTE ,
200- db_sync .Table .DREP_DISTR ,
201- db_sync .Table .DREP_REGISTRATION ,
202- db_sync .Table .EPOCH_STATE ,
203- db_sync .Table .GOV_ACTION_PROPOSAL ,
204- db_sync .Table .OFF_CHAIN_VOTE_DATA ,
205- db_sync .Table .OFF_CHAIN_VOTE_DREP_DATA ,
206- db_sync .Table .OFF_CHAIN_VOTE_EXTERNAL_UPDATE ,
207- db_sync .Table .OFF_CHAIN_VOTE_FETCH_ERROR ,
208- db_sync .Table .OFF_CHAIN_VOTE_GOV_ACTION_DATA ,
209- db_sync .Table .OFF_CHAIN_VOTE_REFERENCE ,
210- db_sync .Table .VOTING_ANCHOR ,
211- db_sync .Table .VOTING_PROCEDURE ,
212- db_sync .Table .TREASURY_WITHDRAWAL ,
213- ]
214-
215215 empty_tables = [
216- table for table in tables_to_check
217- if dbsync_utils .table_empty (table )
216+ table for table in GOVERNANCE_TABLES if dbsync_utils .table_empty (table = table )
218217 ]
219218
220219 if empty_tables :
@@ -226,54 +225,14 @@ def _query_func():
226225 dbsync_utils .retry_query (query_func = _query_func , timeout = 600 )
227226
228227 check_dbsync_state (
229- expected_state = {
230- db_sync .Table .COMMITTEE_DE_REGISTRATION : TableCondition .NOT_EMPTY ,
231- db_sync .Table .COMMITTEE_MEMBER : TableCondition .NOT_EMPTY ,
232- db_sync .Table .COMMITTEE_REGISTRATION : TableCondition .NOT_EMPTY ,
233- db_sync .Table .COMMITTEE : TableCondition .NOT_EMPTY ,
234- db_sync .Table .CONSTITUTION : TableCondition .NOT_EMPTY ,
235- db_sync .Table .DELEGATION_VOTE : TableCondition .NOT_EMPTY ,
236- db_sync .Table .DREP_DISTR : TableCondition .NOT_EMPTY ,
237- db_sync .Table .DREP_REGISTRATION : TableCondition .NOT_EMPTY ,
238- db_sync .Table .EPOCH_STATE : TableCondition .NOT_EMPTY ,
239- db_sync .Table .GOV_ACTION_PROPOSAL : TableCondition .NOT_EMPTY ,
240- db_sync .Table .OFF_CHAIN_VOTE_DATA : TableCondition .NOT_EMPTY ,
241- db_sync .Table .OFF_CHAIN_VOTE_DREP_DATA : TableCondition .NOT_EMPTY ,
242- db_sync .Table .OFF_CHAIN_VOTE_EXTERNAL_UPDATE : TableCondition .NOT_EMPTY ,
243- db_sync .Table .OFF_CHAIN_VOTE_FETCH_ERROR : TableCondition .NOT_EMPTY ,
244- db_sync .Table .OFF_CHAIN_VOTE_GOV_ACTION_DATA : TableCondition .NOT_EMPTY ,
245- db_sync .Table .OFF_CHAIN_VOTE_REFERENCE : TableCondition .NOT_EMPTY ,
246- db_sync .Table .VOTING_ANCHOR : TableCondition .NOT_EMPTY ,
247- db_sync .Table .VOTING_PROCEDURE : TableCondition .NOT_EMPTY ,
248- db_sync .Table .TREASURY_WITHDRAWAL : TableCondition .NOT_EMPTY ,
249- }
228+ expected_state = {t : TableCondition .NOT_EMPTY for t in GOVERNANCE_TABLES } # noqa: C420
250229 )
251230
252231 db_sync_manager .restart_with_config (
253232 custom_config = db_config .with_governance (value = db_sync .SettingState .DISABLE )
254233 )
255234 check_dbsync_state (
256- expected_state = {
257- db_sync .Table .COMMITTEE_DE_REGISTRATION : TableCondition .EMPTY ,
258- db_sync .Table .COMMITTEE_MEMBER : TableCondition .EMPTY ,
259- db_sync .Table .COMMITTEE_REGISTRATION : TableCondition .EMPTY ,
260- db_sync .Table .COMMITTEE : TableCondition .EMPTY ,
261- db_sync .Table .CONSTITUTION : TableCondition .EMPTY ,
262- db_sync .Table .DELEGATION_VOTE : TableCondition .EMPTY ,
263- db_sync .Table .DREP_DISTR : TableCondition .EMPTY ,
264- db_sync .Table .DREP_REGISTRATION : TableCondition .EMPTY ,
265- db_sync .Table .EPOCH_STATE : TableCondition .EMPTY ,
266- db_sync .Table .GOV_ACTION_PROPOSAL : TableCondition .EMPTY ,
267- db_sync .Table .OFF_CHAIN_VOTE_DATA : TableCondition .EMPTY ,
268- db_sync .Table .OFF_CHAIN_VOTE_DREP_DATA : TableCondition .EMPTY ,
269- db_sync .Table .OFF_CHAIN_VOTE_EXTERNAL_UPDATE : TableCondition .EMPTY ,
270- db_sync .Table .OFF_CHAIN_VOTE_FETCH_ERROR : TableCondition .EMPTY ,
271- db_sync .Table .OFF_CHAIN_VOTE_GOV_ACTION_DATA : TableCondition .EMPTY ,
272- db_sync .Table .OFF_CHAIN_VOTE_REFERENCE : TableCondition .EMPTY ,
273- db_sync .Table .VOTING_ANCHOR : TableCondition .EMPTY ,
274- db_sync .Table .VOTING_PROCEDURE : TableCondition .EMPTY ,
275- db_sync .Table .TREASURY_WITHDRAWAL : TableCondition .EMPTY ,
276- }
235+ expected_state = {t : TableCondition .EMPTY for t in GOVERNANCE_TABLES } # noqa: C420
277236 )
278237
279238 yield governance
0 commit comments