Skip to content

Commit

Permalink
chore: clean up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pik694 committed Mar 27, 2024
1 parent c815298 commit 66c2d6f
Show file tree
Hide file tree
Showing 19 changed files with 425 additions and 674 deletions.
38 changes: 1 addition & 37 deletions backend/app/infrastructure/database/allocations.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from collections import defaultdict
from datetime import datetime
from typing import List, Optional
from typing import List

from eth_utils import to_checksum_address
from sqlalchemy.orm import Query
Expand Down Expand Up @@ -182,42 +182,6 @@ def store_allocation_request(
db.session.add_all(new_allocations)


@deprecated("Alloc rework")
def add_all(epoch: int, user_id: int, nonce: int, allocations):
new_allocations = [
Allocation(
epoch=epoch,
user_id=user_id,
nonce=nonce,
proposal_address=to_checksum_address(a.proposal_address),
amount=str(a.amount),
)
for a in allocations
]
db.session.add_all(new_allocations)


@deprecated("Alloc rework")
def add_allocation_request(
user_address: str,
epoch: int,
nonce: int,
signature: str,
is_manually_edited: Optional[bool] = None,
):
user: User = get_by_address(user_address)

allocation_request = AllocationRequest(
user=user,
epoch=epoch,
nonce=nonce,
signature=signature,
is_manually_edited=is_manually_edited,
)

db.session.add(allocation_request)


def get_allocation_request_by_user_nonce(
user_address: str, nonce: int
) -> AllocationRequest | None:
Expand Down
10 changes: 3 additions & 7 deletions backend/app/infrastructure/routes/allocations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
from flask import current_app as app
from flask_restx import Namespace, fields

from app.legacy.controllers import allocations
from app.legacy.core.allocations import AllocationRequest
from app.extensions import api
from app.infrastructure import OctantResource
from app.modules.user.allocations import controller
Expand Down Expand Up @@ -165,14 +163,12 @@ class Allocation(OctantResource):
@ns.expect(user_allocation_request)
@ns.response(201, "User allocated successfully")
def post(self):
payload, signature = ns.payload["payload"], ns.payload["signature"]
app.logger.info(f"User allocation: {ns.payload}")
is_manually_edited = (
ns.payload["isManuallyEdited"] if "isManuallyEdited" in ns.payload else None
)
app.logger.info(f"User allocation payload: {payload}, signature: {signature}")
user_address = allocations.allocate(
AllocationRequest(payload, signature, override_existing_allocations=True),
is_manually_edited,
user_address = controller.allocate(
ns.payload, is_manually_edited=is_manually_edited
)
app.logger.info(f"User: {user_address} allocated successfully")

Expand Down
14 changes: 0 additions & 14 deletions backend/app/legacy/controllers/allocations.py

This file was deleted.

117 changes: 0 additions & 117 deletions backend/app/legacy/core/allocations.py

This file was deleted.

7 changes: 4 additions & 3 deletions backend/app/modules/user/allocations/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,10 @@ def revoke_previous_allocation(user_address: str):


def _deserialize_payload(payload: Dict) -> UserAllocationRequestPayload:
allocation_items = _deserialize_items(payload.payload)
nonce = int(payload.payload["nonce"])
signature = payload.signature
allocation_payload = payload["payload"]
allocation_items = _deserialize_items(allocation_payload)
nonce = int(allocation_payload["nonce"])
signature = payload["signature"]

return UserAllocationRequestPayload(
payload=UserAllocationPayload(allocation_items, nonce), signature=signature
Expand Down
Loading

0 comments on commit 66c2d6f

Please sign in to comment.