Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
overcat committed Dec 6, 2023
1 parent e42457d commit 595e9bd
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 22 deletions.
2 changes: 1 addition & 1 deletion stellar_model/model/horizon/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from decimal import Decimal
from typing import List, Optional, Union

from pydantic import BaseModel, Field, ConfigDict
from pydantic import BaseModel, ConfigDict, Field

from stellar_model.model.horizon.asset import Asset
from stellar_model.model.horizon.claimable_balance import Claimant
Expand Down
22 changes: 16 additions & 6 deletions tests/model/horizon/test_effects.py
Original file line number Diff line number Diff line change
Expand Up @@ -1145,11 +1145,16 @@ def test_contract_credited(self):
parsed_data = EffectContractCreditedEffect.model_validate(raw_data)
self.assertEqual(parsed_data.id, "0000021517786157057-0000000002")
self.assertEqual(parsed_data.paging_token, "21517786157057-2")
self.assertEqual(parsed_data.account, "GDAT5HWTGIU4TSSZ4752OUC4SABDLTLZFRPZUJ3D6LKBNEPA7V2CIG54")
self.assertEqual(
parsed_data.account,
"GDAT5HWTGIU4TSSZ4752OUC4SABDLTLZFRPZUJ3D6LKBNEPA7V2CIG54",
)
self.assertEqual(parsed_data.type, "contract_credited")
self.assertEqual(parsed_data.type_i, 96)
self.assertEqual(parsed_data.created_at,
datetime.datetime(2023, 9, 19, 5, 43, 12, tzinfo=datetime.timezone.utc))
self.assertEqual(
parsed_data.created_at,
datetime.datetime(2023, 9, 19, 5, 43, 12, tzinfo=datetime.timezone.utc),
)
self.assertEqual(parsed_data.asset_type, "native")
self.assertEqual(parsed_data.asset_code, None)
self.assertEqual(parsed_data.asset_issuer, None)
Expand All @@ -1160,11 +1165,16 @@ def test_contract_debited(self):
parsed_data = EffectContractCreditedEffect.model_validate(raw_data)
self.assertEqual(parsed_data.id, "0000021517786157057-0000000002")
self.assertEqual(parsed_data.paging_token, "21517786157057-2")
self.assertEqual(parsed_data.account, "GDAT5HWTGIU4TSSZ4752OUC4SABDLTLZFRPZUJ3D6LKBNEPA7V2CIG54")
self.assertEqual(
parsed_data.account,
"GDAT5HWTGIU4TSSZ4752OUC4SABDLTLZFRPZUJ3D6LKBNEPA7V2CIG54",
)
self.assertEqual(parsed_data.type, "contract_debited")
self.assertEqual(parsed_data.type_i, 97)
self.assertEqual(parsed_data.created_at,
datetime.datetime(2023, 9, 19, 5, 43, 12, tzinfo=datetime.timezone.utc))
self.assertEqual(
parsed_data.created_at,
datetime.datetime(2023, 9, 19, 5, 43, 12, tzinfo=datetime.timezone.utc),
)
self.assertEqual(parsed_data.asset_type, "native")
self.assertEqual(parsed_data.asset_code, None)
self.assertEqual(parsed_data.asset_issuer, None)
Expand Down
57 changes: 42 additions & 15 deletions tests/model/horizon/test_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
from decimal import Decimal

from stellar_model.model.horizon.operations import *
from stellar_model.model.horizon.operations import HostFunctionParameter, AssetContractBalanceChange
from stellar_model.model.horizon.operations import (
AssetContractBalanceChange,
HostFunctionParameter,
)
from tests.model.horizon import load_horizon_file

"""
Expand Down Expand Up @@ -1063,19 +1066,43 @@ def test_invoke_host_function_operation(self):
parsed_data.transaction_hash,
"4ef3d81fba4b7db959080e4894cb8b2575418b8da9aa484f6306a79a3f63de3d",
)
self.assertEqual(parsed_data.function, "HostFunctionTypeHostFunctionTypeInvokeContract")
self.assertEqual(parsed_data.parameters, [
HostFunctionParameter(value='AAAAEgAAAAGw7oy+G8a9SeTIE5E/EuJYl5JfwF0eZJWk8S7LmE7fwA==', type='Address'),
HostFunctionParameter(value='AAAADwAAAAh0cmFuc2Zlcg==', type='Sym'),
HostFunctionParameter(value='AAAAEgAAAAAAAAAAwT6e0zIpycpZ5/unUFyQAjXNeSxfmidj8tQWkeD9dCQ=', type='Address'),
HostFunctionParameter(value='AAAAEgAAAAAAAAAAWLfEosjyl6qPPSRxKB/fzOyv5I5WYzE+wY4Spz7KmKE=', type='Address'),
HostFunctionParameter(value='AAAACgAAAAAAAAAAAAAAASoF8gA=', type='I128')])
self.assertEqual(
parsed_data.function, "HostFunctionTypeHostFunctionTypeInvokeContract"
)
self.assertEqual(
parsed_data.parameters,
[
HostFunctionParameter(
value="AAAAEgAAAAGw7oy+G8a9SeTIE5E/EuJYl5JfwF0eZJWk8S7LmE7fwA==",
type="Address",
),
HostFunctionParameter(value="AAAADwAAAAh0cmFuc2Zlcg==", type="Sym"),
HostFunctionParameter(
value="AAAAEgAAAAAAAAAAwT6e0zIpycpZ5/unUFyQAjXNeSxfmidj8tQWkeD9dCQ=",
type="Address",
),
HostFunctionParameter(
value="AAAAEgAAAAAAAAAAWLfEosjyl6qPPSRxKB/fzOyv5I5WYzE+wY4Spz7KmKE=",
type="Address",
),
HostFunctionParameter(
value="AAAACgAAAAAAAAAAAAAAASoF8gA=", type="I128"
),
],
)
self.assertEqual(parsed_data.address, "")
self.assertEqual(parsed_data.salt, "")
self.assertEqual(parsed_data.asset_balance_changes, [
AssetContractBalanceChange(asset_type='credit_alphanum12', asset_code='Hello',
asset_issuer='GDJKBIYIPBE2NC5XIZX6GCFZHVWFUA7ONMQUOOVTLIM3BESTI4BYADAN',
type='transfer',
from_='GDAT5HWTGIU4TSSZ4752OUC4SABDLTLZFRPZUJ3D6LKBNEPA7V2CIG54',
to='GBMLPRFCZDZJPKUPHUSHCKA737GOZL7ERZLGGMJ6YGHBFJZ6ZKMKCZTM',
amount=Decimal(500))])
self.assertEqual(
parsed_data.asset_balance_changes,
[
AssetContractBalanceChange(
asset_type="credit_alphanum12",
asset_code="Hello",
asset_issuer="GDJKBIYIPBE2NC5XIZX6GCFZHVWFUA7ONMQUOOVTLIM3BESTI4BYADAN",
type="transfer",
from_="GDAT5HWTGIU4TSSZ4752OUC4SABDLTLZFRPZUJ3D6LKBNEPA7V2CIG54",
to="GBMLPRFCZDZJPKUPHUSHCKA737GOZL7ERZLGGMJ6YGHBFJZ6ZKMKCZTM",
amount=Decimal(500),
)
],
)

0 comments on commit 595e9bd

Please sign in to comment.