oceanprotocol / df-py

veOCEAN & Data Farming backend
Apache License 2.0
3 stars 10 forks source link

test_calcrewards.py failing #163

Closed trentmc closed 2 years ago

trentmc commented 2 years ago

Running this command

brownie test util/test/test_calcrewards.py

Gives the following errors locally:

FAILED util/test/test_calcrewards.py::test_stakesToUsd_two_approved_one_nonapproved - AssertionError: assert {8996: {'pool..._addr': 2.0}}} == {8996: {'pool...00000000001}}}
FAILED util/test/test_calcrewards.py::test_stakesToUsd_twobasetokens - AssertionError: assert {8996: {'pool..._addr': 2.0}}} == {8996: {'pool...00000000001}}}
FAILED util/test/test_calcrewards.py::test_poolvolsToUsd_two_approved_one_nonapproved - AssertionError: assert {8996: {'pool...b_addr': 5.5}} == {8996: {'pool..._addr': 20.8}}
FAILED util/test/test_calcrewards.py::test_poolvolsToUsd_twobasetokens - AssertionError: assert {8996: {'pool...b_addr': 5.5}} == {8996: {'pool..._addr': 20.8}}

And in a remote CI run, I got even more errors:

=========================== short test summary info ============================
ERROR util/test/test_calcrewards.py::test_calcRewards1_onechain - Exception: ...
ERROR util/test/test_calcrewards.py::test_calcRewards1_twochains - Exception:...
ERROR util/test/test_calcrewards.py::test_calcRewards2 - Exception: No approv...
ERROR util/test/test_calcrewards.py::test_calcRewards3 - Exception: No approv...
ERROR util/test/test_calcrewards.py::test_calcRewards4 - Exception: No approv...
ERROR util/test/test_calcrewards.py::test_calcRewards5_mix_upper_and_lower_case
ERROR util/test/test_calcrewards.py::test_calcrewards_math - Exception: No ap...
ERROR util/test/test_calcrewards.py::test_apy_cap - Exception: No approved to...
ERROR util/test/test_calcrewards.py::test_stakesToUsd_onebasetoken - Exceptio...
ERROR util/test/test_calcrewards.py::test_stakesToUsd_nonapprovedtoken - Exce...
ERROR util/test/test_calcrewards.py::test_stakesToUsd_two_approved_one_nonapproved
ERROR util/test/test_calcrewards.py::test_stakesToUsd_twobasetokens - Excepti...
ERROR util/test/test_calcrewards.py::test_poolvolsToUsd_onebasetoken - Except...
ERROR util/test/test_calcrewards.py::test_poolvolsToUsd_nonapprovedtoken - Ex...
ERROR util/test/test_calcrewards.py::test_poolvolsToUsd_two_approved_one_nonapproved
ERROR util/test/test_calcrewards.py::test_poolvolsToUsd_twobasetokens - Excep...

Detailed output of local test:

(venv) trentmc@trentmc-xps:~/code/df-py$ brownie test util/test/test_calcrewards.py
Brownie v1.19.0 - Python development framework for Ethereum

========================================================================================================= test session starts =========================================================================================================
platform linux -- Python 3.10.4, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /home/trentmc/code/df-py
plugins: eth-brownie-1.19.0, forked-1.4.0, xdist-1.34.0, hypothesis-6.27.3, web3-5.29.1
collected 16 items                                                                                                                                                                                                                    
Attached to local RPC client listening at '127.0.0.1:8545'...

util/test/test_calcrewards.py .s........FF..FF                                                                                                                                                                                  [100%]

============================================================================================================== FAILURES ===============================================================================================================
____________________________________________________________________________________________ test_stakesToUsd_two_approved_one_nonapproved ____________________________________________________________________________________________

    @enforce_types
    def test_stakesToUsd_two_approved_one_nonapproved():
        nonApprovedToken = _deployTOK(accounts[0])
        nonApprovedTokenAddr = nonApprovedToken.address.lower()

        stakes = {
            C1: {
                nonApprovedTokenAddr: {PA: {LP1: 3.0, LP2: 4.0}},
                OCN: {PA: {LP1: 3.0, LP2: 4.0}},
                H2O: {PC: {LP1: 5.0, LP4: 6.0}},
            }
        }
        stakes_USD = _stakesToUsd(stakes, RATES)
>       assert stakes_USD == {
            C1: {
                PA: {LP1: 3.0 * 0.5, LP2: 4.0 * 0.5},
                PC: {LP1: 5.0 * 1.6, LP4: 6.0 * 1.6},
            }
        }
E       AssertionError: assert {8996: {'pool..._addr': 2.0}}} == {8996: {'pool...00000000001}}}
E         Differing items:
E         {8996: {'poola_addr': {'lp1_addr': 1.5, 'lp2_addr': 2.0}}} != {8996: {'poola_addr': {'lp1_addr': 1.5, 'lp2_addr': 2.0}, 'poolc_addr': {'lp1_addr': 8.0, 'lp4_addr': 9.600000000000001}}}
E         Use -v to get the full diff

util/test/test_calcrewards.py:217: AssertionError
___________________________________________________________________________________________________ test_stakesToUsd_twobasetokens ____________________________________________________________________________________________________

    @enforce_types
    def test_stakesToUsd_twobasetokens():
        stakes = {
            C1: {
                OCN: {PA: {LP1: 3.0, LP2: 4.0}},
                H2O: {PC: {LP1: 5.0, LP4: 6.0}},
            }
        }
        stakes_USD = _stakesToUsd(stakes, RATES)
>       assert stakes_USD == {
            C1: {
                PA: {LP1: 3.0 * 0.5, LP2: 4.0 * 0.5},
                PC: {LP1: 5.0 * 1.6, LP4: 6.0 * 1.6},
            }
        }
E       AssertionError: assert {8996: {'pool..._addr': 2.0}}} == {8996: {'pool...00000000001}}}
E         Differing items:
E         {8996: {'poola_addr': {'lp1_addr': 1.5, 'lp2_addr': 2.0}}} != {8996: {'poola_addr': {'lp1_addr': 1.5, 'lp2_addr': 2.0}, 'poolc_addr': {'lp1_addr': 8.0, 'lp4_addr': 9.600000000000001}}}
E         Use -v to get the full diff

util/test/test_calcrewards.py:234: AssertionError
___________________________________________________________________________________________ test_poolvolsToUsd_two_approved_one_nonapproved ___________________________________________________________________________________________

    @enforce_types
    def test_poolvolsToUsd_two_approved_one_nonapproved():
        nonApprovedToken = _deployTOK(accounts[0])
        nonApprovedTokenAddr = nonApprovedToken.address.lower()
        poolvols = {
            C1: {OCN: {PA: 9.0, PB: 11.0}, H2O: {PC: 13.0}, nonApprovedTokenAddr: {PC: 100}}
        }
        poolvols_USD = _poolvolsToUsd(poolvols, RATES)
>       assert poolvols_USD == {
            C1: {
                PA: 9.0 * 0.5,
                PB: 11.0 * 0.5,
                PC: 13.0 * 1.6,
            }
        }
E       AssertionError: assert {8996: {'pool...b_addr': 5.5}} == {8996: {'pool..._addr': 20.8}}
E         Differing items:
E         {8996: {'poola_addr': 4.5, 'poolb_addr': 5.5}} != {8996: {'poola_addr': 4.5, 'poolb_addr': 5.5, 'poolc_addr': 20.8}}
E         Use -v to get the full diff

util/test/test_calcrewards.py:266: AssertionError
__________________________________________________________________________________________________ test_poolvolsToUsd_twobasetokens ___________________________________________________________________________________________________

    @enforce_types
    def test_poolvolsToUsd_twobasetokens():
        poolvols = {C1: {OCN: {PA: 9.0, PB: 11.0}, H2O: {PC: 13.0}}}
        poolvols_USD = _poolvolsToUsd(poolvols, RATES)
>       assert poolvols_USD == {
            C1: {
                PA: 9.0 * 0.5,
                PB: 11.0 * 0.5,
                PC: 13.0 * 1.6,
            }
        }
E       AssertionError: assert {8996: {'pool...b_addr': 5.5}} == {8996: {'pool..._addr': 20.8}}
E         Differing items:
E         {8996: {'poola_addr': 4.5, 'poolb_addr': 5.5}} != {8996: {'poola_addr': 4.5, 'poolb_addr': 5.5, 'poolc_addr': 20.8}}
E         Use -v to get the full diff

util/test/test_calcrewards.py:279: AssertionError
========================================================================================================== warnings summary ===========================================================================================================
venv/lib/python3.10/site-packages/brownie/network/main.py:44
  /home/trentmc/code/df-py/venv/lib/python3.10/site-packages/brownie/network/main.py:44: BrownieEnvironmentWarning: Development network has a block height of 1058
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/warnings.html
======================================================================================================= short test summary info =======================================================================================================
FAILED util/test/test_calcrewards.py::test_stakesToUsd_two_approved_one_nonapproved - AssertionError: assert {8996: {'pool..._addr': 2.0}}} == {8996: {'pool...00000000001}}}
FAILED util/test/test_calcrewards.py::test_stakesToUsd_twobasetokens - AssertionError: assert {8996: {'pool..._addr': 2.0}}} == {8996: {'pool...00000000001}}}
FAILED util/test/test_calcrewards.py::test_poolvolsToUsd_two_approved_one_nonapproved - AssertionError: assert {8996: {'pool...b_addr': 5.5}} == {8996: {'pool..._addr': 20.8}}
FAILED util/test/test_calcrewards.py::test_poolvolsToUsd_twobasetokens - AssertionError: assert {8996: {'pool...b_addr': 5.5}} == {8996: {'pool..._addr': 20.8}}
========================================================================================= 4 failed, 11 passed, 1 skipped, 1 warning in 51.00s =========================================================================================
trizin commented 2 years ago

CI tests failing due to https://github.com/oceanprotocol/ocean-subgraph/issues/465