generated from ApeWorX/project-template
-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(platform): updates to StreamInfo and ClusterInfo models (#127)
* refactor(platform): remove configuration from `platform.create_cluster` * refactor(runner): make small adjustment to task kill logic * refactor(platform): add StreamInfo to client types * fix(platform): HMAC params in wrong order * feat(platform): add expiration to ClusterInfo record * refactor(tests): fix encoding test, add fuzzing
- Loading branch information
Showing
6 changed files
with
35 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,25 @@ | ||
import uuid | ||
from eth_utils import to_checksum_address | ||
from hypothesis import given | ||
from hypothesis import strategies as st | ||
from hypothesis_jsonschema import from_schema | ||
|
||
from silverback.cluster.types import ClusterConfiguration | ||
|
||
CONFIG_SCHEMA = ClusterConfiguration.model_json_schema() | ||
|
||
def test_hmac_signature(): | ||
config = ClusterConfiguration() | ||
cluster_id = uuid.uuid4() | ||
owner = "0x4838B106FCe9647Bdf1E7877BF73cE8B0BAD5f97" | ||
|
||
@given( # type: ignore[call-overload] | ||
cluster_id=st.uuids(version=4), | ||
owner=st.binary(min_size=20, max_size=20).map(to_checksum_address), | ||
config_dict=from_schema(CONFIG_SCHEMA), | ||
) | ||
def test_hmac_signature(cluster_id, owner, config_dict): | ||
# NOTE: Ignore `version` fuzzed value | ||
config_dict["version"] = 1 | ||
config = ClusterConfiguration(**config_dict) | ||
product_code = config.get_product_code(owner, cluster_id) | ||
# NOTE: There is a gap of empty bytes between 8-16 | ||
encoded_config, sig = product_code[:8], product_code[16:] | ||
# NOTE: Ensure we can properly decode the encoded product code into a configuration | ||
assert config == ClusterConfiguration.decode(product_code[:16]) | ||
assert config.validate_product_code(owner, product_code[16:], cluster_id) | ||
assert config == ClusterConfiguration.decode(encoded_config) | ||
assert config.validate_product_code(owner, sig, cluster_id) |