Skip to content

Commit

Permalink
add more tests, randomize taskChainId (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldruschk authored May 31, 2021
1 parent a52c0e8 commit 14a494d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
41 changes: 40 additions & 1 deletion enochecker_test/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
global_round_id = 0
FLAG_REGEX = r"ENO[A-Za-z0-9+\/=]{48}"
REQUEST_TIMEOUT = 10
CHAIN_ID_PREFIX = secrets.token_hex(20)


@pytest.fixture
Expand Down Expand Up @@ -111,7 +112,9 @@ def _create_request_message(
prefix = "noise"
elif method == "exploit":
prefix = "exploit"
task_chain_id = f"{prefix}_s0_r{round_id}_t0_i{unique_variant_index}"
task_chain_id = (
f"{CHAIN_ID_PREFIX}_{prefix}_s0_r{round_id}_t0_i{unique_variant_index}"
)

return CheckerTaskMessage(
task_id=round_id,
Expand Down Expand Up @@ -375,6 +378,32 @@ def test_getflag(round_id, flag_id, service_address, checker_url):
_test_getflag(flag, round_id, flag_id, service_address, checker_url)


def test_getflag_wrong_flag(round_id, flag_id, service_address, checker_url):
flag = generate_dummyflag()
_test_putflag(flag, round_id, flag_id, service_address, checker_url)
wrong_flag = generate_dummyflag()
_test_getflag(
wrong_flag,
round_id,
flag_id,
service_address,
checker_url,
expected_result=CheckerTaskResult.MUMBLE,
)


def test_getflag_without_putflag(round_id, flag_id, service_address, checker_url):
flag = generate_dummyflag()
_test_getflag(
flag,
round_id,
flag_id,
service_address,
checker_url,
expected_result=CheckerTaskResult.MUMBLE,
)


def test_getflag_multiplied(
round_id, flag_id_multiplied, flag_variants, service_address, checker_url
):
Expand Down Expand Up @@ -442,6 +471,16 @@ def test_getnoise(round_id, noise_id, service_address, checker_url):
_test_getnoise(round_id, noise_id, service_address, checker_url)


def test_getnoise_without_putnoise(round_id, noise_id, service_address, checker_url):
_test_getnoise(
round_id,
noise_id,
service_address,
checker_url,
expected_result=CheckerTaskResult.MUMBLE,
)


def test_getnoise_multiplied(
round_id, noise_id_multiplied, noise_variants, service_address, checker_url
):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setuptools.setup(
name="enochecker_test",
version="0.5.1",
version="0.6.0",
author="ldruschk",
author_email="[email protected]",
description="Library to help testing checker scripts based on enochecker",
Expand Down

0 comments on commit 14a494d

Please sign in to comment.