Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tests/test_chunked.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ def test_get_status_finalized(self, mock_session_class):
"dataCaches": ["arweave.net"],
"fastFinalityIndexes": ["arweave.net"],
"winc": "1000",
"signature": "receipt_sig",
"public": "receipt_pub",
"version": "1.0.0",
"deadlineHeight": 999999,
},
}

Expand All @@ -274,6 +278,10 @@ def test_get_status_finalized(self, mock_session_class):
assert status.id == "tx-id"
assert status.owner == "owner-address"
assert status.data_caches == ["arweave.net"]
assert status.signature == "receipt_sig"
assert status.public == "receipt_pub"
assert status.version == "1.0.0"
assert status.deadline_height == 999999

@patch("turbo_sdk.chunked.requests.Session")
def test_get_status_validating(self, mock_session_class):
Expand Down
10 changes: 10 additions & 0 deletions tests/test_turbo.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,23 @@ def test_upload_with_bytes(self, mock_post, turbo):
"dataCaches": ["cache1"],
"fastFinalityIndexes": ["index1"],
"winc": "1000",
"timestamp": 1776068746997,
"signature": "test_sig",
"public": "test_pub",
"version": "1.0.0",
"deadlineHeight": 1234567,
}
mock_post.return_value = mock_response

result = turbo.upload(data=test_data, tags=[{"name": "Test", "value": "bytes"}])

assert result.id == "test_tx_id"
assert result.owner == "test_owner"
assert result.timestamp == 1776068746997
assert result.signature == "test_sig"
assert result.public == "test_pub"
assert result.version == "1.0.0"
assert result.deadline_height == 1234567
mock_post.assert_called_once()

@patch("turbo_sdk.client.requests.post")
Expand Down
9 changes: 9 additions & 0 deletions turbo_sdk/chunked.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ def get_status(self, upload_id: str) -> TurboUploadStatus:
data_caches=receipt.get("dataCaches", []),
fast_finality_indexes=receipt.get("fastFinalityIndexes", []),
winc=receipt.get("winc"),
signature=receipt.get("signature"),
public=receipt.get("public"),
version=receipt.get("version"),
deadline_height=receipt.get("deadlineHeight"),
)
elif response.status_code == 404:
raise ChunkedUploadError("Upload session not found")
Expand Down Expand Up @@ -300,6 +304,11 @@ def upload(
data_caches=status.data_caches,
fast_finality_indexes=status.fast_finality_indexes,
winc=status.winc or "0",
timestamp=status.timestamp,
signature=status.signature,
public=status.public,
version=status.version,
deadline_height=status.deadline_height,
)
except Exception:
# Could implement cleanup here in future
Expand Down
5 changes: 5 additions & 0 deletions turbo_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ def _upload_single(
data_caches=result.get("dataCaches", []),
fast_finality_indexes=result.get("fastFinalityIndexes", []),
winc=result.get("winc", "0"),
timestamp=result.get("timestamp"),
signature=result.get("signature"),
public=result.get("public"),
version=result.get("version"),
deadline_height=result.get("deadlineHeight"),
)
else:
raise Exception(f"Upload failed: {response.status_code} - {response.text}")
Expand Down
9 changes: 9 additions & 0 deletions turbo_sdk/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ class TurboUploadStatus:
data_caches: List[str] = field(default_factory=list)
fast_finality_indexes: List[str] = field(default_factory=list)
winc: Optional[str] = None
signature: Optional[str] = None
public: Optional[str] = None
version: Optional[str] = None
deadline_height: Optional[int] = None


@dataclass
Expand All @@ -56,6 +60,11 @@ class TurboUploadResponse:
data_caches: List[str] # Cache endpoints
fast_finality_indexes: List[str] # Fast finality
winc: str # Winston credits cost
timestamp: Optional[int] = None # Receipt creation time (ms)
signature: Optional[str] = None # Base64URL receipt signature
public: Optional[str] = None # Signer's public key
version: Optional[str] = None # Receipt schema version
deadline_height: Optional[int] = None # Block height context


@dataclass
Expand Down
Loading