Skip to content

Commit ebc6130

Browse files
test(db-sync config): Add db-sync test for governance option
1 parent 1a27e31 commit ebc6130

12 files changed

+154
-48
lines changed

cardano_node_tests/tests/test_dbsync_config.py

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from cardano_node_tests.utils import cluster_nodes
1515
from cardano_node_tests.utils import configuration
1616
from cardano_node_tests.utils import dbsync_service_manager as db_sync
17+
from cardano_node_tests.utils import dbsync_queries
1718
from cardano_node_tests.utils import dbsync_utils
1819
from cardano_node_tests.utils import helpers
1920

@@ -143,7 +144,6 @@ def basic_tx_out(
143144
"""Test `tx_out` option."""
144145
db_config = db_sync_manager.get_config_builder()
145146

146-
# Test tx_out : enable
147147
db_sync_manager.restart_with_config(
148148
custom_config=db_config.with_tx_out(
149149
value=db_sync.TxOutMode.ENABLE, force_tx_in=False, use_address_table=False
@@ -158,7 +158,6 @@ def basic_tx_out(
158158
}
159159
)
160160

161-
# Test tx_out : disable
162161
db_sync_manager.restart_with_config(
163162
custom_config=db_config.with_tx_out(
164163
value=db_sync.TxOutMode.DISABLE, force_tx_in=True, use_address_table=True
@@ -177,6 +176,83 @@ def basic_tx_out(
177176

178177
yield basic_tx_out
179178

179+
def governance(
180+
db_sync_manager: db_sync.DBSyncManager,
181+
):
182+
"""Test `governance` option."""
183+
db_config = db_sync_manager.get_config_builder()
184+
185+
db_sync_manager.restart_with_config(
186+
custom_config=db_config.with_governance(
187+
value=db_sync.SettingState.ENABLE
188+
)
189+
)
190+
# Off-chain vote data is inserted into the database a few minutes after the restart of db-sync
191+
def _query_func():
192+
off_chain_vote_data = next(
193+
iter(dbsync_queries.query_off_chain_vote_data()), None
194+
)
195+
if off_chain_vote_data is None:
196+
msg = f"no any off-chain vota data record found id db-sync database"
197+
raise dbsync_utils.DbSyncNoResponseError(msg)
198+
return off_chain_vote_data
199+
dbsync_utils.retry_query(query_func=_query_func, timeout=360)
200+
201+
check_dbsync_state(
202+
expected_state={
203+
db_sync.Table.COMMITTEE_DE_REGISTRATION: TableCondition.NOT_EMPTY,
204+
db_sync.Table.COMMITTEE_MEMBER: TableCondition.NOT_EMPTY,
205+
db_sync.Table.COMMITTEE_REGISTRATION: TableCondition.NOT_EMPTY,
206+
db_sync.Table.COMMITTEE: TableCondition.NOT_EMPTY,
207+
db_sync.Table.CONSTITUTION: TableCondition.NOT_EMPTY,
208+
db_sync.Table.DELEGATION_VOTE: TableCondition.NOT_EMPTY,
209+
db_sync.Table.DREP_DISTR: TableCondition.NOT_EMPTY,
210+
db_sync.Table.DREP_REGISTRATION: TableCondition.NOT_EMPTY,
211+
db_sync.Table.EPOCH_STATE: TableCondition.NOT_EMPTY,
212+
db_sync.Table.GOV_ACTION_PROPOSAL: TableCondition.NOT_EMPTY,
213+
db_sync.Table.OFF_CHAIN_VOTE_DATA: TableCondition.NOT_EMPTY,
214+
db_sync.Table.OFF_CHAIN_VOTE_DREP_DATA: TableCondition.NOT_EMPTY,
215+
db_sync.Table.OFF_CHAIN_VOTE_EXTERNAL_UPDATE: TableCondition.NOT_EMPTY,
216+
db_sync.Table.OFF_CHAIN_VOTE_FETCH_ERROR: TableCondition.NOT_EMPTY,
217+
db_sync.Table.OFF_CHAIN_VOTE_GOV_ACTION_DATA: TableCondition.NOT_EMPTY,
218+
db_sync.Table.OFF_CHAIN_VOTE_REFERENCE: TableCondition.NOT_EMPTY,
219+
db_sync.Table.VOTING_ANCHOR: TableCondition.NOT_EMPTY,
220+
db_sync.Table.VOTING_PROCEDURE: TableCondition.NOT_EMPTY,
221+
db_sync.Table.TREASURY_WITHDRAWAL: TableCondition.NOT_EMPTY,
222+
}
223+
)
224+
225+
db_sync_manager.restart_with_config(
226+
custom_config=db_config.with_governance(
227+
value=db_sync.SettingState.DISABLE
228+
)
229+
)
230+
check_dbsync_state(
231+
expected_state={
232+
db_sync.Table.COMMITTEE_DE_REGISTRATION: TableCondition.EMPTY,
233+
db_sync.Table.COMMITTEE_MEMBER: TableCondition.EMPTY,
234+
db_sync.Table.COMMITTEE_REGISTRATION: TableCondition.EMPTY,
235+
db_sync.Table.COMMITTEE: TableCondition.EMPTY,
236+
db_sync.Table.CONSTITUTION: TableCondition.EMPTY,
237+
db_sync.Table.DELEGATION_VOTE: TableCondition.EMPTY,
238+
db_sync.Table.DREP_DISTR: TableCondition.EMPTY,
239+
db_sync.Table.DREP_REGISTRATION: TableCondition.EMPTY,
240+
db_sync.Table.EPOCH_STATE: TableCondition.EMPTY,
241+
db_sync.Table.GOV_ACTION_PROPOSAL: TableCondition.EMPTY,
242+
db_sync.Table.OFF_CHAIN_VOTE_DATA: TableCondition.EMPTY,
243+
db_sync.Table.OFF_CHAIN_VOTE_DREP_DATA: TableCondition.EMPTY,
244+
db_sync.Table.OFF_CHAIN_VOTE_EXTERNAL_UPDATE: TableCondition.EMPTY,
245+
db_sync.Table.OFF_CHAIN_VOTE_FETCH_ERROR: TableCondition.EMPTY,
246+
db_sync.Table.OFF_CHAIN_VOTE_GOV_ACTION_DATA: TableCondition.EMPTY,
247+
db_sync.Table.OFF_CHAIN_VOTE_REFERENCE: TableCondition.EMPTY,
248+
db_sync.Table.VOTING_ANCHOR: TableCondition.EMPTY,
249+
db_sync.Table.VOTING_PROCEDURE: TableCondition.EMPTY,
250+
db_sync.Table.TREASURY_WITHDRAWAL: TableCondition.EMPTY,
251+
}
252+
)
253+
254+
yield governance
255+
180256
def tx_cbor_value_enable(
181257
db_sync_manager: db_sync.DBSyncManager,
182258
):

cardano_node_tests/tests/tests_conway/test_committee.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,13 @@
3232

3333
LOGGER = logging.getLogger(__name__)
3434

35-
pytestmark = pytest.mark.skipif(
36-
VERSIONS.transaction_era < VERSIONS.CONWAY,
37-
reason="runs only with Tx era >= Conway",
38-
)
35+
pytestmark = [
36+
pytest.mark.skipif(
37+
VERSIONS.transaction_era < VERSIONS.CONWAY,
38+
reason="runs only with Tx era >= Conway",
39+
),
40+
pytest.mark.dbsync_config
41+
]
3942

4043

4144
@pytest.fixture

cardano_node_tests/tests/tests_conway/test_constitution.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@
2727

2828
LOGGER = logging.getLogger(__name__)
2929

30-
pytestmark = pytest.mark.skipif(
31-
VERSIONS.transaction_era < VERSIONS.CONWAY,
32-
reason="runs only with Tx era >= Conway",
33-
)
30+
pytestmark = [
31+
pytest.mark.skipif(
32+
VERSIONS.transaction_era < VERSIONS.CONWAY,
33+
reason="runs only with Tx era >= Conway",
34+
),
35+
pytest.mark.dbsync_config
36+
]
3437

3538

3639
@pytest.fixture

cardano_node_tests/tests/tests_conway/test_conway.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@
1919
LOGGER = logging.getLogger(__name__)
2020
DATA_DIR = pl.Path(__file__).parent.parent / "data"
2121

22-
pytestmark = pytest.mark.skipif(
23-
VERSIONS.transaction_era < VERSIONS.CONWAY,
24-
reason="runs only with Tx era >= Conway",
25-
)
22+
pytestmark = [
23+
pytest.mark.skipif(
24+
VERSIONS.transaction_era < VERSIONS.CONWAY,
25+
reason="runs only with Tx era >= Conway",
26+
),
27+
pytest.mark.dbsync_config
28+
]
2629

2730

2831
@pytest.fixture

cardano_node_tests/tests/tests_conway/test_drep.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,13 @@
3939

4040
MAINNET_DREP_DEPOSIT = 500_000_000
4141

42-
pytestmark = pytest.mark.skipif(
43-
VERSIONS.transaction_era < VERSIONS.CONWAY,
44-
reason="runs only with Tx era >= Conway",
45-
)
42+
pytestmark = [
43+
pytest.mark.skipif(
44+
VERSIONS.transaction_era < VERSIONS.CONWAY,
45+
reason="runs only with Tx era >= Conway",
46+
),
47+
pytest.mark.dbsync_config
48+
]
4649

4750

4851
@dataclasses.dataclass(frozen=True, order=True)

cardano_node_tests/tests/tests_conway/test_info.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@
2222
LOGGER = logging.getLogger(__name__)
2323
DATA_DIR = pl.Path(__file__).parent.parent / "data"
2424

25-
pytestmark = pytest.mark.skipif(
26-
VERSIONS.transaction_era < VERSIONS.CONWAY,
27-
reason="runs only with Tx era >= Conway",
28-
)
25+
pytestmark = [
26+
pytest.mark.skipif(
27+
VERSIONS.transaction_era < VERSIONS.CONWAY,
28+
reason="runs only with Tx era >= Conway",
29+
),
30+
pytest.mark.dbsync_config
31+
]
2932

3033

3134
@pytest.fixture

cardano_node_tests/tests/tests_conway/test_no_confidence.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@
2323

2424
LOGGER = logging.getLogger(__name__)
2525

26-
pytestmark = pytest.mark.skipif(
27-
VERSIONS.transaction_era < VERSIONS.CONWAY,
28-
reason="runs only with Tx era >= Conway",
29-
)
26+
pytestmark = [
27+
pytest.mark.skipif(
28+
VERSIONS.transaction_era < VERSIONS.CONWAY,
29+
reason="runs only with Tx era >= Conway",
30+
),
31+
pytest.mark.dbsync_config
32+
]
3033

3134

3235
@pytest.fixture

cardano_node_tests/tests/tests_conway/test_pparam_update.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@
2626
LOGGER = logging.getLogger(__name__)
2727
DATA_DIR = pl.Path(__file__).parent.parent / "data"
2828

29-
pytestmark = pytest.mark.skipif(
30-
VERSIONS.transaction_era < VERSIONS.CONWAY,
31-
reason="runs only with Tx era >= Conway",
32-
)
29+
pytestmark = [
30+
pytest.mark.skipif(
31+
VERSIONS.transaction_era < VERSIONS.CONWAY,
32+
reason="runs only with Tx era >= Conway",
33+
),
34+
pytest.mark.dbsync_config
35+
]
3336

3437

3538
NETWORK_GROUP_PPARAMS = {

cardano_node_tests/tests/tests_conway/test_treasury_donation.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@
1717

1818
LOGGER = logging.getLogger(__name__)
1919

20-
pytestmark = pytest.mark.skipif(
21-
VERSIONS.transaction_era < VERSIONS.CONWAY,
22-
reason="runs only with Tx era >= Conway",
23-
)
20+
pytestmark = [
21+
pytest.mark.skipif(
22+
VERSIONS.transaction_era < VERSIONS.CONWAY,
23+
reason="runs only with Tx era >= Conway",
24+
),
25+
pytest.mark.dbsync_config
26+
]
2427

2528

2629
@pytest.fixture

cardano_node_tests/tests/tests_conway/test_treasury_withdrawals.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@
2323

2424
LOGGER = logging.getLogger(__name__)
2525

26-
pytestmark = pytest.mark.skipif(
27-
VERSIONS.transaction_era < VERSIONS.CONWAY,
28-
reason="runs only with Tx era >= Conway",
29-
)
26+
pytestmark = [
27+
pytest.mark.skipif(
28+
VERSIONS.transaction_era < VERSIONS.CONWAY,
29+
reason="runs only with Tx era >= Conway",
30+
),
31+
pytest.mark.dbsync_config
32+
]
3033

3134

3235
@pytest.fixture

0 commit comments

Comments
 (0)