From 41586171bc99092cd0cefd74cee4c012d6c774e7 Mon Sep 17 00:00:00 2001 From: Pedro Valido <80268365+pedrovalido@users.noreply.github.com> Date: Sun, 6 Oct 2024 14:42:57 +0100 Subject: [PATCH] chore: fix nits and tests --- .github/workflows/ci.yml | 2 +- env.example | 15 +++++++++------ scripts/deploy.py | 2 +- tests/base/test_lp_sugar.py | 6 ++---- tests/base/test_ve_sugar.py | 3 +-- tests/optimism/test_relay_sugar.py | 2 +- tests/test_factory_registry.py | 11 +++++++---- 7 files changed, 22 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a906e6..db66c16 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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' diff --git a/env.example b/env.example index 7acdac0..b9968e0 100644 --- a/env.example +++ b/env.example @@ -1,8 +1,3 @@ -# For testing purposes -TEST_FACTORY_ADDRESS=0xCc0bDDB707055e04e497aB22a59c2aF4391cd12F -TEST_ADDRESS=0xEeE7FB850D28f5cabd5f1EDF540646b5bEA17CE5 -TEST_ALM_ADDRESS=0x892Ff98a46e5bd141E2D12618f4B2Fe6284debac - CHAIN_ID=10 CONTRACT='lp' @@ -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 @@ -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 diff --git a/scripts/deploy.py b/scripts/deploy.py index bfbb528..f93e89c 100644 --- a/scripts/deploy.py +++ b/scripts/deploy.py @@ -37,7 +37,7 @@ def main(): os.getenv(f'VOTER_{chain_id}'), {'from': account} ) - + if 'registry' in contract_name: FactoryRegistry.deploy( account, diff --git a/tests/base/test_lp_sugar.py b/tests/base/test_lp_sugar.py index e8c4e15..cc82ccb 100644 --- a/tests/base/test_lp_sugar.py +++ b/tests/base/test_lp_sugar.py @@ -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 @@ -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, []) @@ -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): diff --git a/tests/base/test_ve_sugar.py b/tests/base/test_ve_sugar.py index 071fdc9..81ef098 100644 --- a/tests/base/test_ve_sugar.py +++ b/tests/base/test_ve_sugar.py @@ -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 @@ -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 diff --git a/tests/optimism/test_relay_sugar.py b/tests/optimism/test_relay_sugar.py index 7620582..ed5ff41 100644 --- a/tests/optimism/test_relay_sugar.py +++ b/tests/optimism/test_relay_sugar.py @@ -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 diff --git a/tests/test_factory_registry.py b/tests/test_factory_registry.py index f75c14d..119166b 100644 --- a/tests/test_factory_registry.py +++ b/tests/test_factory_registry.py @@ -1,7 +1,7 @@ import os import pytest -from brownie import accounts, FactoryRegistry, reverts +from web3.constants import ADDRESS_ZERO @pytest.fixture @@ -9,13 +9,14 @@ 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() @@ -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" @@ -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]