chore(trading): Refactor test fixtures (#5913)
This commit is contained in:
parent
8221882346
commit
177e72dd16
@ -339,4 +339,3 @@ def retry_on_http_error(request):
|
||||
print(f"Retrying due to HTTPError (attempt {i+1}/{retry_count})")
|
||||
else:
|
||||
raise
|
||||
|
||||
|
@ -18,7 +18,7 @@ expire = "expire"
|
||||
@pytest.fixture(scope="module")
|
||||
def vega(request):
|
||||
with init_vega(request) as vega_instance:
|
||||
request.addfinalizer(lambda: cleanup_container(vega_instance)) # Register the cleanup function
|
||||
request.addfinalizer(lambda: cleanup_container(vega_instance))
|
||||
yield vega_instance
|
||||
|
||||
|
||||
|
@ -261,7 +261,7 @@ class TestStopOcoValidation:
|
||||
@pytest.fixture(scope="class")
|
||||
def vega(request):
|
||||
with init_vega(request) as vega_instance:
|
||||
request.addfinalizer(lambda: cleanup_container(vega_instance)) # Register the cleanup function
|
||||
request.addfinalizer(lambda: cleanup_container(vega_instance))
|
||||
yield vega_instance
|
||||
|
||||
@pytest.fixture(scope="class")
|
||||
|
@ -1,6 +1,7 @@
|
||||
import pytest
|
||||
from typing import Tuple, Generator
|
||||
from fees_test_ids import *
|
||||
from playwright.sync_api import Page, expect
|
||||
from playwright.sync_api import expect, Page
|
||||
from vega_sim.null_service import VegaServiceNull
|
||||
from actions.vega import submit_order
|
||||
from wallet_config import MM_WALLET
|
||||
@ -16,26 +17,13 @@ from fixtures.market import setup_continuous_market
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def vega(request):
|
||||
def setup_environment(
|
||||
request, browser
|
||||
) -> Generator[Tuple[VegaServiceNull, str, Page], None, None]:
|
||||
with init_vega(request) as vega_instance:
|
||||
request.addfinalizer(
|
||||
lambda: cleanup_container(vega_instance)
|
||||
)
|
||||
yield vega_instance
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def page(vega, browser, request):
|
||||
with init_page(vega, browser, request) as page:
|
||||
risk_accepted_setup(page)
|
||||
auth_setup(vega, page)
|
||||
yield page
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", autouse=True)
|
||||
def setup_combined_market(vega: VegaServiceNull):
|
||||
market = setup_continuous_market(vega, custom_quantum=100000)
|
||||
vega.update_volume_discount_program(
|
||||
request.addfinalizer(lambda: cleanup_container(vega_instance))
|
||||
market = setup_continuous_market(vega_instance, custom_quantum=100000)
|
||||
vega_instance.update_volume_discount_program(
|
||||
proposal_key=MM_WALLET.name,
|
||||
benefit_tiers=[
|
||||
{
|
||||
@ -49,9 +37,9 @@ def setup_combined_market(vega: VegaServiceNull):
|
||||
],
|
||||
window_length=7,
|
||||
)
|
||||
next_epoch(vega=vega)
|
||||
next_epoch(vega_instance)
|
||||
|
||||
vega.update_referral_program(
|
||||
vega_instance.update_referral_program(
|
||||
proposal_key=MM_WALLET.name,
|
||||
benefit_tiers=[
|
||||
{
|
||||
@ -73,20 +61,26 @@ def setup_combined_market(vega: VegaServiceNull):
|
||||
],
|
||||
window_length=1,
|
||||
)
|
||||
vega.create_referral_set(key_name=MM_WALLET.name)
|
||||
next_epoch(vega=vega)
|
||||
referral_set_id = list(vega.list_referral_sets().keys())[0]
|
||||
vega.apply_referral_code(key_name="Key 1", id=referral_set_id)
|
||||
next_epoch(vega=vega)
|
||||
vega_instance.create_referral_set(key_name=MM_WALLET.name)
|
||||
next_epoch(vega_instance)
|
||||
referral_set_id = list(vega_instance.list_referral_sets().keys())[0]
|
||||
vega_instance.apply_referral_code(key_name="Key 1", id=referral_set_id)
|
||||
next_epoch(vega_instance)
|
||||
|
||||
for _ in range(2):
|
||||
submit_order(vega, "Key 1", market, "SIDE_BUY", 2, 110)
|
||||
forward_time(vega, True if _ < 2 - 1 else False)
|
||||
return market
|
||||
submit_order(vega_instance, "Key 1", market, "SIDE_BUY", 2, 110)
|
||||
forward_time(vega_instance, True if _ < 2 - 1 else False)
|
||||
|
||||
with init_page(vega_instance, browser, request) as page_instance:
|
||||
risk_accepted_setup(page_instance)
|
||||
auth_setup(vega_instance, page_instance)
|
||||
yield vega_instance, market, page_instance
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_combo_tier_2")
|
||||
def test_fees_page_discount_program_my_trading_fees(page: Page):
|
||||
def test_fees_page_discount_program_my_trading_fees(
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto("/#/fees")
|
||||
expect(page.get_by_test_id(ADJUSTED_FEES)).to_have_text("6.432%-6.432%")
|
||||
expect(page.get_by_test_id(TOTAL_FEE_BEFORE_DISCOUNT)).to_have_text(
|
||||
@ -97,10 +91,10 @@ def test_fees_page_discount_program_my_trading_fees(page: Page):
|
||||
expect(page.get_by_test_id(LIQUIDITY_FEES)).to_have_text("Liquidity0%-0%")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_combo_tier_2")
|
||||
def test_fees_page_discount_program_total_discount(
|
||||
page: Page,
|
||||
):
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto("/#/fees")
|
||||
expect(page.get_by_test_id(TOTAL_DISCOUNT)).to_have_text("36%")
|
||||
expect(page.get_by_test_id(VOLUME_DISCOUNT_ROW)).to_have_text("Volume discount20%")
|
||||
@ -113,8 +107,10 @@ def test_fees_page_discount_program_total_discount(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_combo_tier_2")
|
||||
def test_fees_page_discount_program_fees_by_market(page: Page):
|
||||
def test_fees_page_discount_program_fees_by_market(
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto("/#/fees")
|
||||
pinned = page.locator(PINNED_ROW_LOCATOR)
|
||||
row = page.locator(ROW_LOCATOR)
|
||||
@ -126,12 +122,11 @@ def test_fees_page_discount_program_fees_by_market(page: Page):
|
||||
expect(row.locator(COL_TOTAL_FEE)).to_have_text("10.05%")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_combo_tier_2")
|
||||
def test_deal_ticket_discount_program(
|
||||
page: Page,
|
||||
setup_combined_market,
|
||||
):
|
||||
page.goto(f"/#/markets/{setup_combined_market}")
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto(f"/#/markets/{market}")
|
||||
page.get_by_test_id(ORDER_SIZE).fill("1")
|
||||
page.get_by_test_id(ORDER_PRICE).fill("1")
|
||||
expect(page.get_by_test_id(DISCOUNT_PILL)).to_have_text("-36%")
|
||||
@ -150,12 +145,9 @@ def test_deal_ticket_discount_program(
|
||||
expect(tooltip.get_by_test_id(TOTAL_FEE_VALUE)).to_have_text("0.06432 tDAI")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_combo_tier_2")
|
||||
def test_fills_taker_discount_program(
|
||||
page: Page,
|
||||
setup_combined_market,
|
||||
):
|
||||
page.goto(f"/#/markets/{setup_combined_market}")
|
||||
def test_fills_taker_discount_program(setup_environment):
|
||||
vega, market, page = setup_environment
|
||||
page.goto(f"/#/markets/{market}")
|
||||
page.get_by_test_id(FILLS).click()
|
||||
row = page.get_by_test_id(TAB_FILLS).locator(ROW_LOCATOR).first
|
||||
expect(row.locator(COL_SIZE)).to_have_text("+2")
|
||||
@ -166,13 +158,11 @@ def test_fills_taker_discount_program(
|
||||
expect(row.locator(COL_FEE_DISCOUNT)).to_have_text("7.48926 tDAI")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_combo_tier_2")
|
||||
def test_fills_maker_discount_program(
|
||||
vega: VegaServiceNull,
|
||||
page: Page,
|
||||
setup_combined_market,
|
||||
):
|
||||
page.goto(f"/#/markets/{setup_combined_market}")
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto(f"/#/markets/{market}")
|
||||
change_keys(page, vega, MM_WALLET.name)
|
||||
page.get_by_test_id(FILLS).click()
|
||||
row = page.get_by_test_id(TAB_FILLS).locator(ROW_LOCATOR).first
|
||||
@ -184,11 +174,11 @@ def test_fills_maker_discount_program(
|
||||
expect(row.locator(COL_FEE_DISCOUNT)).to_have_text("7.452 tDAI")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_combo_tier_2")
|
||||
def test_fills_maker_fee_tooltip_discount_program(
|
||||
vega: VegaServiceNull, page: Page, setup_combined_market
|
||||
):
|
||||
page.goto(f"/#/markets/{setup_combined_market}")
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto(f"/#/markets/{market}")
|
||||
change_keys(page, vega, MM_WALLET.name)
|
||||
page.get_by_test_id(FILLS).click()
|
||||
row = page.get_by_test_id(TAB_FILLS).locator(ROW_LOCATOR).first
|
||||
@ -200,12 +190,11 @@ def test_fills_maker_fee_tooltip_discount_program(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_combo_tier_2")
|
||||
def test_fills_taker_fee_tooltip_discount_program(
|
||||
page: Page,
|
||||
setup_combined_market,
|
||||
):
|
||||
page.goto(f"/#/markets/{setup_combined_market}")
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto(f"/#/markets/{market}")
|
||||
page.get_by_test_id(FILLS).click()
|
||||
row = page.get_by_test_id(TAB_FILLS).locator(ROW_LOCATOR).first
|
||||
# tbd - tooltip is not visible without this wait
|
||||
|
@ -1,4 +1,5 @@
|
||||
import pytest
|
||||
from typing import Tuple, Generator
|
||||
from fees_test_ids import *
|
||||
from playwright.sync_api import Page, expect
|
||||
from vega_sim.null_service import VegaServiceNull
|
||||
@ -14,27 +15,17 @@ from conftest import (
|
||||
from actions.utils import next_epoch, change_keys, forward_time
|
||||
from fixtures.market import setup_continuous_market
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def vega(request):
|
||||
def setup_environment(
|
||||
request, browser
|
||||
) -> Generator[Tuple[VegaServiceNull, str, Page], None, None]:
|
||||
with init_vega(request) as vega_instance:
|
||||
request.addfinalizer(
|
||||
lambda: cleanup_container(vega_instance)
|
||||
)
|
||||
yield vega_instance
|
||||
request.addfinalizer(lambda: cleanup_container(vega_instance))
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def page(vega, browser, request):
|
||||
with init_page(vega, browser, request) as page:
|
||||
risk_accepted_setup(page)
|
||||
auth_setup(vega, page)
|
||||
yield page
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", autouse=True)
|
||||
def setup_market_with_referral_discount_program(vega: VegaServiceNull):
|
||||
market = setup_continuous_market(vega, custom_quantum=100000)
|
||||
vega.update_referral_program(
|
||||
# Setup the market with the referral discount program
|
||||
market = setup_continuous_market(vega_instance, custom_quantum=100000)
|
||||
vega_instance.update_referral_program(
|
||||
proposal_key=MM_WALLET.name,
|
||||
benefit_tiers=[
|
||||
{
|
||||
@ -56,21 +47,26 @@ def setup_market_with_referral_discount_program(vega: VegaServiceNull):
|
||||
],
|
||||
window_length=1,
|
||||
)
|
||||
vega.create_referral_set(key_name=MM_WALLET.name)
|
||||
next_epoch(vega=vega)
|
||||
referral_set_id = list(vega.list_referral_sets().keys())[0]
|
||||
vega.apply_referral_code(key_name="Key 1", id=referral_set_id)
|
||||
next_epoch(vega=vega)
|
||||
vega_instance.create_referral_set(key_name=MM_WALLET.name)
|
||||
next_epoch(vega_instance)
|
||||
referral_set_id = list(vega_instance.list_referral_sets().keys())[0]
|
||||
vega_instance.apply_referral_code(key_name="Key 1", id=referral_set_id)
|
||||
next_epoch(vega_instance)
|
||||
|
||||
for _ in range(2):
|
||||
submit_order(vega, "Key 1", market, "SIDE_BUY", 1, 110)
|
||||
forward_time(vega, True if _ < 2 - 1 else False)
|
||||
submit_order(vega_instance, "Key 1", market, "SIDE_BUY", 1, 110)
|
||||
forward_time(vega_instance, True if _ < 2 - 1 else False)
|
||||
|
||||
return market
|
||||
with init_page(vega_instance, browser, request) as page_instance:
|
||||
risk_accepted_setup(page_instance)
|
||||
auth_setup(vega_instance, page_instance)
|
||||
yield vega_instance, market, page_instance
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_referral_tier_1")
|
||||
def test_fees_page_discount_program_my_trading_fees(page: Page):
|
||||
def test_fees_page_discount_program_my_trading_fees(
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto("/#/fees")
|
||||
expect(page.get_by_test_id(ADJUSTED_FEES)).to_have_text("9.045%-9.045%")
|
||||
expect(page.get_by_test_id(TOTAL_FEE_BEFORE_DISCOUNT)).to_have_text(
|
||||
@ -81,8 +77,10 @@ def test_fees_page_discount_program_my_trading_fees(page: Page):
|
||||
expect(page.get_by_test_id(LIQUIDITY_FEES)).to_have_text("Liquidity0%-0%")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_referral_tier_1")
|
||||
def test_fees_page_discount_program_total_discount(page: Page):
|
||||
def test_fees_page_discount_program_total_discount(
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto("/#/fees")
|
||||
expect(page.get_by_test_id(TOTAL_DISCOUNT)).to_have_text("10%")
|
||||
expect(page.get_by_test_id(VOLUME_DISCOUNT_ROW)).to_have_text("Volume discount0%")
|
||||
@ -95,15 +93,19 @@ def test_fees_page_discount_program_total_discount(page: Page):
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_referral_tier_1")
|
||||
def test_fees_page_referral_discount_program_referral_benefits(page: Page):
|
||||
def test_fees_page_referral_discount_program_referral_benefits(
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto("/#/fees")
|
||||
expect(page.get_by_test_id(RUNNING_NOTIONAL_TAKER_VOLUME)).to_have_text("103")
|
||||
expect(page.get_by_test_id(EPOCHS_IN_REFERRAL_SET)).to_have_text("1")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_referral_tier_1")
|
||||
def test_fees_page_discount_program_discount(page: Page):
|
||||
def test_fees_page_discount_program_discount(
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto("/#/fees")
|
||||
expect(page.get_by_test_id(TIER_VALUE_0)).to_have_text("1")
|
||||
expect(page.get_by_test_id(TIER_VALUE_1)).to_have_text("2")
|
||||
@ -119,8 +121,10 @@ def test_fees_page_discount_program_discount(page: Page):
|
||||
expect(page.get_by_test_id("your-referral-tier-0").nth(1)).to_have_text("Your tier")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_referral_tier_1")
|
||||
def test_fees_page_discount_program_fees_by_market(page: Page):
|
||||
def test_fees_page_discount_program_fees_by_market(
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto("/#/fees")
|
||||
pinned = page.locator(PINNED_ROW_LOCATOR)
|
||||
row = page.locator(ROW_LOCATOR)
|
||||
@ -132,11 +136,11 @@ def test_fees_page_discount_program_fees_by_market(page: Page):
|
||||
expect(row.locator(COL_TOTAL_FEE)).to_have_text("10.05%")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_referral_tier_1")
|
||||
def test_deal_ticket_discount_program(
|
||||
page: Page, setup_market_with_referral_discount_program
|
||||
):
|
||||
page.goto(f"/#/markets/{setup_market_with_referral_discount_program}")
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto(f"/#/markets/{market}")
|
||||
page.get_by_test_id(ORDER_SIZE).fill("1")
|
||||
page.get_by_test_id(ORDER_PRICE).fill("1")
|
||||
expect(page.get_by_test_id(DISCOUNT_PILL)).to_have_text("-10%")
|
||||
@ -155,12 +159,11 @@ def test_deal_ticket_discount_program(
|
||||
expect(tooltip.get_by_test_id(TOTAL_FEE_VALUE)).to_have_text("0.09045 tDAI")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_referral_tier_1")
|
||||
def test_fills_taker_discount_program(
|
||||
page: Page,
|
||||
setup_market_with_referral_discount_program,
|
||||
):
|
||||
page.goto(f"/#/markets/{setup_market_with_referral_discount_program}")
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto(f"/#/markets/{market}")
|
||||
page.get_by_test_id(FILLS).click()
|
||||
row = page.get_by_test_id(TAB_FILLS).locator(ROW_LOCATOR).first
|
||||
expect(row.locator(COL_SIZE)).to_have_text("+1")
|
||||
@ -171,13 +174,11 @@ def test_fills_taker_discount_program(
|
||||
expect(row.locator(COL_FEE_DISCOUNT)).to_have_text("1.04017 tDAI")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_referral_tier_1")
|
||||
def test_fills_maker_discount_program(
|
||||
vega: VegaServiceNull,
|
||||
page: Page,
|
||||
setup_market_with_referral_discount_program,
|
||||
):
|
||||
page.goto(f"/#/markets/{setup_market_with_referral_discount_program}")
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto(f"/#/markets/{market}")
|
||||
change_keys(page, vega, MM_WALLET.name)
|
||||
page.get_by_test_id(FILLS).click()
|
||||
row = page.get_by_test_id(TAB_FILLS).locator(ROW_LOCATOR).first
|
||||
@ -189,11 +190,11 @@ def test_fills_maker_discount_program(
|
||||
expect(row.locator(COL_FEE_DISCOUNT)).to_have_text("1.035 tDAI")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_referral_tier_1")
|
||||
def test_fills_maker_fee_tooltip_discount_program(
|
||||
vega: VegaServiceNull, page: Page, setup_market_with_referral_discount_program
|
||||
):
|
||||
page.goto(f"/#/markets/{setup_market_with_referral_discount_program}")
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto(f"/#/markets/{market}")
|
||||
change_keys(page, vega, MM_WALLET.name)
|
||||
page.get_by_test_id(FILLS).click()
|
||||
row = page.get_by_test_id(TAB_FILLS).locator(ROW_LOCATOR).first
|
||||
@ -205,12 +206,11 @@ def test_fills_maker_fee_tooltip_discount_program(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_referral_tier_1")
|
||||
def test_fills_taker_fee_tooltip_discount_program(
|
||||
page: Page,
|
||||
setup_market_with_referral_discount_program,
|
||||
):
|
||||
page.goto(f"/#/markets/{setup_market_with_referral_discount_program}")
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto(f"/#/markets/{market}")
|
||||
page.get_by_test_id(FILLS).click()
|
||||
row = page.get_by_test_id(TAB_FILLS).locator(ROW_LOCATOR).first
|
||||
# tbd - tooltip is not visible without this wait
|
||||
|
@ -1,5 +1,6 @@
|
||||
import pytest
|
||||
from fees_test_ids import *
|
||||
from typing import Tuple, Generator
|
||||
from playwright.sync_api import Page, expect
|
||||
from vega_sim.null_service import VegaServiceNull
|
||||
from actions.vega import submit_order
|
||||
@ -16,26 +17,15 @@ from fixtures.market import setup_continuous_market
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def vega(request):
|
||||
def setup_environment(
|
||||
request, browser
|
||||
) -> Generator[Tuple[VegaServiceNull, str, Page], None, None]:
|
||||
with init_vega(request) as vega_instance:
|
||||
request.addfinalizer(
|
||||
lambda: cleanup_container(vega_instance)
|
||||
)
|
||||
yield vega_instance
|
||||
request.addfinalizer(lambda: cleanup_container(vega_instance))
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def page(vega, browser, request):
|
||||
with init_page(vega, browser, request) as page:
|
||||
risk_accepted_setup(page)
|
||||
auth_setup(vega, page)
|
||||
yield page
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", autouse=True)
|
||||
def setup_market_with_referral_discount_program(vega: VegaServiceNull):
|
||||
market = setup_continuous_market(vega, custom_quantum=100000)
|
||||
vega.update_referral_program(
|
||||
# Setup market with referral discount program
|
||||
market = setup_continuous_market(vega_instance, custom_quantum=100000)
|
||||
vega_instance.update_referral_program(
|
||||
proposal_key=MM_WALLET.name,
|
||||
benefit_tiers=[
|
||||
{
|
||||
@ -57,21 +47,26 @@ def setup_market_with_referral_discount_program(vega: VegaServiceNull):
|
||||
],
|
||||
window_length=1,
|
||||
)
|
||||
vega.create_referral_set(key_name=MM_WALLET.name)
|
||||
next_epoch(vega=vega)
|
||||
referral_set_id = list(vega.list_referral_sets().keys())[0]
|
||||
vega.apply_referral_code(key_name="Key 1", id=referral_set_id)
|
||||
next_epoch(vega=vega)
|
||||
vega_instance.create_referral_set(key_name=MM_WALLET.name)
|
||||
next_epoch(vega_instance)
|
||||
referral_set_id = list(vega_instance.list_referral_sets().keys())[0]
|
||||
vega_instance.apply_referral_code(key_name="Key 1", id=referral_set_id)
|
||||
next_epoch(vega_instance)
|
||||
|
||||
for _ in range(2):
|
||||
submit_order(vega, "Key 1", market, "SIDE_BUY", 2, 110)
|
||||
forward_time(vega, True if _ < 2 - 1 else False)
|
||||
submit_order(vega_instance, "Key 1", market, "SIDE_BUY", 2, 110)
|
||||
forward_time(vega_instance, True if _ < 2 - 1 else False)
|
||||
|
||||
return market
|
||||
with init_page(vega_instance, browser, request) as page_instance:
|
||||
risk_accepted_setup(page_instance)
|
||||
auth_setup(vega_instance, page_instance)
|
||||
yield vega_instance, market, page_instance
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_referral_tier_2")
|
||||
def test_fees_page_discount_program_my_trading_fees(page: Page):
|
||||
def test_fees_page_discount_program_my_trading_fees(
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto("/#/fees")
|
||||
expect(page.get_by_test_id(ADJUSTED_FEES)).to_have_text("8.04%-8.04%")
|
||||
expect(page.get_by_test_id(TOTAL_FEE_BEFORE_DISCOUNT)).to_have_text(
|
||||
@ -82,8 +77,10 @@ def test_fees_page_discount_program_my_trading_fees(page: Page):
|
||||
expect(page.get_by_test_id(LIQUIDITY_FEES)).to_have_text("Liquidity0%-0%")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_referral_tier_2")
|
||||
def test_fees_page_discount_program_total_discount(page: Page):
|
||||
def test_fees_page_discount_program_total_discount(
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto("/#/fees")
|
||||
expect(page.get_by_test_id(TOTAL_DISCOUNT)).to_have_text("20%")
|
||||
expect(page.get_by_test_id(VOLUME_DISCOUNT_ROW)).to_have_text("Volume discount0%")
|
||||
@ -96,15 +93,19 @@ def test_fees_page_discount_program_total_discount(page: Page):
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_referral_tier_2")
|
||||
def test_fees_page_referral_discount_program_referral_benefits(page: Page):
|
||||
def test_fees_page_referral_discount_program_referral_benefits(
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto("/#/fees")
|
||||
expect(page.get_by_test_id(RUNNING_NOTIONAL_TAKER_VOLUME)).to_have_text("207")
|
||||
expect(page.get_by_test_id(REQUIRED_FOR_NEXT_TIER)).not_to_be_visible()
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_referral_tier_2")
|
||||
def test_fees_page_discount_program_discount(page: Page):
|
||||
def test_fees_page_discount_program_discount(
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto("/#/fees")
|
||||
expect(page.get_by_test_id(TIER_VALUE_0)).to_have_text("1")
|
||||
expect(page.get_by_test_id(TIER_VALUE_1)).to_have_text("2")
|
||||
@ -120,8 +121,10 @@ def test_fees_page_discount_program_discount(page: Page):
|
||||
expect(page.get_by_test_id("your-referral-tier-1").nth(1)).to_have_text("Your tier")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_referral_tier_2")
|
||||
def test_fees_page_discount_program_fees_by_market(page: Page):
|
||||
def test_fees_page_discount_program_fees_by_market(
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto("/#/fees")
|
||||
pinned = page.locator(PINNED_ROW_LOCATOR)
|
||||
row = page.locator(ROW_LOCATOR)
|
||||
@ -133,11 +136,11 @@ def test_fees_page_discount_program_fees_by_market(page: Page):
|
||||
expect(row.locator(COL_TOTAL_FEE)).to_have_text("10.05%")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_referral_tier_2")
|
||||
def test_deal_ticket_discount_program(
|
||||
page: Page, setup_market_with_referral_discount_program
|
||||
):
|
||||
page.goto(f"/#/markets/{setup_market_with_referral_discount_program}")
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto(f"/#/markets/{market}")
|
||||
page.get_by_test_id(ORDER_SIZE).fill("1")
|
||||
page.get_by_test_id(ORDER_PRICE).fill("1")
|
||||
expect(page.get_by_test_id(DISCOUNT_PILL)).to_have_text("-20%")
|
||||
@ -156,12 +159,11 @@ def test_deal_ticket_discount_program(
|
||||
expect(tooltip.get_by_test_id(TOTAL_FEE_VALUE)).to_have_text("0.0804 tDAI")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_referral_tier_2")
|
||||
def test_fills_taker_discount_program(
|
||||
page: Page,
|
||||
setup_market_with_referral_discount_program,
|
||||
):
|
||||
page.goto(f"/#/markets/{setup_market_with_referral_discount_program}")
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto(f"/#/markets/{market}")
|
||||
page.get_by_test_id(FILLS).click()
|
||||
row = page.get_by_test_id(TAB_FILLS).locator(ROW_LOCATOR).first
|
||||
expect(row.locator(COL_SIZE)).to_have_text("+2")
|
||||
@ -172,13 +174,11 @@ def test_fills_taker_discount_program(
|
||||
expect(row.locator(COL_FEE_DISCOUNT)).to_have_text("4.1607 tDAI")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_referral_tier_2")
|
||||
def test_fills_maker_discount_program(
|
||||
vega: VegaServiceNull,
|
||||
page: Page,
|
||||
setup_market_with_referral_discount_program,
|
||||
):
|
||||
page.goto(f"/#/markets/{setup_market_with_referral_discount_program}")
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto(f"/#/markets/{market}")
|
||||
change_keys(page, vega, MM_WALLET.name)
|
||||
page.get_by_test_id(FILLS).click()
|
||||
row = page.get_by_test_id(TAB_FILLS).locator(ROW_LOCATOR).first
|
||||
@ -190,11 +190,11 @@ def test_fills_maker_discount_program(
|
||||
expect(row.locator(COL_FEE_DISCOUNT)).to_have_text("4.14 tDAI")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_referral_tier_2")
|
||||
def test_fills_maker_fee_tooltip_discount_program(
|
||||
vega: VegaServiceNull, page: Page, setup_market_with_referral_discount_program
|
||||
):
|
||||
page.goto(f"/#/markets/{setup_market_with_referral_discount_program}")
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto(f"/#/markets/{market}")
|
||||
change_keys(page, vega, MM_WALLET.name)
|
||||
page.get_by_test_id(FILLS).click()
|
||||
row = page.get_by_test_id(TAB_FILLS).locator(ROW_LOCATOR).first
|
||||
@ -206,12 +206,11 @@ def test_fills_maker_fee_tooltip_discount_program(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_referral_tier_2")
|
||||
def test_fills_taker_fee_tooltip_discount_program(
|
||||
page: Page,
|
||||
setup_market_with_referral_discount_program,
|
||||
):
|
||||
page.goto(f"/#/markets/{setup_market_with_referral_discount_program}")
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto(f"/#/markets/{market}")
|
||||
page.get_by_test_id(FILLS).click()
|
||||
row = page.get_by_test_id(TAB_FILLS).locator(ROW_LOCATOR).first
|
||||
# tbd - tooltip is not visible without this wait
|
||||
|
@ -1,5 +1,6 @@
|
||||
import pytest
|
||||
from fees_test_ids import *
|
||||
from typing import Tuple, Generator
|
||||
from playwright.sync_api import Page, expect
|
||||
from vega_sim.null_service import VegaServiceNull
|
||||
from actions.vega import submit_order
|
||||
@ -16,26 +17,15 @@ from fixtures.market import setup_continuous_market
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def vega(request):
|
||||
def setup_environment(
|
||||
request, browser
|
||||
) -> Generator[Tuple[VegaServiceNull, str, Page], None, None]:
|
||||
with init_vega(request) as vega_instance:
|
||||
request.addfinalizer(
|
||||
lambda: cleanup_container(vega_instance)
|
||||
)
|
||||
yield vega_instance
|
||||
request.addfinalizer(lambda: cleanup_container(vega_instance))
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def page(vega, browser, request):
|
||||
with init_page(vega, browser, request) as page:
|
||||
risk_accepted_setup(page)
|
||||
auth_setup(vega, page)
|
||||
yield page
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", autouse=True)
|
||||
def setup_market_with_volume_discount_program(vega: VegaServiceNull):
|
||||
market = setup_continuous_market(vega, custom_quantum=100000)
|
||||
vega.update_volume_discount_program(
|
||||
# Setup the market with volume discount program
|
||||
market = setup_continuous_market(vega_instance, custom_quantum=100000)
|
||||
vega_instance.update_volume_discount_program(
|
||||
proposal_key=MM_WALLET.name,
|
||||
benefit_tiers=[
|
||||
{
|
||||
@ -49,16 +39,23 @@ def setup_market_with_volume_discount_program(vega: VegaServiceNull):
|
||||
],
|
||||
window_length=7,
|
||||
)
|
||||
next_epoch(vega=vega)
|
||||
next_epoch(vega=vega_instance)
|
||||
|
||||
for _ in range(2):
|
||||
submit_order(vega, "Key 1", market, "SIDE_BUY", 1, 110)
|
||||
forward_time(vega, True if _ < 2 - 1 else False)
|
||||
return market
|
||||
submit_order(vega_instance, "Key 1", market, "SIDE_BUY", 1, 110)
|
||||
forward_time(vega_instance, True if _ < 2 - 1 else False)
|
||||
|
||||
# Initialize and setup page
|
||||
with init_page(vega_instance, browser, request) as page:
|
||||
risk_accepted_setup(page)
|
||||
auth_setup(vega_instance, page)
|
||||
yield vega_instance, market, page
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_volume_tier_1")
|
||||
def test_fees_page_discount_program_my_trading_fees(page: Page):
|
||||
def test_fees_page_discount_program_my_trading_fees(
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto("/#/fees")
|
||||
expect(page.get_by_test_id(ADJUSTED_FEES)).to_have_text("9.045%-9.045%")
|
||||
expect(page.get_by_test_id(TOTAL_FEE_BEFORE_DISCOUNT)).to_have_text(
|
||||
@ -69,10 +66,10 @@ def test_fees_page_discount_program_my_trading_fees(page: Page):
|
||||
expect(page.get_by_test_id(LIQUIDITY_FEES)).to_have_text("Liquidity0%-0%")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_volume_tier_1")
|
||||
def test_fees_page_discount_program_total_discount(
|
||||
page: Page,
|
||||
):
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto("/#/fees")
|
||||
expect(page.get_by_test_id(TOTAL_DISCOUNT)).to_have_text("10%")
|
||||
expect(page.get_by_test_id(VOLUME_DISCOUNT_ROW)).to_have_text("Volume discount10%")
|
||||
@ -85,20 +82,20 @@ def test_fees_page_discount_program_total_discount(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_volume_tier_1")
|
||||
def test_fees_page_volume_discount_program_my_current_volume(
|
||||
page: Page,
|
||||
):
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto("/#/fees")
|
||||
expect(page.get_by_test_id(PAST_EPOCHS_VOLUME)).to_have_text("103")
|
||||
|
||||
expect(page.get_by_test_id(REQUIRED_FOR_NEXT_TIER)).to_have_text("97")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_volume_tier_1")
|
||||
def test_fees_page_discount_program_discount(
|
||||
page: Page,
|
||||
):
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto("/#/fees")
|
||||
expect(page.get_by_test_id(TIER_VALUE_0)).to_have_text("1")
|
||||
expect(page.get_by_test_id(TIER_VALUE_1)).to_have_text("2")
|
||||
@ -111,8 +108,10 @@ def test_fees_page_discount_program_discount(
|
||||
expect(page.get_by_test_id("your-volume-tier-0").nth(1)).to_have_text("Your tier")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_volume_tier_1")
|
||||
def test_fees_page_discount_program_fees_by_market(page: Page):
|
||||
def test_fees_page_discount_program_fees_by_market(
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto("/#/fees")
|
||||
pinned = page.locator(PINNED_ROW_LOCATOR)
|
||||
row = page.locator(ROW_LOCATOR)
|
||||
@ -124,11 +123,11 @@ def test_fees_page_discount_program_fees_by_market(page: Page):
|
||||
expect(row.locator(COL_TOTAL_FEE)).to_have_text("10.05%")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_volume_tier_1")
|
||||
def test_deal_ticket_discount_program_testing(
|
||||
page: Page, setup_market_with_volume_discount_program
|
||||
):
|
||||
page.goto(f"/#/markets/{setup_market_with_volume_discount_program}")
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto(f"/#/markets/{market}")
|
||||
page.get_by_test_id(ORDER_SIZE).fill("1")
|
||||
page.get_by_test_id(ORDER_PRICE).fill("1")
|
||||
expect(page.get_by_test_id(DISCOUNT_PILL)).to_have_text("-10%")
|
||||
@ -149,9 +148,10 @@ def test_deal_ticket_discount_program_testing(
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_volume_tier_1")
|
||||
def test_fills_taker_discount_program(
|
||||
page: Page, setup_market_with_volume_discount_program
|
||||
):
|
||||
page.goto(f"/#/markets/{setup_market_with_volume_discount_program}")
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto(f"/#/markets/{market}")
|
||||
page.get_by_test_id(FILLS).click()
|
||||
row = page.get_by_test_id(TAB_FILLS).locator(ROW_LOCATOR).first
|
||||
expect(row.locator(COL_SIZE)).to_have_text("+1")
|
||||
@ -164,9 +164,10 @@ def test_fills_taker_discount_program(
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_volume_tier_1")
|
||||
def test_fills_maker_discount_program(
|
||||
page: Page, setup_market_with_volume_discount_program, vega: VegaServiceNull
|
||||
):
|
||||
page.goto(f"/#/markets/{setup_market_with_volume_discount_program}")
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto(f"/#/markets/{market}")
|
||||
change_keys(page, vega, MM_WALLET.name)
|
||||
page.get_by_test_id(FILLS).click()
|
||||
row = page.get_by_test_id(TAB_FILLS).locator(ROW_LOCATOR).first
|
||||
@ -178,11 +179,11 @@ def test_fills_maker_discount_program(
|
||||
expect(row.locator(COL_FEE_DISCOUNT)).to_have_text("1.035 tDAI")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_volume_tier_1")
|
||||
def test_fills_maker_fee_tooltip_discount_program(
|
||||
vega: VegaServiceNull, page: Page, setup_market_with_volume_discount_program
|
||||
):
|
||||
page.goto(f"/#/markets/{setup_market_with_volume_discount_program}")
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto(f"/#/markets/{market}")
|
||||
change_keys(page, vega, MM_WALLET.name)
|
||||
page.get_by_test_id(FILLS).click()
|
||||
row = page.get_by_test_id(TAB_FILLS).locator(ROW_LOCATOR).first
|
||||
@ -194,12 +195,11 @@ def test_fills_maker_fee_tooltip_discount_program(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_volume_tier_1")
|
||||
def test_fills_taker_fee_tooltip_discount_program(
|
||||
page: Page,
|
||||
setup_market_with_volume_discount_program,
|
||||
):
|
||||
page.goto(f"/#/markets/{setup_market_with_volume_discount_program}")
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto(f"/#/markets/{market}")
|
||||
page.get_by_test_id(FILLS).click()
|
||||
row = page.get_by_test_id(TAB_FILLS).locator(ROW_LOCATOR).first
|
||||
# tbd - tooltip is not visible without this wait
|
||||
|
@ -1,5 +1,6 @@
|
||||
import pytest
|
||||
from fees_test_ids import *
|
||||
from typing import Tuple, Generator
|
||||
from playwright.sync_api import Page, expect
|
||||
from vega_sim.null_service import VegaServiceNull
|
||||
from actions.vega import submit_order
|
||||
@ -14,27 +15,17 @@ from conftest import (
|
||||
from actions.utils import next_epoch, change_keys, forward_time
|
||||
from fixtures.market import setup_continuous_market
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def vega(request):
|
||||
def setup_environment(
|
||||
request, browser
|
||||
) -> Generator[Tuple[VegaServiceNull, str, Page], None, None]:
|
||||
with init_vega(request) as vega_instance:
|
||||
request.addfinalizer(
|
||||
lambda: cleanup_container(vega_instance)
|
||||
)
|
||||
yield vega_instance
|
||||
request.addfinalizer(lambda: cleanup_container(vega_instance))
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def page(vega, browser, request):
|
||||
with init_page(vega, browser, request) as page:
|
||||
risk_accepted_setup(page)
|
||||
auth_setup(vega, page)
|
||||
yield page
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", autouse=True)
|
||||
def setup_market_with_volume_discount_program(vega: VegaServiceNull):
|
||||
market = setup_continuous_market(vega, custom_quantum=100000)
|
||||
vega.update_volume_discount_program(
|
||||
# Setup the market with volume discount program
|
||||
market = setup_continuous_market(vega_instance, custom_quantum=100000)
|
||||
vega_instance.update_volume_discount_program(
|
||||
proposal_key=MM_WALLET.name,
|
||||
benefit_tiers=[
|
||||
{
|
||||
@ -48,17 +39,23 @@ def setup_market_with_volume_discount_program(vega: VegaServiceNull):
|
||||
],
|
||||
window_length=7,
|
||||
)
|
||||
next_epoch(vega=vega)
|
||||
next_epoch(vega=vega_instance)
|
||||
|
||||
for _ in range(3):
|
||||
submit_order(vega, "Key 1", market, "SIDE_BUY", 1, 110)
|
||||
forward_time(vega, True if _ < 3 - 1 else False)
|
||||
submit_order(vega_instance, "Key 1", market, "SIDE_BUY", 1, 110)
|
||||
forward_time(vega_instance, True if _ < 3 - 1 else False)
|
||||
|
||||
return market
|
||||
# Initialize page and apply setups
|
||||
with init_page(vega_instance, browser, request) as page_instance:
|
||||
risk_accepted_setup(page_instance)
|
||||
auth_setup(vega_instance, page_instance)
|
||||
yield vega_instance, market, page_instance
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_volume_tier_2")
|
||||
def test_fees_page_discount_program_my_trading_fees(page: Page):
|
||||
def test_fees_page_discount_program_my_trading_fees(
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto("/#/fees")
|
||||
expect(page.get_by_test_id(ADJUSTED_FEES)).to_have_text("8.04%-8.04%")
|
||||
expect(page.get_by_test_id(TOTAL_FEE_BEFORE_DISCOUNT)).to_have_text(
|
||||
@ -69,8 +66,10 @@ def test_fees_page_discount_program_my_trading_fees(page: Page):
|
||||
expect(page.get_by_test_id(LIQUIDITY_FEES)).to_have_text("Liquidity0%-0%")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_volume_tier_2")
|
||||
def test_fees_page_discount_program_total_discount(page: Page):
|
||||
def test_fees_page_discount_program_total_discount(
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto("/#/fees")
|
||||
expect(page.get_by_test_id(TOTAL_DISCOUNT)).to_have_text("20%")
|
||||
expect(page.get_by_test_id(VOLUME_DISCOUNT_ROW)).to_have_text("Volume discount20%")
|
||||
@ -83,15 +82,19 @@ def test_fees_page_discount_program_total_discount(page: Page):
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_volume_tier_2")
|
||||
def test_fees_page_volume_discount_program_my_current_volume(page: Page):
|
||||
def test_fees_page_volume_discount_program_my_current_volume(
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto("/#/fees")
|
||||
expect(page.get_by_test_id(PAST_EPOCHS_VOLUME)).to_have_text("206")
|
||||
expect(page.get_by_test_id(REQUIRED_FOR_NEXT_TIER)).not_to_be_visible()
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_volume_tier_2")
|
||||
def test_fees_page_discount_program_discount(page: Page):
|
||||
def test_fees_page_discount_program_discount(
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto("/#/fees")
|
||||
expect(page.get_by_test_id(TIER_VALUE_0)).to_have_text("1")
|
||||
expect(page.get_by_test_id(TIER_VALUE_1)).to_have_text("2")
|
||||
@ -104,8 +107,8 @@ def test_fees_page_discount_program_discount(page: Page):
|
||||
expect(page.get_by_test_id("your-volume-tier-1").nth(1)).to_have_text("Your tier")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_volume_tier_2")
|
||||
def test_fees_page_discount_program_fees_by_market(page: Page):
|
||||
def test_fees_page_discount_program_fees_by_market(setup_environment):
|
||||
vega, market, page = setup_environment
|
||||
page.goto("/#/fees")
|
||||
pinned = page.locator(PINNED_ROW_LOCATOR)
|
||||
row = page.locator(ROW_LOCATOR)
|
||||
@ -117,12 +120,11 @@ def test_fees_page_discount_program_fees_by_market(page: Page):
|
||||
expect(row.locator(COL_TOTAL_FEE)).to_have_text("10.05%")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_volume_tier_2")
|
||||
def test_deal_ticket_discount_program(
|
||||
page: Page,
|
||||
setup_market_with_volume_discount_program,
|
||||
):
|
||||
page.goto(f"/#/markets/{setup_market_with_volume_discount_program}")
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto(f"/#/markets/{market}")
|
||||
page.get_by_test_id(ORDER_SIZE).fill("1")
|
||||
page.get_by_test_id(ORDER_PRICE).fill("1")
|
||||
expect(page.get_by_test_id(DISCOUNT_PILL)).to_have_text("-20%")
|
||||
@ -141,12 +143,11 @@ def test_deal_ticket_discount_program(
|
||||
expect(tooltip.get_by_test_id(TOTAL_FEE_VALUE)).to_have_text("0.0804 tDAI")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_volume_tier_2")
|
||||
def test_fills_taker_discount_program(
|
||||
page: Page,
|
||||
setup_market_with_volume_discount_program,
|
||||
):
|
||||
page.goto(f"/#/markets/{setup_market_with_volume_discount_program}")
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto(f"/#/markets/{market}")
|
||||
page.get_by_test_id(FILLS).click()
|
||||
row = page.get_by_test_id(TAB_FILLS).locator(ROW_LOCATOR).first
|
||||
expect(row.locator(COL_SIZE)).to_have_text("+1")
|
||||
@ -159,13 +160,11 @@ def test_fills_taker_discount_program(
|
||||
expect(row.locator(COL_FEE_DISCOUNT)).to_have_text("2.08035 tDAI")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_volume_tier_2")
|
||||
def test_fills_maker_discount_program(
|
||||
vega: VegaServiceNull,
|
||||
page: Page,
|
||||
setup_market_with_volume_discount_program,
|
||||
):
|
||||
page.goto(f"/#/markets/{setup_market_with_volume_discount_program}")
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto(f"/#/markets/{market}")
|
||||
change_keys(page, vega, MM_WALLET.name)
|
||||
page.get_by_test_id(FILLS).click()
|
||||
row = page.get_by_test_id(TAB_FILLS).locator(ROW_LOCATOR).first
|
||||
@ -177,11 +176,11 @@ def test_fills_maker_discount_program(
|
||||
expect(row.locator(COL_FEE_DISCOUNT)).to_have_text("2.07 tDAI")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_volume_tier_2")
|
||||
def test_fills_maker_fee_tooltip_discount_program(
|
||||
vega, page: Page, setup_market_with_volume_discount_program
|
||||
):
|
||||
page.goto(f"/#/markets/{setup_market_with_volume_discount_program}")
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto(f"/#/markets/{market}")
|
||||
change_keys(page, vega, MM_WALLET.name)
|
||||
page.get_by_test_id(FILLS).click()
|
||||
row = page.get_by_test_id(TAB_FILLS).locator(ROW_LOCATOR).first
|
||||
@ -193,12 +192,11 @@ def test_fills_maker_fee_tooltip_discount_program(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_fees_volume_tier_2")
|
||||
def test_fills_taker_fee_tooltip_discount_program(
|
||||
page: Page,
|
||||
setup_market_with_volume_discount_program,
|
||||
):
|
||||
page.goto(f"/#/markets/{setup_market_with_volume_discount_program}")
|
||||
setup_environment: Tuple[VegaServiceNull, str, Page],
|
||||
) -> None:
|
||||
vega, market, page = setup_environment
|
||||
page.goto(f"/#/markets/{market}")
|
||||
page.get_by_test_id(FILLS).click()
|
||||
row = page.get_by_test_id(TAB_FILLS).locator(ROW_LOCATOR).first
|
||||
# tbd - tooltip is not visible without this wait
|
||||
|
@ -10,38 +10,25 @@ order_tab = "tab-orders"
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def vega(request):
|
||||
def setup_environment(request, browser):
|
||||
# Initialize Vega with cleanup
|
||||
with init_vega(request) as vega_instance:
|
||||
request.addfinalizer(lambda: cleanup_container(vega_instance)) # Register the cleanup function
|
||||
yield vega_instance
|
||||
request.addfinalizer(lambda: cleanup_container(vega_instance))
|
||||
|
||||
# Setup multiple markets
|
||||
markets = {
|
||||
"market_1": setup_continuous_market(vega_instance, custom_market_name="market-1"),
|
||||
"market_2": setup_continuous_market(vega_instance, custom_market_name="market-2"),
|
||||
"market_3": setup_continuous_market(vega_instance, custom_market_name="market-3"),
|
||||
"market_4": setup_continuous_market(vega_instance, custom_market_name="market-4"),
|
||||
"market_5": setup_simple_market(vega_instance, custom_market_name="market-5"),
|
||||
}
|
||||
|
||||
@pytest.fixture(scope="module", autouse=True)
|
||||
def markets(vega: VegaServiceNull):
|
||||
market_1 = setup_continuous_market(
|
||||
vega,
|
||||
custom_market_name="market-1",
|
||||
)
|
||||
market_2 = setup_continuous_market(
|
||||
vega,
|
||||
custom_market_name="market-2",
|
||||
)
|
||||
market_3 = setup_continuous_market(
|
||||
vega,
|
||||
custom_market_name="market-3",
|
||||
)
|
||||
market_4 = setup_continuous_market(
|
||||
vega,
|
||||
custom_market_name="market-4",
|
||||
)
|
||||
market_5 = setup_simple_market(
|
||||
vega,
|
||||
custom_market_name="market-5",
|
||||
)
|
||||
|
||||
vega.submit_order(
|
||||
# Execute a series of orders across different markets
|
||||
# Example for market_1 orders, adjust as necessary for your test scenario
|
||||
vega_instance.submit_order(
|
||||
trading_key="Key 1",
|
||||
market_id=market_1,
|
||||
market_id=markets["market_1"],
|
||||
time_in_force="TIME_IN_FORCE_IOC",
|
||||
order_type="TYPE_LIMIT",
|
||||
side="SIDE_SELL",
|
||||
@ -49,13 +36,13 @@ def markets(vega: VegaServiceNull):
|
||||
price=130,
|
||||
)
|
||||
|
||||
vega.forward("2s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
vega_instance.forward("2s")
|
||||
vega_instance.wait_fn(1)
|
||||
vega_instance.wait_for_total_catchup()
|
||||
|
||||
vega.submit_order(
|
||||
vega_instance.submit_order(
|
||||
trading_key="Key 1",
|
||||
market_id=market_1,
|
||||
market_id=markets["market_1"],
|
||||
time_in_force="TIME_IN_FORCE_GTC",
|
||||
order_type="TYPE_LIMIT",
|
||||
side="SIDE_SELL",
|
||||
@ -63,13 +50,13 @@ def markets(vega: VegaServiceNull):
|
||||
price=88,
|
||||
)
|
||||
|
||||
vega.forward("2s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
vega_instance.forward("2s")
|
||||
vega_instance.wait_fn(1)
|
||||
vega_instance.wait_for_total_catchup()
|
||||
|
||||
vega.submit_order(
|
||||
vega_instance.submit_order(
|
||||
trading_key="Key 1",
|
||||
market_id=market_1,
|
||||
market_id=markets["market_1"],
|
||||
time_in_force="TIME_IN_FORCE_IOC",
|
||||
order_type="TYPE_LIMIT",
|
||||
side="SIDE_SELL",
|
||||
@ -77,13 +64,13 @@ def markets(vega: VegaServiceNull):
|
||||
price=88,
|
||||
)
|
||||
|
||||
vega.forward("2s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
vega_instance.forward("2s")
|
||||
vega_instance.wait_fn(1)
|
||||
vega_instance.wait_for_total_catchup()
|
||||
|
||||
vega.submit_order(
|
||||
vega_instance.submit_order(
|
||||
trading_key="Key 1",
|
||||
market_id=market_1,
|
||||
market_id=markets["market_1"],
|
||||
time_in_force="TIME_IN_FORCE_GTC",
|
||||
order_type="TYPE_LIMIT",
|
||||
side="SIDE_SELL",
|
||||
@ -92,40 +79,40 @@ def markets(vega: VegaServiceNull):
|
||||
wait=False,
|
||||
)
|
||||
|
||||
vega.forward("2s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
vega_instance.forward("2s")
|
||||
vega_instance.wait_fn(1)
|
||||
vega_instance.wait_for_total_catchup()
|
||||
|
||||
vega.submit_order(
|
||||
vega_instance.submit_order(
|
||||
trading_key="Key 1",
|
||||
market_id=market_2,
|
||||
market_id=markets["market_2"],
|
||||
time_in_force="TIME_IN_FORCE_IOC",
|
||||
order_type="TYPE_LIMIT",
|
||||
side="SIDE_BUY",
|
||||
volume=100,
|
||||
price=104,
|
||||
)
|
||||
vega.forward("2s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
vega_instance.forward("2s")
|
||||
vega_instance.wait_fn(1)
|
||||
vega_instance.wait_for_total_catchup()
|
||||
|
||||
vega.submit_order(
|
||||
vega_instance.submit_order(
|
||||
trading_key="Key 1",
|
||||
market_id=market_3,
|
||||
market_id=markets["market_3"],
|
||||
time_in_force="TIME_IN_FORCE_GTT",
|
||||
order_type="TYPE_LIMIT",
|
||||
side="SIDE_SELL",
|
||||
volume=10,
|
||||
price=120,
|
||||
expires_at=vega.get_blockchain_time() + 5 * 1e9,
|
||||
expires_at=vega_instance.get_blockchain_time() + 5 * 1e9,
|
||||
)
|
||||
|
||||
vega.forward("2s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
vega_instance.forward("2s")
|
||||
vega_instance.wait_fn(1)
|
||||
vega_instance.wait_for_total_catchup()
|
||||
|
||||
vega.submit_order(
|
||||
market_id=market_4,
|
||||
vega_instance.submit_order(
|
||||
market_id=markets["market_4"],
|
||||
trading_key="Key 1",
|
||||
side="SIDE_BUY",
|
||||
order_type="TYPE_LIMIT",
|
||||
@ -134,12 +121,12 @@ def markets(vega: VegaServiceNull):
|
||||
volume=20,
|
||||
)
|
||||
|
||||
vega.forward("2s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
vega_instance.forward("2s")
|
||||
vega_instance.wait_fn(1)
|
||||
vega_instance.wait_for_total_catchup()
|
||||
|
||||
vega.submit_order(
|
||||
market_id=market_4,
|
||||
vega_instance.submit_order(
|
||||
market_id=markets["market_4"],
|
||||
trading_key="Key 1",
|
||||
side="SIDE_BUY",
|
||||
order_type="TYPE_LIMIT",
|
||||
@ -148,12 +135,12 @@ def markets(vega: VegaServiceNull):
|
||||
volume=40,
|
||||
)
|
||||
|
||||
vega.forward("2s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
vega_instance.forward("2s")
|
||||
vega_instance.wait_fn(1)
|
||||
vega_instance.wait_for_total_catchup()
|
||||
|
||||
vega.submit_order(
|
||||
market_id=market_4,
|
||||
vega_instance.submit_order(
|
||||
market_id=markets["market_4"],
|
||||
trading_key="Key 1",
|
||||
side="SIDE_SELL",
|
||||
order_type="TYPE_LIMIT",
|
||||
@ -162,12 +149,12 @@ def markets(vega: VegaServiceNull):
|
||||
volume=60,
|
||||
)
|
||||
|
||||
vega.forward("2s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
vega_instance.forward("2s")
|
||||
vega_instance.wait_fn(1)
|
||||
vega_instance.wait_for_total_catchup()
|
||||
|
||||
vega.submit_order(
|
||||
market_id=market_5,
|
||||
vega_instance.submit_order(
|
||||
market_id=markets["market_5"],
|
||||
trading_key="Key 1",
|
||||
side="SIDE_SELL",
|
||||
order_type="TYPE_LIMIT",
|
||||
@ -177,13 +164,13 @@ def markets(vega: VegaServiceNull):
|
||||
volume=60,
|
||||
)
|
||||
|
||||
vega.forward("2s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
vega_instance.forward("2s")
|
||||
vega_instance.wait_fn(1)
|
||||
vega_instance.wait_for_total_catchup()
|
||||
|
||||
vega.submit_order(
|
||||
vega_instance.submit_order(
|
||||
trading_key="Key 1",
|
||||
market_id=market_2,
|
||||
market_id=markets["market_2"],
|
||||
time_in_force="TIME_IN_FORCE_GTC",
|
||||
order_type="TYPE_LIMIT",
|
||||
side="SIDE_SELL",
|
||||
@ -191,12 +178,12 @@ def markets(vega: VegaServiceNull):
|
||||
price=150,
|
||||
)
|
||||
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
vega_instance.wait_fn(1)
|
||||
vega_instance.wait_for_total_catchup()
|
||||
|
||||
vega.submit_order(
|
||||
vega_instance.submit_order(
|
||||
trading_key="Key 1",
|
||||
market_id=market_2,
|
||||
market_id=markets["market_2"],
|
||||
time_in_force="TIME_IN_FORCE_GTC",
|
||||
order_type="TYPE_LIMIT",
|
||||
side="SIDE_SELL",
|
||||
@ -204,12 +191,12 @@ def markets(vega: VegaServiceNull):
|
||||
price=160,
|
||||
)
|
||||
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
vega_instance.wait_fn(1)
|
||||
vega_instance.wait_for_total_catchup()
|
||||
|
||||
vega.submit_order(
|
||||
vega_instance.submit_order(
|
||||
trading_key="Key 1",
|
||||
market_id=market_3,
|
||||
market_id=markets["market_3"],
|
||||
time_in_force="TIME_IN_FORCE_GTC",
|
||||
order_type="TYPE_LIMIT",
|
||||
side="SIDE_BUY",
|
||||
@ -217,21 +204,24 @@ def markets(vega: VegaServiceNull):
|
||||
price=60,
|
||||
)
|
||||
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
vega_instance.wait_fn(1)
|
||||
vega_instance.wait_for_total_catchup()
|
||||
# Initialize page and setup
|
||||
|
||||
yield vega_instance, markets
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def page(vega, browser, request):
|
||||
with init_page(vega, browser, request) as page:
|
||||
def page(setup_environment, browser, request):
|
||||
vega_instance, markets = setup_environment
|
||||
with init_page(vega_instance, browser, request) as page:
|
||||
risk_accepted_setup(page)
|
||||
auth_setup(vega, page)
|
||||
auth_setup(vega_instance, page)
|
||||
page.goto("/")
|
||||
page.get_by_test_id("All").click()
|
||||
yield page
|
||||
|
||||
|
||||
# close toast that is still opened after test
|
||||
@pytest.fixture(autouse=True)
|
||||
def after_each(page: Page):
|
||||
yield
|
||||
@ -381,7 +371,8 @@ def test_order_status_pegged_mid(page: Page):
|
||||
)
|
||||
|
||||
|
||||
def test_order_amend_order(vega: VegaServiceNull, page: Page):
|
||||
def test_order_amend_order(setup_environment, page:Page):
|
||||
vega, markets = setup_environment
|
||||
# 7002-SORD-053
|
||||
# 7003-MORD-012
|
||||
# 7003-MORD-014
|
||||
@ -402,13 +393,13 @@ def test_order_amend_order(vega: VegaServiceNull, page: Page):
|
||||
)
|
||||
|
||||
|
||||
def test_order_cancel_single_order(vega: VegaServiceNull, page: Page):
|
||||
def test_order_cancel_single_order(setup_environment, page:Page):
|
||||
vega, markets = setup_environment
|
||||
# 7003-MORD-009
|
||||
# 7003-MORD-010
|
||||
# 7003-MORD-011
|
||||
# 7002-SORD-043
|
||||
page.get_by_test_id("cancel").first.click()
|
||||
|
||||
wait_for_toast_confirmation(page, timeout=5000)
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
@ -420,7 +411,8 @@ def test_order_cancel_single_order(vega: VegaServiceNull, page: Page):
|
||||
)
|
||||
|
||||
|
||||
def test_order_cancel_all_orders(vega: VegaServiceNull, page: Page):
|
||||
def test_order_cancel_all_orders(setup_environment, page:Page):
|
||||
vega, markets = setup_environment
|
||||
# 7003-MORD-009
|
||||
# 7003-MORD-010
|
||||
# 7003-MORD-011
|
||||
|
@ -1,8 +1,15 @@
|
||||
import pytest
|
||||
import vega_sim.proto.vega as vega_protos
|
||||
from typing import Tuple, Generator
|
||||
from rewards_test_ids import *
|
||||
from playwright.sync_api import Page, expect
|
||||
from conftest import init_vega, init_page, auth_setup, risk_accepted_setup, cleanup_container
|
||||
from conftest import (
|
||||
init_vega,
|
||||
init_page,
|
||||
auth_setup,
|
||||
risk_accepted_setup,
|
||||
cleanup_container,
|
||||
)
|
||||
from fixtures.market import setup_continuous_market
|
||||
from actions.utils import next_epoch, change_keys
|
||||
from wallet_config import MM_WALLET
|
||||
@ -10,22 +17,20 @@ from vega_sim.null_service import VegaServiceNull
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def vega(request):
|
||||
def setup_environment(request, browser) -> Generator[Tuple[Page, str, str], None, None]:
|
||||
with init_vega(request) as vega_instance:
|
||||
request.addfinalizer(lambda: cleanup_container(vega_instance))
|
||||
yield vega_instance
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def page(vega, browser, request):
|
||||
with init_page(vega, browser, request) as page:
|
||||
tDAI_market, tDAI_asset_id = setup_market_with_reward_program(vega_instance)
|
||||
|
||||
with init_page(vega_instance, browser, request) as page:
|
||||
risk_accepted_setup(page)
|
||||
auth_setup(vega, page)
|
||||
auth_setup(vega_instance, page)
|
||||
page.goto(REWARDS_URL)
|
||||
change_keys(page, vega, PARTY_B)
|
||||
yield page
|
||||
change_keys(page, vega_instance, PARTY_B)
|
||||
yield page, tDAI_market, tDAI_asset_id
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", autouse=True)
|
||||
def setup_market_with_reward_program(vega: VegaServiceNull):
|
||||
tDAI_market = setup_continuous_market(vega)
|
||||
PARTY_A, PARTY_B, PARTY_C, PARTY_D = keys(vega)
|
||||
@ -83,35 +88,35 @@ def setup_market_with_reward_program(vega: VegaServiceNull):
|
||||
return tDAI_market, tDAI_asset_id
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_rewards_hoarder_tier_0")
|
||||
def test_network_reward_pot(
|
||||
page: Page,
|
||||
):
|
||||
setup_environment: Tuple[Page, str, str],
|
||||
) -> None:
|
||||
page, tDAI_market, tDAI_asset_id = setup_environment
|
||||
expect(page.get_by_test_id(TOTAL_REWARDS)).to_have_text("50.00 tDAI")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_rewards_hoarder_tier_0")
|
||||
def test_reward_multiplier(
|
||||
page: Page,
|
||||
):
|
||||
setup_environment: Tuple[Page, str, str],
|
||||
) -> None:
|
||||
page, tDAI_market, tDAI_asset_id = setup_environment
|
||||
expect(page.get_by_test_id(COMBINED_MULTIPLIERS)).to_have_text("1x")
|
||||
expect(page.get_by_test_id(STREAK_REWARD_MULTIPLIER_VALUE)).to_have_text("1x")
|
||||
expect(page.get_by_test_id(HOARDER_REWARD_MULTIPLIER_VALUE)).to_have_text("1x")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_rewards_hoarder_tier_0")
|
||||
def test_hoarder_bonus(
|
||||
page: Page,
|
||||
):
|
||||
setup_environment: Tuple[Page, str, str],
|
||||
) -> None:
|
||||
page, tDAI_market, tDAI_asset_id = setup_environment
|
||||
expect(page.get_by_test_id(HOARDER_BONUS_TOTAL_HOARDED)).to_contain_text(
|
||||
"5,000,000"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_rewards_hoarder_tier_0")
|
||||
def test_reward_history(
|
||||
page: Page,
|
||||
):
|
||||
setup_environment: Tuple[Page, str, str],
|
||||
) -> None:
|
||||
page, tDAI_market, tDAI_asset_id = setup_environment
|
||||
page.locator('[name="fromEpoch"]').fill("1")
|
||||
expect((page.get_by_role(ROW).locator(PRICE_TAKING_COL_ID)).nth(1)).to_have_text(
|
||||
"100.00100.00%"
|
||||
|
@ -1,8 +1,15 @@
|
||||
import pytest
|
||||
from rewards_test_ids import *
|
||||
from typing import Tuple, Generator
|
||||
import vega_sim.proto.vega as vega_protos
|
||||
from playwright.sync_api import Page, expect
|
||||
from conftest import init_vega, init_page, auth_setup, risk_accepted_setup, cleanup_container
|
||||
from conftest import (
|
||||
init_vega,
|
||||
init_page,
|
||||
auth_setup,
|
||||
risk_accepted_setup,
|
||||
cleanup_container,
|
||||
)
|
||||
from fixtures.market import setup_continuous_market
|
||||
from actions.utils import next_epoch, change_keys
|
||||
from wallet_config import MM_WALLET
|
||||
@ -10,23 +17,21 @@ from vega_sim.null_service import VegaServiceNull
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def vega(request):
|
||||
def setup_environment(request, browser) -> Generator[Tuple[Page, str, str], None, None]:
|
||||
|
||||
with init_vega(request) as vega_instance:
|
||||
request.addfinalizer(lambda: cleanup_container(vega_instance))
|
||||
yield vega_instance
|
||||
|
||||
tDAI_market, tDAI_asset_id = setup_market_with_reward_program(vega_instance)
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def page(vega, browser, request):
|
||||
with init_page(vega, browser, request) as page:
|
||||
with init_page(vega_instance, browser, request) as page:
|
||||
risk_accepted_setup(page)
|
||||
auth_setup(vega, page)
|
||||
auth_setup(vega_instance, page)
|
||||
page.goto(REWARDS_URL)
|
||||
change_keys(page, vega, PARTY_B)
|
||||
yield page
|
||||
change_keys(page, vega_instance, PARTY_B)
|
||||
yield page, tDAI_market, tDAI_asset_id
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", autouse=True)
|
||||
def setup_market_with_reward_program(vega: VegaServiceNull):
|
||||
tDAI_market = setup_continuous_market(vega)
|
||||
PARTY_A, PARTY_B, PARTY_C, PARTY_D = keys(vega)
|
||||
@ -135,31 +140,35 @@ def setup_market_with_reward_program(vega: VegaServiceNull):
|
||||
return tDAI_market, tDAI_asset_id
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_rewards_hoarder_tier_1")
|
||||
def test_network_reward_pot(
|
||||
page: Page,
|
||||
):
|
||||
setup_environment: Tuple[Page, str, str],
|
||||
) -> None:
|
||||
page, tDAI_market, tDAI_asset_id = setup_environment
|
||||
expect(page.get_by_test_id(TOTAL_REWARDS)).to_have_text("166.66666 tDAI")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_rewards_hoarder_tier_1")
|
||||
def test_reward_multiplier(
|
||||
page: Page,
|
||||
):
|
||||
setup_environment: Tuple[Page, str, str],
|
||||
) -> None:
|
||||
page, tDAI_market, tDAI_asset_id = setup_environment
|
||||
expect(page.get_by_test_id(COMBINED_MULTIPLIERS)).to_have_text("2x")
|
||||
expect(page.get_by_test_id(STREAK_REWARD_MULTIPLIER_VALUE)).to_have_text("1x")
|
||||
expect(page.get_by_test_id(HOARDER_REWARD_MULTIPLIER_VALUE)).to_have_text("2x")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_rewards_hoarder_tier_1")
|
||||
def test_hoarder_bonus(page: Page):
|
||||
def test_hoarder_bonus(
|
||||
setup_environment: Tuple[Page, str, str],
|
||||
) -> None:
|
||||
page, tDAI_market, tDAI_asset_id = setup_environment
|
||||
expect(page.get_by_test_id(HOARDER_BONUS_TOTAL_HOARDED)).to_contain_text(
|
||||
"16,666,666"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_rewards_hoarder_tier_1")
|
||||
def test_reward_history(page: Page):
|
||||
def test_reward_history(
|
||||
setup_environment: Tuple[Page, str, str],
|
||||
) -> None:
|
||||
page, tDAI_market, tDAI_asset_id = setup_environment
|
||||
page.locator('[name="fromEpoch"]').fill("1")
|
||||
expect((page.get_by_role(ROW).locator(PRICE_TAKING_COL_ID)).nth(1)).to_have_text(
|
||||
"299.99999100.00%"
|
||||
|
@ -1,5 +1,6 @@
|
||||
import pytest
|
||||
from rewards_test_ids import *
|
||||
from typing import Tuple, Generator
|
||||
import vega_sim.proto.vega as vega_protos
|
||||
from playwright.sync_api import Page, expect
|
||||
from conftest import (
|
||||
@ -16,23 +17,23 @@ from vega_sim.null_service import VegaServiceNull
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def vega(request):
|
||||
def setup_environment(request, browser) -> Generator[Tuple[Page, str, str], None, None]:
|
||||
|
||||
with init_vega(request) as vega_instance:
|
||||
request.addfinalizer(lambda: cleanup_container(vega_instance))
|
||||
yield vega_instance
|
||||
|
||||
tDAI_market, tDAI_asset_id = setup_market_with_reward_program(vega_instance)
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def page(vega, browser, request):
|
||||
with init_page(vega, browser, request) as page:
|
||||
with init_page(vega_instance, browser, request) as page:
|
||||
risk_accepted_setup(page)
|
||||
auth_setup(vega, page)
|
||||
auth_setup(vega_instance, page)
|
||||
page.goto(REWARDS_URL)
|
||||
change_keys(page, vega, PARTY_B)
|
||||
yield page
|
||||
change_keys(page, vega_instance, PARTY_B)
|
||||
yield page, tDAI_market, tDAI_asset_id
|
||||
|
||||
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", autouse=True)
|
||||
def setup_market_with_reward_program(vega: VegaServiceNull):
|
||||
tDAI_market = setup_continuous_market(vega)
|
||||
PARTY_A, PARTY_B, PARTY_C, PARTY_D = keys(vega)
|
||||
@ -90,25 +91,23 @@ def setup_market_with_reward_program(vega: VegaServiceNull):
|
||||
return tDAI_market, tDAI_asset_id
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_rewards_activity_tier_0")
|
||||
def test_network_reward_pot(
|
||||
page: Page,
|
||||
):
|
||||
setup_environment: Tuple[Page, str, str],
|
||||
) -> None:
|
||||
page, tDAI_market, tDAI_asset_id = setup_environment
|
||||
expect(page.get_by_test_id(TOTAL_REWARDS)).to_have_text("50.00 tDAI")
|
||||
page.pause()
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_rewards_activity_tier_0")
|
||||
def test_reward_multiplier(
|
||||
page: Page,
|
||||
):
|
||||
page.pause()
|
||||
setup_environment: Tuple[Page, str, str],
|
||||
) -> None:
|
||||
page, tDAI_market, tDAI_asset_id = setup_environment
|
||||
expect(page.get_by_test_id(COMBINED_MULTIPLIERS)).to_have_text("1x")
|
||||
expect(page.get_by_test_id(STREAK_REWARD_MULTIPLIER_VALUE)).to_have_text("1x")
|
||||
expect(page.get_by_test_id(HOARDER_REWARD_MULTIPLIER_VALUE)).to_have_text("1x")
|
||||
|
||||
|
||||
""" @pytest.mark.xdist_group(name="test_rewards_activity_tier_0")
|
||||
"""
|
||||
def test_activity_streak(
|
||||
page: Page,
|
||||
):
|
||||
@ -117,7 +116,6 @@ def test_activity_streak(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_rewards_activity_tier_0")
|
||||
def test_reward_history(
|
||||
page: Page,
|
||||
):
|
||||
|
@ -1,8 +1,15 @@
|
||||
import pytest
|
||||
from rewards_test_ids import *
|
||||
from typing import Tuple, Generator
|
||||
import vega_sim.proto.vega as vega_protos
|
||||
from playwright.sync_api import Page, expect
|
||||
from conftest import init_vega, init_page, auth_setup, risk_accepted_setup, cleanup_container
|
||||
from conftest import (
|
||||
init_vega,
|
||||
init_page,
|
||||
auth_setup,
|
||||
risk_accepted_setup,
|
||||
cleanup_container,
|
||||
)
|
||||
from fixtures.market import setup_continuous_market
|
||||
from actions.utils import next_epoch, change_keys
|
||||
from wallet_config import MM_WALLET
|
||||
@ -10,22 +17,21 @@ from vega_sim.null_service import VegaServiceNull
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def vega(request):
|
||||
def setup_environment(request, browser) -> Generator[Tuple[Page, str, str], None, None]:
|
||||
|
||||
with init_vega(request) as vega_instance:
|
||||
request.addfinalizer(lambda: cleanup_container(vega_instance))
|
||||
yield vega_instance
|
||||
|
||||
tDAI_market, tDAI_asset_id = setup_market_with_reward_program(vega_instance)
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def page(vega, browser, request):
|
||||
with init_page(vega, browser, request) as page:
|
||||
with init_page(vega_instance, browser, request) as page:
|
||||
risk_accepted_setup(page)
|
||||
auth_setup(vega, page)
|
||||
auth_setup(vega_instance, page)
|
||||
page.goto(REWARDS_URL)
|
||||
change_keys(page, vega, PARTY_B)
|
||||
yield page
|
||||
change_keys(page, vega_instance, PARTY_B)
|
||||
yield page, tDAI_market, tDAI_asset_id
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", autouse=True)
|
||||
def setup_market_with_reward_program(vega: VegaServiceNull):
|
||||
tDAI_market = setup_continuous_market(vega)
|
||||
PARTY_A, PARTY_B, PARTY_C, PARTY_D = keys(vega)
|
||||
@ -128,34 +134,35 @@ def setup_market_with_reward_program(vega: VegaServiceNull):
|
||||
return tDAI_market, tDAI_asset_id
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_rewards_activity_tier_1")
|
||||
def test_network_reward_pot(page: Page):
|
||||
|
||||
def test_network_reward_pot(
|
||||
setup_environment: Tuple[Page, str, str],
|
||||
) -> None:
|
||||
page, tDAI_market, tDAI_asset_id = setup_environment
|
||||
expect(page.get_by_test_id(TOTAL_REWARDS)).to_have_text("116.66666 tDAI")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_rewards_activity_tier_1")
|
||||
def test_reward_multiplier(
|
||||
page: Page,
|
||||
):
|
||||
setup_environment: Tuple[Page, str, str],
|
||||
) -> None:
|
||||
page, tDAI_market, tDAI_asset_id = setup_environment
|
||||
expect(page.get_by_test_id(COMBINED_MULTIPLIERS)).to_have_text("2x")
|
||||
expect(page.get_by_test_id(STREAK_REWARD_MULTIPLIER_VALUE)).to_have_text("2x")
|
||||
expect(page.get_by_test_id(HOARDER_REWARD_MULTIPLIER_VALUE)).to_have_text("1x")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_rewards_activity_tier_1")
|
||||
def test_activity_streak(
|
||||
page: Page,
|
||||
):
|
||||
setup_environment: Tuple[Page, str, str],
|
||||
) -> None:
|
||||
page, tDAI_market, tDAI_asset_id = setup_environment
|
||||
expect(page.get_by_test_id(EPOCH_STREAK)).to_have_text(
|
||||
"Active trader: 7 epochs so far (Tier 1 as of last epoch)"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_rewards_activity_tier_1")
|
||||
def test_reward_history(
|
||||
page: Page,
|
||||
):
|
||||
setup_environment: Tuple[Page, str, str],
|
||||
) -> None:
|
||||
page, tDAI_market, tDAI_asset_id = setup_environment
|
||||
page.locator('[name="fromEpoch"]').fill("1")
|
||||
expect((page.get_by_role(ROW).locator(PRICE_TAKING_COL_ID)).nth(1)).to_have_text(
|
||||
"300.00100.00%"
|
||||
@ -167,10 +174,10 @@ def test_reward_history(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_rewards_activity_tier_1")
|
||||
def test_redeem(
|
||||
page: Page,
|
||||
):
|
||||
setup_environment: Tuple[Page, str, str],
|
||||
) -> None:
|
||||
page, tDAI_market, tDAI_asset_id = setup_environment
|
||||
page.get_by_test_id("redeem-rewards-button").click()
|
||||
available_to_withdraw = page.get_by_test_id(
|
||||
"available-to-withdraw-value"
|
||||
|
@ -1,5 +1,6 @@
|
||||
import pytest
|
||||
from rewards_test_ids import *
|
||||
from typing import Tuple, Generator
|
||||
import vega_sim.proto.vega as vega_protos
|
||||
from playwright.sync_api import Page, expect
|
||||
from conftest import init_vega, init_page, auth_setup, risk_accepted_setup, cleanup_container
|
||||
@ -9,24 +10,20 @@ from wallet_config import MM_WALLET
|
||||
from vega_sim.null_service import VegaServiceNull
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def vega(request):
|
||||
def setup_environment(request, browser) -> Generator[Tuple[Page, str, str], None, None]:
|
||||
with init_vega(request) as vega_instance:
|
||||
request.addfinalizer(lambda: cleanup_container(vega_instance))
|
||||
yield vega_instance
|
||||
|
||||
tDAI_market, tDAI_asset_id = setup_market_with_reward_program(vega_instance)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def page(vega, browser, request):
|
||||
with init_page(vega, browser, request) as page:
|
||||
with init_page(vega_instance, browser, request) as page:
|
||||
risk_accepted_setup(page)
|
||||
auth_setup(vega, page)
|
||||
auth_setup(vega_instance, page)
|
||||
page.goto(REWARDS_URL)
|
||||
change_keys(page, vega, PARTY_B)
|
||||
yield page
|
||||
change_keys(page, vega_instance, PARTY_B)
|
||||
yield page, tDAI_market, tDAI_asset_id
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", autouse=True)
|
||||
def setup_market_with_reward_program(vega: VegaServiceNull):
|
||||
tDAI_market = setup_continuous_market(vega)
|
||||
PARTY_A, PARTY_B, PARTY_C, PARTY_D = keys(vega)
|
||||
@ -150,16 +147,18 @@ def setup_market_with_reward_program(vega: VegaServiceNull):
|
||||
return tDAI_market, tDAI_asset_id
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_rewards_combo_tier_1")
|
||||
def test_network_reward_pot( page: Page
|
||||
):
|
||||
|
||||
def test_network_reward_pot( setup_environment: Tuple[Page, str, str],
|
||||
) -> None:
|
||||
page, tDAI_market, tDAI_asset_id = setup_environment
|
||||
expect(page.get_by_test_id(TOTAL_REWARDS)).to_have_text("183.33333 tDAI")
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_rewards_combo_tier_1")
|
||||
|
||||
def test_reward_multiplier(
|
||||
page: Page,
|
||||
):
|
||||
setup_environment: Tuple[Page, str, str],
|
||||
) -> None:
|
||||
page, tDAI_market, tDAI_asset_id = setup_environment
|
||||
expect(page.get_by_test_id(COMBINED_MULTIPLIERS)).to_have_text("4x")
|
||||
expect(page.get_by_test_id(STREAK_REWARD_MULTIPLIER_VALUE)).to_have_text(
|
||||
"2x"
|
||||
@ -169,10 +168,11 @@ def test_reward_multiplier(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="test_rewards_combo_tier_1")
|
||||
|
||||
def test_reward_history(
|
||||
page: Page,
|
||||
):
|
||||
setup_environment: Tuple[Page, str, str],
|
||||
) -> None:
|
||||
page, tDAI_market, tDAI_asset_id = setup_environment
|
||||
page.locator('[name="fromEpoch"]').fill("1")
|
||||
expect((page.get_by_role(ROW).locator(PRICE_TAKING_COL_ID)).nth(1)).to_have_text(
|
||||
"299.99999100.00%"
|
||||
|
Loading…
Reference in New Issue
Block a user