Skip to content

Commit

Permalink
more docs in verify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
0xlucyfer authored and 0xlucyfer committed Sep 11, 2023
1 parent 5c81d60 commit 9457db6
Showing 1 changed file with 43 additions and 6 deletions.
49 changes: 43 additions & 6 deletions tests/test_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ class TestVerify:

# Tests that the function returns True when provided with a valid proof and known valid inputs.
def test_verify_valid_proof_with_known_inputs(self):
'''
Tests the function with a known set of valid inputs and expects a successful verification.
'''
public_key = b'''-----BEGIN PUBLIC KEY-----
MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAED4BkWbqMmS/jxRQKC+xJVF2PeSwEx5g5
WrzeDT8WfdzesmMHFoP5p3yi7KPMsIwa7ZkNRbgvNX4y2wF9f4y9rA==
Expand All @@ -30,6 +33,9 @@ def test_verify_valid_proof_with_known_inputs(self):

# Tests that the function returns True when provided with a valid proof and a different set of valid inputs.
def test_verify_valid_proof_with_different_inputs_same_pub_key(self):
'''
Tests the function with a different set of valid inputs but the same public key.
'''
public_key = b'''-----BEGIN PUBLIC KEY-----
MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAED4BkWbqMmS/jxRQKC+xJVF2PeSwEx5g5
WrzeDT8WfdzesmMHFoP5p3yi7KPMsIwa7ZkNRbgvNX4y2wF9f4y9rA==
Expand All @@ -46,8 +52,11 @@ def test_verify_valid_proof_with_different_inputs_same_pub_key(self):
assert derived_bullet_index_hash == bullet_index_hash


# Tests that the function returns True when provided with different valid public key.

def test_verify_valid_proof_with_different_public_key(self):
'''
Tests the function with a different valid public key.
'''
public_key = b'''-----BEGIN PUBLIC KEY-----
MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE1DJ2RmUmTwg07t9w83Q5m4vNhqDqu2Xe
c0S1sJX01clxnSv3PsPI7g9Lujsc5+87q6NJ05eljd8R6jMRJV7nlQ==
Expand All @@ -64,6 +73,9 @@ def test_verify_valid_proof_with_different_public_key(self):
assert derived_bullet_index_hash == bullet_index_hash

def test_valid_verify_with_min_chambers(self):
'''
Tests the function with the minimum number of revolver chambers.
'''
public_key = b'''-----BEGIN PUBLIC KEY-----
MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE1DJ2RmUmTwg07t9w83Q5m4vNhqDqu2Xe
c0S1sJX01clxnSv3PsPI7g9Lujsc5+87q6NJ05eljd8R6jMRJV7nlQ==
Expand All @@ -79,7 +91,10 @@ def test_valid_verify_with_min_chambers(self):
assert proof_validity == True
assert derived_bullet_index_hash == bullet_index_hash

# def test_valid_verify_with_small_chambers(self):
def test_valid_verify_with_small_chambers(self):
'''
Tests the function with a small number of revolver chambers.
'''
public_key = b'''-----BEGIN PUBLIC KEY-----
MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE1DJ2RmUmTwg07t9w83Q5m4vNhqDqu2Xe
c0S1sJX01clxnSv3PsPI7g9Lujsc5+87q6NJ05eljd8R6jMRJV7nlQ==
Expand All @@ -96,6 +111,9 @@ def test_valid_verify_with_min_chambers(self):
assert derived_bullet_index_hash == bullet_index_hash

def test_valid_verify_with_same_chambers_and_bets(self):
'''
Tests the function with the same number of revolver chambers and bets.
'''
public_key = b'''-----BEGIN PUBLIC KEY-----
MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE1DJ2RmUmTwg07t9w83Q5m4vNhqDqu2Xe
c0S1sJX01clxnSv3PsPI7g9Lujsc5+87q6NJ05eljd8R6jMRJV7nlQ==
Expand All @@ -112,6 +130,9 @@ def test_valid_verify_with_same_chambers_and_bets(self):
assert derived_bullet_index_hash == bullet_index_hash

def test_valid_verify_with_same_chambers_and_diff_bets(self):
'''
Tests the function with the same number of revolver chambers but different bets.
'''
public_key = b'''-----BEGIN PUBLIC KEY-----
MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE1DJ2RmUmTwg07t9w83Q5m4vNhqDqu2Xe
c0S1sJX01clxnSv3PsPI7g9Lujsc5+87q6NJ05eljd8R6jMRJV7nlQ==
Expand All @@ -128,6 +149,9 @@ def test_valid_verify_with_same_chambers_and_diff_bets(self):
assert derived_bullet_index_hash == bullet_index_hash

def test_invalid_revolver_size(self):
'''
Tests the function where the revolver chambers is incorrect.
'''
public_key = b'''-----BEGIN PUBLIC KEY-----
MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE1DJ2RmUmTwg07t9w83Q5m4vNhqDqu2Xe
c0S1sJX01clxnSv3PsPI7g9Lujsc5+87q6NJ05eljd8R6jMRJV7nlQ==
Expand All @@ -144,6 +168,9 @@ def test_invalid_revolver_size(self):
assert derived_bullet_index_hash == bullet_index_hash

def test_invalid_alpha(self):
'''
Tests the function where the alpha is incorrect.
'''
public_key = b'''-----BEGIN PUBLIC KEY-----
MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE1DJ2RmUmTwg07t9w83Q5m4vNhqDqu2Xe
c0S1sJX01clxnSv3PsPI7g9Lujsc5+87q6NJ05eljd8R6jMRJV7nlQ==
Expand All @@ -160,6 +187,9 @@ def test_invalid_alpha(self):
assert derived_bullet_index_hash == bullet_index_hash

def test_invalid_proof(self):
'''
Tests the function where the proof is incorrect.
'''
public_key = b'''-----BEGIN PUBLIC KEY-----
MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE1DJ2RmUmTwg07t9w83Q5m4vNhqDqu2Xe
c0S1sJX01clxnSv3PsPI7g9Lujsc5+87q6NJ05eljd8R6jMRJV7nlQ==
Expand All @@ -177,6 +207,9 @@ def test_invalid_proof(self):
assert derived_bullet_index_hash == bullet_index_hash

def test_invalid_salt(self):
'''
Tests the function where the salt is incorrect.
'''
public_key = b'''-----BEGIN PUBLIC KEY-----
MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE1DJ2RmUmTwg07t9w83Q5m4vNhqDqu2Xe
c0S1sJX01clxnSv3PsPI7g9Lujsc5+87q6NJ05eljd8R6jMRJV7nlQ==
Expand All @@ -194,6 +227,9 @@ def test_invalid_salt(self):
assert derived_bullet_index_hash == bullet_index_hash

def test_invalid_seed_hash(self):
'''
Tests the function where the seed hash is incorrect.
'''
public_key = b'''-----BEGIN PUBLIC KEY-----
MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE1DJ2RmUmTwg07t9w83Q5m4vNhqDqu2Xe
c0S1sJX01clxnSv3PsPI7g9Lujsc5+87q6NJ05eljd8R6jMRJV7nlQ==
Expand All @@ -210,8 +246,11 @@ def test_invalid_seed_hash(self):
assert proof_validity == False
assert derived_bullet_index_hash == bullet_index_hash

# Tests that the function returns True when provided with different valid public key.

def test_invalid_pub_key(self):
'''
Tests the function where the public key is incorrect.
'''
# real_public_key = b'''-----BEGIN PUBLIC KEY-----
# MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE1DJ2RmUmTwg07t9w83Q5m4vNhqDqu2Xe
# c0S1sJX01clxnSv3PsPI7g9Lujsc5+87q6NJ05eljd8R6jMRJV7nlQ==
Expand All @@ -232,7 +271,6 @@ def test_invalid_pub_key(self):
assert derived_bullet_index_hash == bullet_index_hash


# Tests that the function returns True when provided with different valid public key.
@patch('ecdsa.keys.VerifyingKey.verify', side_effect=InterruptedError)
def test_vk_verify_exception(self, mocked_sig):
public_key = b'''-----BEGIN PUBLIC KEY-----
Expand All @@ -252,7 +290,6 @@ def test_vk_verify_exception(self, mocked_sig):
assert proof_validity == False
assert derived_bullet_index_hash == bullet_index_hash

# Tests that the function returns True when provided with different valid public key.
@patch('ecdsa.keys.VerifyingKey.verify', side_effect=ValueError)
def test_vk_verify_exception_value_error(self, mocked_sig):
public_key = b'''-----BEGIN PUBLIC KEY-----
Expand All @@ -272,7 +309,7 @@ def test_vk_verify_exception_value_error(self, mocked_sig):
assert proof_validity == False
assert derived_bullet_index_hash == bullet_index_hash

# Tests that the function returns True when provided with different valid public key.

@patch('ecdsa.keys.VerifyingKey.verify', return_valud=True)
def test_happy_path_not_successful(self, mocked_sig):
public_key = b'''-----BEGIN PUBLIC KEY-----
Expand Down

0 comments on commit 9457db6

Please sign in to comment.