• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

safe-global / safe-eth-py / 10527345804

23 Aug 2024 02:20PM UTC coverage: 93.892% (-0.01%) from 93.903%
10527345804

push

github

web-flow
Add addresses 1.4.1 for chain BEVM_TESTNET (#1297)

* Add new master copy address 0x41675C099F32341bf84BFc5382aF534df5C7461a

* Add new master copy address 0x29fcB43b46531BcA003ddC8FCB67FFE91900C762

* Add new proxy address 0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67

* Apply linter fixes

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

8670 of 9234 relevant lines covered (93.89%)

3.76 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

28.21
/gnosis/eth/tests/oracles/test_cowswap.py
1
from unittest import mock
4✔
2

3
from django.test import TestCase
4✔
4

5
import pytest
4✔
6
from eth_account import Account
4✔
7
from requests import Session
4✔
8

9
from ... import EthereumClient
4✔
10
from ...oracles import CannotGetPriceFromOracle, CowswapOracle
4✔
11
from ..ethereum_test_case import EthereumTestCaseMixin
4✔
12
from ..test_oracles import (
4✔
13
    dai_token_mainnet_address,
14
    usdc_token_mainnet_address,
15
    usdt_token_mainnet_address,
16
    weth_token_mainnet_address,
17
)
18
from ..utils import just_test_if_mainnet_node
4✔
19

20

21
@pytest.skip("Having issues often", allow_module_level=True)
4✔
22
class TestCowswapOracle(EthereumTestCaseMixin, TestCase):
×
23
    def test_get_price(self):
×
24
        mainnet_node = just_test_if_mainnet_node()
×
25
        ethereum_client = EthereumClient(mainnet_node)
×
26

27
        self.assertTrue(CowswapOracle.is_available(ethereum_client))
×
28

29
        cowswap_oracle = CowswapOracle(ethereum_client)
×
30

31
        price = cowswap_oracle.get_price(weth_token_mainnet_address)
×
32
        self.assertEqual(price, 1.0)
×
33

34
        price = cowswap_oracle.get_price(dai_token_mainnet_address)
×
35
        self.assertLess(price, 1)
×
36
        self.assertGreater(price, 0)
×
37

38
        price = cowswap_oracle.get_price(
×
39
            weth_token_mainnet_address, dai_token_mainnet_address
40
        )
41
        self.assertGreater(price, 1)
×
42

43
        # Test with 2 stablecoins with same decimals
44
        price = cowswap_oracle.get_price(
×
45
            usdt_token_mainnet_address, usdc_token_mainnet_address
46
        )
47
        self.assertAlmostEqual(price, 1.0, delta=0.5)
×
48

49
        # Test with 2 stablecoins with different decimals
50
        price = cowswap_oracle.get_price(
×
51
            dai_token_mainnet_address, usdc_token_mainnet_address
52
        )
53
        self.assertAlmostEqual(price, 1.0, delta=0.5)
×
54

55
        price = cowswap_oracle.get_price(
×
56
            usdc_token_mainnet_address, dai_token_mainnet_address
57
        )
58
        self.assertAlmostEqual(price, 1.0, delta=0.5)
×
59

60
        with mock.patch.object(
×
61
            Session, "post", side_effect=IOError("Connection Error")
62
        ):
63
            with self.assertRaises(CannotGetPriceFromOracle):
×
64
                cowswap_oracle.get_price(
×
65
                    usdc_token_mainnet_address, dai_token_mainnet_address
66
                )
67

68
        random_token = Account.create().address
×
69
        with self.assertRaisesMessage(
×
70
            CannotGetPriceFromOracle,
71
            f"Cannot get decimals for token={random_token}",
72
        ):
73
            cowswap_oracle.get_price(random_token)
×
74

75
        with mock.patch(
×
76
            "gnosis.eth.oracles.cowswap.get_decimals", autospec=True, return_value=18
77
        ):
78
            with self.assertRaises(CannotGetPriceFromOracle):
×
79
                cowswap_oracle.get_price(random_token)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc