Skip to content

Commit

Permalink
Fix #1241 - 'Ocean' object has no attribute 'OCEAN_ocean' (#1242)
Browse files Browse the repository at this point in the history
Fixes #1241

Changes proposed in this PR:

- Fix the bug
- Add relevant test
- Add related tests, for thoroughness
  • Loading branch information
trentmc authored Dec 26, 2022
1 parent b95f22d commit 91168e7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 18 deletions.
2 changes: 1 addition & 1 deletion ocean_lib/ocean/ocean.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def OCEAN_token(self) -> Datatoken:
@property
@enforce_types
def OCEAN(self): # alias for OCEAN_token
return self.OCEAN_ocean
return self.OCEAN_token

# ======================================================================
# objects for singleton smart contracts
Expand Down
53 changes: 36 additions & 17 deletions ocean_lib/ocean/test/test_ocean.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@
from ocean_lib.models.dispenser import Dispenser
from ocean_lib.models.factory_router import FactoryRouter
from ocean_lib.models.fixed_rate_exchange import FixedRateExchange
from ocean_lib.models.df.df_rewards import DFRewards
from ocean_lib.models.df.df_strategy_v1 import DFStrategyV1
from ocean_lib.models.ve.smart_wallet_checker import SmartWalletChecker
from ocean_lib.models.ve.ve_delegation import VeDelegation
from ocean_lib.models.ve.ve_delegation_proxy import VeDelegationProxy
from ocean_lib.models.ve.ve_fee_estimate import VeFeeEstimate
from ocean_lib.models.ve.ve_allocate import VeAllocate
from ocean_lib.models.ve.ve_fee_distributor import VeFeeDistributor
from ocean_lib.models.ve.ve_ocean import VeOcean

from tests.resources.helper_functions import deploy_erc721_erc20


Expand All @@ -20,25 +27,37 @@ def test_nft_factory(config, publisher_ocean, publisher_wallet):
data_nft, datatoken = deploy_erc721_erc20(
config, publisher_wallet, publisher_wallet
)
ocn = publisher_ocean
assert ocn.data_nft_factory
ocean = publisher_ocean
assert ocean.data_nft_factory

assert ocn.get_nft_token(data_nft.address).address == data_nft.address
assert ocn.get_datatoken(datatoken.address).address == datatoken.address
assert ocean.get_nft_token(data_nft.address).address == data_nft.address
assert ocean.get_datatoken(datatoken.address).address == datatoken.address


@pytest.mark.unit
def test_contract_objects(publisher_ocean):
ocn = publisher_ocean

assert ocn.OCEAN_address[:2] == "0x"
assert isinstance(ocn.OCEAN_token, Datatoken)
assert isinstance(ocn.data_nft_factory, DataNFTFactoryContract)

assert isinstance(ocn.dispenser, Dispenser)
assert isinstance(ocn.fixed_rate_exchange, FixedRateExchange)
assert isinstance(ocn.factory_router, FactoryRouter)

assert isinstance(ocn.ve_ocean, VeOcean)
assert isinstance(ocn.ve_allocate, VeAllocate)
assert isinstance(ocn.ve_fee_distributor, VeFeeDistributor)
ocean = publisher_ocean

assert ocean.OCEAN_address[:2] == "0x"
assert isinstance(ocean.OCEAN_token, Datatoken)
assert isinstance(ocean.OCEAN, Datatoken)
assert ocean.OCEAN_address == ocean.OCEAN_token.address
assert ocean.OCEAN_address == ocean.OCEAN.address

assert isinstance(ocean.data_nft_factory, DataNFTFactoryContract)
assert isinstance(ocean.dispenser, Dispenser)
assert isinstance(ocean.fixed_rate_exchange, FixedRateExchange)
assert isinstance(ocean.factory_router, FactoryRouter)

assert isinstance(ocean.df_rewards, DFRewards)
assert isinstance(ocean.df_strategy_v1, DFStrategyV1)
assert isinstance(ocean.smart_wallet_checker, SmartWalletChecker)
assert isinstance(ocean.ve_allocate, VeAllocate)
assert isinstance(ocean.ve_delegation, VeDelegation)
assert isinstance(ocean.ve_delegation_proxy, VeDelegationProxy)
assert isinstance(ocean.ve_fee_distributor, VeFeeDistributor)
assert isinstance(ocean.ve_fee_estimate, VeFeeEstimate)
assert isinstance(ocean.ve_ocean, VeOcean)
assert isinstance(ocean.veOCEAN, VeOcean)

assert ocean.config == ocean.config_dict # test alias

0 comments on commit 91168e7

Please sign in to comment.