Skip to content

Commit

Permalink
chore: fix nits and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrovalido committed Oct 6, 2024
1 parent 14a7663 commit 4158617
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
- name: Runs code QA and tests for base
run: docker run --rm --env-file=env.example -v $(pwd):/app -w /app -t velodrome/sugar sh -c 'flake8 && brownie test tests/base/**.py --network=base-main'
- name: Runs code QA and sugar factory registry tests
run: docker run --rm --env-file=env.example -v $(pwd):/app -w /app -t velodrome/sugar sh -c 'flake8 && brownie test tests/test_factory_registry.py'
run: docker run --rm --env-file=env.example -v $(pwd):/app -w /app -t velodrome/sugar sh -c 'flake8 && brownie test tests/test_factory_registry.py --network=mode-main'
15 changes: 9 additions & 6 deletions env.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# For testing purposes
TEST_FACTORY_ADDRESS=0xCc0bDDB707055e04e497aB22a59c2aF4391cd12F
TEST_ADDRESS=0xEeE7FB850D28f5cabd5f1EDF540646b5bEA17CE5
TEST_ALM_ADDRESS=0x892Ff98a46e5bd141E2D12618f4B2Fe6284debac

CHAIN_ID=10
CONTRACT='lp'

Expand All @@ -16,6 +11,10 @@ DIST_10=0x9D4736EC60715e71aFe72973f7885DCBC21EA99b
RELAY_REGISTRY_ADDRESSES_10=0xe9F00f2e61CB0c6fb00A2e457546aCbF0fC303C2,0x6b1253B116B5919932399295C75116d33F8EfF96
GOVERNOR_10=0x1F82e10D58aEf03DeA2e478029fB0387A1cbE989

TEST_FACTORY_ADDRESS_10=0xCc0bDDB707055e04e497aB22a59c2aF4391cd12F
TEST_ADDRESS_10=0xEeE7FB850D28f5cabd5f1EDF540646b5bEA17CE5
TEST_ALM_ADDRESS_10=0x892Ff98a46e5bd141E2D12618f4B2Fe6284debac

LP_SUGAR_ADDRESS_10=0x0937DA94887472239Ada5483c6DBd2904FfD4ACF
VE_SUGAR_ADDRESS_10=0x94f913362b232e31daB49a1aFB775cfd25DaA6a1
RELAY_SUGAR_ADDRESS_10=0xb8307e5842B9aeE75C704183F0355076aa74b4e2
Expand All @@ -30,13 +29,17 @@ DIST_8453=0x227f65131A261548b057215bB1D5Ab2997964C7d
RELAY_REGISTRY_ADDRESSES_8453=0x05e41604B9463e2224227053980dfF3f57fb6dB5,0xD308aBCe663302d3b86b36d332CEFd8A4F62C5Ed
GOVERNOR_8453=0x94C012A23A8A65A6f40608dA30534a46a433F410

TEST_FACTORY_ADDRESS_8453=0x5e7BB104d84c7CB9B682AaC2F3d509f5F406809A
TEST_ADDRESS_8453=0xEeE7FB850D28f5cabd5f1EDF540646b5bEA17CE5
TEST_ALM_ADDRESS_8453=0x892Ff98a46e5bd141E2D12618f4B2Fe6284debac

LP_SUGAR_ADDRESS_8453=0x51f290CCCD6a54Af00b38edDd59212dE068B8A4b
VE_SUGAR_ADDRESS_8453=0x4c5d3925fe65DFeB5A079485136e4De09cb664A5
RELAY_SUGAR_ADDRESS_8453=0x8932B5FE23C07Df06533F8f09E43e7cca6a24143

#MODE
VOTER_34443=0x0000000000000000000000000000000000000000
REGISTRY_34443=0x7e9f5D93C590c45A54faC774baf9AdD6CA94a295
REGISTRY_34443=0xeFFa2e499309db6FEb3868B52AB0889b0D7825ec
CONVERTOR_34443=0x1111111111111111111111111111111111111111
SLIPSTREAM_HELPER_34443=0x0000000000000000000000000000000000000000
ALM_FACTORY_34443=0x0000000000000000000000000000000000000000
Expand Down
2 changes: 1 addition & 1 deletion scripts/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def main():
os.getenv(f'VOTER_{chain_id}'),
{'from': account}
)

if 'registry' in contract_name:
FactoryRegistry.deploy(
account,
Expand Down
6 changes: 2 additions & 4 deletions tests/base/test_lp_sugar.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def test_forSwaps(sugar_contract, SwapLpStruct, LpStruct):
second_lp = LpStruct(*sugar_contract.byIndex(1))
swap_lps = list(map(
lambda _p: SwapLpStruct(*_p),
sugar_contract.forSwaps(10, 1)
sugar_contract.forSwaps(10, 0)
))

assert swap_lps is not None
Expand All @@ -96,7 +96,6 @@ def test_forSwaps(sugar_contract, SwapLpStruct, LpStruct):

def test_tokens(sugar_contract, TokenStruct, LpStruct):
first_lp = LpStruct(*sugar_contract.byIndex(0))
second_lp = LpStruct(*sugar_contract.byIndex(1))
tokens = list(map(
lambda _p: TokenStruct(*_p),
sugar_contract.tokens(10, 0, ADDRESS_ZERO, [])
Expand All @@ -105,14 +104,13 @@ def test_tokens(sugar_contract, TokenStruct, LpStruct):
assert tokens is not None
assert len(tokens) > 1

token0, token1, token2 = tokens[0: 3]
token0, token1 = tokens[0: 2]

assert token0.token_address == first_lp.token0
assert token0.symbol is not None
assert token0.decimals > 0

assert token1.token_address == first_lp.token1
assert token2.token_address == second_lp.token0


def test_all(sugar_contract, LpStruct):
Expand Down
3 changes: 1 addition & 2 deletions tests/base/test_ve_sugar.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def VeNFTStruct(sugar_contract):


def test_initial_state(sugar_contract):
assert sugar_contract.voter() == os.getenv('VOTER_8453'))
assert sugar_contract.voter() == os.getenv('VOTER_8453')
assert sugar_contract.dist() == \
os.getenv('DIST_8453')
assert sugar_contract.ve() is not None
Expand All @@ -33,7 +33,6 @@ def test_byId(sugar_contract, VeNFTStruct):
assert venft is not None
assert len(venft) == 14
assert venft.id is not None
assert len(venft.votes) > 0
assert venft.voted_at > 0


Expand Down
2 changes: 1 addition & 1 deletion tests/optimism/test_relay_sugar.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def RelayStruct(sugar_contract):
def test_initial_state(sugar_contract):
assert sugar_contract.voter() == os.getenv('VOTER_10')
assert sugar_contract.registries(0) == \
os.getenv('RELAY_REGISTRY_ADDRESSES').split(',')[0]
os.getenv('RELAY_REGISTRY_ADDRESSES_10').split(',')[0]
assert sugar_contract.ve() is not None
assert sugar_contract.token() is not None

Expand Down
11 changes: 7 additions & 4 deletions tests/test_factory_registry.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import os
import pytest

from brownie import accounts, FactoryRegistry, reverts
from web3.constants import ADDRESS_ZERO


@pytest.fixture
def factory_registry(FactoryRegistry, accounts):
# Deploy the contract using the first test account as the owner
yield FactoryRegistry.at(os.getenv('REGISTRY_34443'))


def test_initial_state(factory_registry):
assert factory_registry.owner() == "0xd42C7914cF8dc24a1075E29C283C581bd1b0d3D3"
assert factory_registry.owner() ==\
"0xd42C7914cF8dc24a1075E29C283C581bd1b0d3D3"


def test_approve(factory_registry, accounts):
owner = factory_registry.owner()
non_owner = "0x9999999999999999999999999999999999999999"
pool_factory = "0x1111111111111111111111111111111111111111"
pool_factory_count = factory_registry.pool_factory_count()

Expand All @@ -25,6 +26,7 @@ def test_approve(factory_registry, accounts):
assert factory_registry.poolFactories(0) == pool_factory
assert factory_registry.pool_factory_exists(pool_factory)


def test_unapprove(factory_registry, accounts):
owner = factory_registry.owner()
pool_factory = "0x1111111111111111111111111111111111111111"
Expand All @@ -40,7 +42,8 @@ def test_unapprove(factory_registry, accounts):
assert factory_registry.pool_factory_count() == pool_factory_count
assert not factory_registry.pool_factory_exists(pool_factory)


def test_factories_to_pool_factory(factory_registry):
pool_factory = "0x1111111111111111111111111111111111111111"
result = factory_registry.factoriesToPoolFactory(pool_factory)
assert result == ("0x0000000000000000000000000000000000000000", pool_factory)
assert result == [ADDRESS_ZERO, pool_factory]

0 comments on commit 4158617

Please sign in to comment.