Skip to content

Commit 370cafa

Browse files
committed
fix: missing token version in version api
1 parent 182f97d commit 370cafa

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

hathor/version_resource.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from hathor.feature_activation.feature_service import FeatureService
2424
from hathor.feature_activation.utils import Features
2525
from hathor.manager import HathorManager
26+
from hathor.transaction.token_info import TokenVersion
2627
from hathor.types import BlockId, TransactionId
2728
from hathor.utils.pydantic import BaseModel, Hex
2829

@@ -31,6 +32,7 @@ class NativeTokenInfo(BaseModel):
3132
"""Information about the native token."""
3233
name: str = Field(description="Native token name")
3334
symbol: str = Field(description="Native token symbol")
35+
version: int = Field(description="Native token version")
3436

3537

3638
class VersionResponse(ResponseModel):
@@ -72,7 +74,7 @@ class VersionResponse(ResponseModel):
7274
genesis_block_hash=BlockId(b'\x00' * 32),
7375
genesis_tx1_hash=TransactionId(b'\x00' * 31 + b'\x01'),
7476
genesis_tx2_hash=TransactionId(b'\x00' * 31 + b'\x02'),
75-
native_token=NativeTokenInfo(name='Hathor', symbol='HTR'),
77+
native_token=NativeTokenInfo(name='Hathor', symbol='HTR', version=TokenVersion.NATIVE),
7678
),
7779
),
7880
}
@@ -135,5 +137,6 @@ def render_GET(self, request):
135137
native_token=NativeTokenInfo(
136138
name=self._settings.NATIVE_TOKEN_NAME,
137139
symbol=self._settings.NATIVE_TOKEN_SYMBOL,
140+
version=TokenVersion.NATIVE,
138141
),
139142
)

hathor_tests/resources/test_version.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from twisted.internet.defer import inlineCallbacks
77

88
import hathor
9+
from hathor.transaction.token_info import TokenVersion
910
from hathor.version import BASE_VERSION, DEFAULT_VERSION_SUFFIX, _get_version
1011
from hathor.version_resource import VersionResource
1112
from hathor_tests.resources.base_resource import StubSite, _BaseResourceTest
@@ -27,6 +28,16 @@ def test_get(self):
2728
data = response.json_value()
2829
self.assertEqual(data['version'], hathor.__version__)
2930

31+
@inlineCallbacks
32+
def test_native_token(self):
33+
response = yield self.web.get("version")
34+
data = response.json_value()
35+
36+
native_token = data['native_token']
37+
self.assertEqual(native_token['name'], self._settings.NATIVE_TOKEN_NAME)
38+
self.assertEqual(native_token['symbol'], self._settings.NATIVE_TOKEN_SYMBOL)
39+
self.assertEqual(native_token['version'], int(TokenVersion.NATIVE))
40+
3041
def test_local_version(self):
3142
"""Test that we will return a version with the default prefix when the BUILD_VERSION file
3243
does not exist.

0 commit comments

Comments
 (0)