Skip to content

Commit

Permalink
test: fix VeSugar + RelaySugar tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ethzoomer committed Jan 15, 2024
1 parent 2339bcc commit 7e66054
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 28 deletions.
6 changes: 3 additions & 3 deletions env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ REGISTRY_ADDRESS=0xF4c67CdEAaB8360370F41514d06e32CcD8aA1d7B
DIST_ADDRESS=0x9D4736EC60715e71aFe72973f7885DCBC21EA99b
CONVERTOR_ADDRESS=0x585Af0b397AC42dbeF7f18395426BF878634f18D
LP_SUGAR_ADDRESS=0x6eDCAb198EAdDBDA3865f813A83F6bC9012F16e9
VE_SUGAR_ADDRESS=0x0eCc2593E3a6A9be3628940Fa4D928CC257B588B
RELAY_SUGAR_ADDRESS=0x7f609cf1a99318652859aED5B00C7F5F187E0077
RELAY_REGISTRY_ADDRESS=0xBC3dc970f891ffdd3049FA3a649985CC6626d486
VE_SUGAR_ADDRESS=0x37403dBd6f1b583ea244F7956fF9e37EF45c63eB
RELAY_SUGAR_ADDRESS=0x062185EEF2726EFc11880856CD356FA2Ac2B38Ff
RELAY_REGISTRY_ADDRESS=0xe9F00f2e61CB0c6fb00A2e457546aCbF0fC303C2
7 changes: 4 additions & 3 deletions tests/test_relay_sugar.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ def RelayStruct(sugar_contract):

def test_initial_state(sugar_contract):
assert sugar_contract.voter() == os.getenv('VOTER_ADDRESS')
assert sugar_contract.registry() == \
os.getenv('RELAY_REGISTRY_ADDRESS')
assert sugar_contract.registries(0) == os.getenv('RELAY_REGISTRY_ADDRESS')
assert sugar_contract.ve() is not None
assert sugar_contract.token() is not None


def test_all(sugar_contract, RelayStruct):
Expand All @@ -33,4 +34,4 @@ def test_all(sugar_contract, RelayStruct):
sugar_contract.all(ADDRESS_ZERO)
))

assert relays is not None
assert len(relays) > 5
26 changes: 4 additions & 22 deletions tests/test_ve_sugar.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ def sugar_contract(VeSugar, accounts):
yield VeSugar.at(os.getenv('VE_SUGAR_ADDRESS'))


@pytest.fixture
def RewardStruct(sugar_contract):
method_output = sugar_contract.rewards.abi['outputs'][0]
members = list(map(lambda _e: _e['name'], method_output['components']))

yield namedtuple('RewardStruct', members)


@pytest.fixture
def VeNFTStruct(sugar_contract):
method_output = sugar_contract.byId.abi['outputs'][0]
Expand All @@ -30,20 +22,19 @@ def VeNFTStruct(sugar_contract):

def test_initial_state(sugar_contract):
assert sugar_contract.voter() == os.getenv('VOTER_ADDRESS')
assert sugar_contract.rewards_distributor() == \
os.getenv('REWARDS_DIST_ADDRESS')
assert sugar_contract.dist() == \
os.getenv('DIST_ADDRESS')
assert sugar_contract.ve() is not None


def test_byId(sugar_contract, VeNFTStruct):
venft = VeNFTStruct(*sugar_contract.byId(1))

assert venft is not None
assert len(venft) == 11
assert len(venft) == 13
assert venft.id is not None
assert len(venft.votes) > 0
assert venft.voted_at > 0
assert venft.attachments > 0


def test_byAccount(sugar_contract, VeNFTStruct):
Expand All @@ -54,7 +45,7 @@ def test_byAccount(sugar_contract, VeNFTStruct):
))

assert venft is not None
assert len(venft) == 11
assert len(venft) == 13
assert venft.account == acc_venft[0].account


Expand Down Expand Up @@ -92,12 +83,3 @@ def test_all_limit_offset(sugar_contract, VeNFTStruct):

assert venft1.id == second_venft.id
assert venft1.account == second_venft.account


def test_rewards(sugar_contract, RewardStruct):
rewards = list(map(
lambda _r: RewardStruct(*_r),
sugar_contract.rewards(100, 0, 1)
))

assert len(rewards) > 0

0 comments on commit 7e66054

Please sign in to comment.