fix(trading): fix market sim tests (#6132)

This commit is contained in:
daro-maj 2024-03-29 11:21:23 +01:00 committed by GitHub
parent 954b4b2755
commit 029357b5ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 83 additions and 62 deletions

View File

@ -10,7 +10,7 @@ on:
inputs: inputs:
console-test-branch: console-test-branch:
type: choice type: choice
description: 'main: v0.74.10, develop: v0.75.1' description: 'main: v0.74.10, develop: v0.75.5'
options: options:
- main - main
- develop - develop

View File

@ -1,4 +1,4 @@
CONSOLE_IMAGE_NAME=vegaprotocol/trading:latest CONSOLE_IMAGE_NAME=vegaprotocol/trading:latest
VEGA_VERSION=v0.75.1 VEGA_VERSION=v0.75.5
LOCAL_SERVER=false LOCAL_SERVER=false
VEGA_ENV=STAGNET1 VEGA_ENV=STAGNET1

View File

@ -1,4 +1,4 @@
CONSOLE_IMAGE_NAME=vegaprotocol/trading:develop CONSOLE_IMAGE_NAME=vegaprotocol/trading:develop
VEGA_VERSION=v0.75.1 VEGA_VERSION=v0.75.5
LOCAL_SERVER=false LOCAL_SERVER=false
VEGA_ENV=STAGNET1 VEGA_ENV=STAGNET1

View File

@ -1,4 +1,4 @@
# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. # This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand.
[[package]] [[package]]
name = "certifi" name = "certifi"
@ -1165,8 +1165,8 @@ profile = ["pytest-profiling", "snakeviz"]
[package.source] [package.source]
type = "git" type = "git"
url = "https://github.com/vegaprotocol/vega-market-sim.git/" url = "https://github.com/vegaprotocol/vega-market-sim.git/"
reference = "HEAD" reference = "pre-release/vega-v0.75.5"
resolved_reference = "b2b4cd004800ba2732448f329b0fa8f0746d4d0b" resolved_reference = "b2a3437fc13ced2b7ecd582ca4778bbc4b0fe3a6"
[[package]] [[package]]
name = "websocket-client" name = "websocket-client"
@ -1347,4 +1347,4 @@ files = [
[metadata] [metadata]
lock-version = "2.0" lock-version = "2.0"
python-versions = ">=3.9,<3.11" python-versions = ">=3.9,<3.11"
content-hash = "39ce8400de7bf060857447281ef27bd78c9b1d9639da063b051e3ae6e7887a67" content-hash = "80e87cbde486e7bb150fce0b1c974de38501bc16732952b455d43cb843426623"

View File

@ -13,7 +13,7 @@ pytest-playwright = "^0.4.2"
docker = "^6.1.3" docker = "^6.1.3"
pytest-xdist = "^3.3.1" pytest-xdist = "^3.3.1"
python-dotenv = "^1.0.0" python-dotenv = "^1.0.0"
vega-sim = { git = "https://github.com/vegaprotocol/vega-market-sim.git/" } vega-sim = { git = "https://github.com/vegaprotocol/vega-market-sim.git/", branch = "pre-release/vega-v0.75.5"}
[build-system] [build-system]
requires = ["poetry-core"] requires = ["poetry-core"]

View File

@ -13,7 +13,7 @@ pytest-playwright = "^0.4.2"
docker = "^6.1.3" docker = "^6.1.3"
pytest-xdist = "^3.3.1" pytest-xdist = "^3.3.1"
python-dotenv = "^1.0.0" python-dotenv = "^1.0.0"
vega-sim = { git = "https://github.com/vegaprotocol/vega-market-sim.git/" } vega-sim = { git = "https://github.com/vegaprotocol/vega-market-sim.git/", branch = "pre-release/vega-v0.75.5"}
[build-system] [build-system]
requires = ["poetry-core"] requires = ["poetry-core"]

View File

@ -43,7 +43,8 @@ class TestSettledMarket:
"", "",
] ]
page.wait_for_selector('[data-testid="tab-closed-markets"]', state="visible") page.wait_for_selector(
'[data-testid="tab-closed-markets"]', state="visible")
page_headers = ( page_headers = (
page.get_by_test_id("tab-closed-markets") page.get_by_test_id("tab-closed-markets")
.locator(".ag-header-cell-text") .locator(".ag-header-cell-text")
@ -64,16 +65,19 @@ class TestSettledMarket:
).first ).first
# 6001-MARK-001 # 6001-MARK-001
expect(row_selector.locator('[col-id="code"]')).to_have_text("BTC:DAI_2023Futr") expect(row_selector.locator('[col-id="code"]')
).to_have_text("BTC:DAI_2023Futr")
# 6001-MARK-003 # 6001-MARK-003
expect(row_selector.locator('[col-id="state"]')).to_have_text("Settled") expect(row_selector.locator(
'[col-id="state"]')).to_have_text("Settled")
# 6001-MARK-004 # 6001-MARK-004
# 6001-MARK-005 # 6001-MARK-005
# 6001-MARK-009 # 6001-MARK-009
# 6001-MARK-008 # 6001-MARK-008
# 6001-MARK-010 # 6001-MARK-010
pattern = r"(\d+)\s+(months|hours|days|minutes)\s+ago" pattern = r"(\d+)\s+(months|hours|days|minutes)\s+ago"
date_text = row_selector.locator('[col-id="settlementDate"]').inner_text() date_text = row_selector.locator(
'[col-id="settlementDate"]').inner_text()
assert re.match( assert re.match(
pattern, date_text pattern, date_text
), f"Expected text to match pattern but got {date_text}" ), f"Expected text to match pattern but got {date_text}"
@ -86,11 +90,14 @@ class TestSettledMarket:
actual_href actual_href
), f"Expected href to match {expected_pattern.pattern}, but got {actual_href}" ), f"Expected href to match {expected_pattern.pattern}, but got {actual_href}"
# 6001-MARK-011 # 6001-MARK-011
expect(row_selector.locator('[col-id="bestBidPrice"]')).to_have_text("0.00") expect(row_selector.locator(
'[col-id="bestBidPrice"]')).to_have_text("0.00")
# 6001-MARK-012 # 6001-MARK-012
expect(row_selector.locator('[col-id="bestOfferPrice"]')).to_have_text("0.00") expect(row_selector.locator(
'[col-id="bestOfferPrice"]')).to_have_text("0.00")
# 6001-MARK-013 # 6001-MARK-013
expect(row_selector.locator('[col-id="markPrice"]')).to_have_text("110.00") expect(row_selector.locator(
'[col-id="markPrice"]')).to_have_text("110.00")
# 6001-MARK-014 # 6001-MARK-014
# 6001-MARK-015 # 6001-MARK-015
# 6001-MARK-016 # 6001-MARK-016
@ -107,7 +114,8 @@ class TestSettledMarket:
), f"Expected href to match {expected_pattern.pattern}, but got {actual_href}" ), f"Expected href to match {expected_pattern.pattern}, but got {actual_href}"
# 6001-MARK-018 # 6001-MARK-018
expect(row_selector.locator('[col-id="settlementAsset"]')).to_have_text("tDAI") expect(row_selector.locator(
'[col-id="settlementAsset"]')).to_have_text("tDAI")
# 6001-MARK-020 # 6001-MARK-020
assert re.match( assert re.match(
pattern, date_text pattern, date_text
@ -129,8 +137,10 @@ def test_terminated_market_no_settlement_date(page: Page, vega: VegaServiceNull)
row_selector = page.locator( row_selector = page.locator(
'[data-testid="tab-closed-markets"] .ag-center-cols-container .ag-row' '[data-testid="tab-closed-markets"] .ag-center-cols-container .ag-row'
).first ).first
expect(row_selector.locator('[col-id="state"]')).to_have_text("Trading Terminated") expect(row_selector.locator('[col-id="state"]')
expect(row_selector.locator('[col-id="settlementDate"]')).to_have_text("Unknown") ).to_have_text("Trading Terminated")
expect(row_selector.locator(
'[col-id="settlementDate"]')).to_have_text("Unknown")
# TODO Create test for terminated market with settlement date in future # TODO Create test for terminated market with settlement date in future
# TODO Create test for terminated market with settlement date in past # TODO Create test for terminated market with settlement date in past

View File

@ -20,44 +20,50 @@ from wallet_config import MM_WALLET, MM_WALLET2, TERMINATE_WALLET
row_selector = '[data-testid="tab-funding-payments"] .ag-center-cols-container .ag-row' row_selector = '[data-testid="tab-funding-payments"] .ag-center-cols-container .ag-row'
col_amount = '[col-id="amount"]' col_amount = '[col-id="amount"]'
@pytest.fixture(scope="module") @pytest.fixture(scope="module")
def setup_environment( def setup_environment(
request, browser request, browser
) -> Generator[Tuple[Page, VegaServiceNull, str], None, None]: ) -> Generator[Tuple[Page, VegaServiceNull, str], None, None]:
with init_vega(request) as vega: with init_vega(request) as vega:
request.addfinalizer(lambda: cleanup_container(vega)) request.addfinalizer(lambda: cleanup_container(vega))
perps_market = setup_perps_market(vega) perps_market = setup_perps_market(vega)
submit_multiple_orders( submit_multiple_orders(
vega, MM_WALLET.name, perps_market, "SIDE_SELL", [[1, 110], [1, 105]] vega, MM_WALLET.name, perps_market, "SIDE_SELL", [
) [1, 110], [1, 105]]
submit_multiple_orders( )
vega, MM_WALLET2.name, perps_market, "SIDE_BUY", [[1, 90], [1, 95]] submit_multiple_orders(
) vega, MM_WALLET2.name, perps_market, "SIDE_BUY", [[1, 90], [1, 95]]
vega.submit_settlement_data( )
settlement_key=TERMINATE_WALLET.name, vega.submit_settlement_data(
settlement_price=110, settlement_key=TERMINATE_WALLET.name,
market_id=perps_market, settlement_price=110,
) market_id=perps_market,
vega.wait_fn(1) )
vega.wait_for_total_catchup() vega.wait_fn(1)
submit_multiple_orders( vega.wait_for_total_catchup()
vega, MM_WALLET.name, perps_market, "SIDE_SELL", [[1, 110], [1, 105]] submit_multiple_orders(
) vega, MM_WALLET.name, perps_market, "SIDE_SELL", [
submit_multiple_orders( [1, 110], [1, 105]]
vega, MM_WALLET2.name, perps_market, "SIDE_BUY", [[1, 112], [1, 115]] )
) submit_multiple_orders(
vega.submit_settlement_data( vega, MM_WALLET2.name, perps_market, "SIDE_BUY", [
settlement_key=TERMINATE_WALLET.name, [1, 112], [1, 115]]
settlement_price=110, )
market_id=perps_market, vega.submit_settlement_data(
) settlement_key=TERMINATE_WALLET.name,
vega.wait_fn(10) settlement_price=110,
vega.wait_for_total_catchup() market_id=perps_market,
)
vega.wait_fn(10)
vega.wait_for_total_catchup()
with init_page(vega, browser, request) as page:
risk_accepted_setup(page)
auth_setup(vega, page)
yield page, vega, perps_market
with init_page(vega, browser, request) as page:
risk_accepted_setup(page)
auth_setup(vega, page)
yield page, vega, perps_market
class TestPerpetuals: class TestPerpetuals:
def test_funding_payment_profit(self, def test_funding_payment_profit(self,
setup_environment: Tuple[Page, str, str], setup_environment: Tuple[Page, str, str],
@ -86,7 +92,8 @@ class TestPerpetuals:
expect(page.get_by_test_id("market-funding")).to_contain_text( expect(page.get_by_test_id("market-funding")).to_contain_text(
"Funding Rate / Countdown-8.1818%" "Funding Rate / Countdown-8.1818%"
) )
expect(page.get_by_test_id("index-price")).to_have_text("Index Price110.00") expect(page.get_by_test_id("index-price")
).to_have_text("Index Price110.00")
@pytest.mark.skip("Skipped due to issue #5421") @pytest.mark.skip("Skipped due to issue #5421")
def test_funding_payment_history(perps_market, page: Page, vega): def test_funding_payment_history(perps_market, page: Page, vega):
@ -106,6 +113,7 @@ class TestPerpetuals:
print("Bounding box not found for the element") print("Bounding box not found for the element")
@pytest.mark.skip("need to be clarify")
@pytest.mark.usefixtures("risk_accepted", "auth") @pytest.mark.usefixtures("risk_accepted", "auth")
def test_perps_market_termination_proposed(page: Page, vega: VegaServiceNull): def test_perps_market_termination_proposed(page: Page, vega: VegaServiceNull):
perpetual_market = setup_perps_market(vega) perpetual_market = setup_perps_market(vega)
@ -115,7 +123,7 @@ def test_perps_market_termination_proposed(page: Page, vega: VegaServiceNull):
market_id=perpetual_market, market_id=perpetual_market,
market_state=MarketStateUpdateType.Terminate, market_state=MarketStateUpdateType.Terminate,
price=100, price=100,
vote_closing_time=datetime.now() + timedelta(seconds=15), vote_closing_time=datetime.now() + timedelta(seconds=30),
vote_enactment_time=datetime.now() + timedelta(seconds=60), vote_enactment_time=datetime.now() + timedelta(seconds=60),
approve_proposal=True, approve_proposal=True,
forward_time_to_enactment=False, forward_time_to_enactment=False,
@ -150,9 +158,12 @@ def test_perps_market_terminated(page: Page, vega: VegaServiceNull):
page.goto(f"/#/markets/{perpetual_market}") page.goto(f"/#/markets/{perpetual_market}")
# TODO change back to have text once bug #5465 is fixed # TODO change back to have text once bug #5465 is fixed
expect(page.get_by_test_id("market-price")).to_have_text("Mark Price100.00") expect(page.get_by_test_id("market-price")
expect(page.get_by_test_id("market-change")).to_contain_text("Change (24h)") ).to_have_text("Mark Price100.00")
expect(page.get_by_test_id("market-volume")).to_contain_text("Volume (24h)") expect(page.get_by_test_id("market-change")
).to_contain_text("Change (24h)")
expect(page.get_by_test_id("market-volume")
).to_contain_text("Volume (24h)")
expect(page.get_by_test_id("market-trading-mode")).to_have_text( expect(page.get_by_test_id("market-trading-mode")).to_have_text(
"Trading modeNo trading" "Trading modeNo trading"
) )