Skip to content

Commit

Permalink
Misc test fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
calina-c committed Aug 3, 2023
1 parent 085a8d7 commit 616b0dd
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 24 deletions.
3 changes: 0 additions & 3 deletions READMEs/setup-remote.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,6 @@ ocean = Ocean(config)
OCEAN = ocean.OCEAN_token
# Create Alice's wallet
from brownie.network import accounts
accounts.clear()
alice_private_key = os.getenv('REMOTE_TEST_PRIVATE_KEY1')
alice = accounts.add(alice_private_key)
assert alice.balance() > 0, "Alice needs MATIC"
Expand Down
2 changes: 1 addition & 1 deletion conftest_ganache.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def setup_all(request, config, ocean_token):
assert balance >= to_wei(10), "Need more ETH"

amt_distribute = to_wei(1000)
ocean_token.mint(wallet, to_wei(2000), {"from": wallet.address})
ocean_token.mint(wallet, to_wei(2000), {"from": wallet})

for w in (get_publisher_wallet(), get_consumer_wallet()):
balance = config["web3_instance"].eth.get_balance(w.address)
Expand Down
6 changes: 1 addition & 5 deletions ocean_lib/ocean/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ def str_with_wei(amt_wei: int) -> str:

@enforce_types
def get_from_address(tx_dict: dict) -> str:
address = (
tx_dict["from"].address
if hasattr(tx_dict["from"], "address")
else tx_dict["from"]
)
address = tx_dict["from"].address

return Web3.toChecksumAddress(address.lower())

Expand Down
18 changes: 11 additions & 7 deletions ocean_lib/web3_internal/contract_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
logger = logging.getLogger(__name__)


# TODO: cleanup
def function_wrapper(contract, web3, contract_functions, func_name):
if hasattr(contract, func_name):
return getattr(contract, func_name)
Expand Down Expand Up @@ -49,14 +50,17 @@ def wrap(*args, **kwargs):
return result.call()
else:
wallet = tx_dict["from"]
tx_dict["nonce"] = web3.eth.get_transaction_count(wallet.address)
tx_dict["from"] = (
tx_dict["from"].address
if hasattr(tx_dict["from"], "address")
else tx_dict["from"]
)
tx_dict2 = tx_dict.copy()
tx_dict2["nonce"] = web3.eth.get_transaction_count(wallet.address)

tx_dict2["from"] = tx_dict["from"].address

if "gasPrice" in tx_dict:
tx_dict2["gasPrice"] = tx_dict["gasPrice"]
else:
tx_dict2["gasPrice"] = int(web3.eth.gas_price * 1.1)

result = result.build_transaction(tx_dict)
result = result.build_transaction(tx_dict2)
signed_tx = web3.eth.account.sign_transaction(result, wallet.privateKey)
receipt = web3.eth.send_raw_transaction(signed_tx.rawTransaction)

Expand Down
3 changes: 0 additions & 3 deletions tests/integration/remote/test_mumbai_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Copyright 2023 Ocean Protocol Foundation
# SPDX-License-Identifier: Apache-2.0
#
from brownie.network import accounts

from ocean_lib.example_config import get_config_dict
from ocean_lib.ocean.ocean import Ocean
Expand All @@ -17,7 +16,6 @@ def test_nonocean_tx(tmp_path, monkeypatch):

config = get_config_dict("mumbai")
ocean = Ocean(config)
accounts.clear()
(alice_wallet, bob_wallet) = util.get_wallets()

# Do a simple-as-possible test that uses ocean stack, while accounting for gotchas
Expand All @@ -32,7 +30,6 @@ def test_ocean_tx__create(tmp_path, monkeypatch):
config = get_config_dict("mumbai")
ocean = Ocean(config)

accounts.clear()
(alice_wallet, _) = util.get_wallets()

# Do a simple-as-possible test that uses ocean stack, while accounting for gotchas
Expand Down
4 changes: 1 addition & 3 deletions tests/integration/remote/test_mumbai_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@
import pathlib
import runpy

from brownie.network import accounts

from . import util


def test_simple_remote_readme(monkeypatch):
monkeypatch.delenv("ADDRESS_FILE")
accounts.clear()
(ref_alice_wallet, _) = util.get_wallets()

# README generation command:
Expand All @@ -27,6 +24,7 @@ def test_simple_remote_readme(monkeypatch):
if "Alice needs MATIC" in str(e) or "Bob needs MATIC" in str(e):
return
raise (e)

ocean = result["ocean"]
alice = result["alice"]

Expand Down
2 changes: 0 additions & 2 deletions tests/integration/remote/test_polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# SPDX-License-Identifier: Apache-2.0
#
import pytest
from brownie.network import accounts

from ocean_lib.example_config import get_config_dict
from ocean_lib.ocean.ocean import Ocean
Expand All @@ -20,7 +19,6 @@ def test_ocean_tx__create(tmp_path, monkeypatch):
config = get_config_dict("polygon")
ocean = Ocean(config)

accounts.clear()
(alice_wallet, _) = util.get_wallets()

# Do a simple-as-possible test that uses ocean stack, while accounting for gotchas
Expand Down

0 comments on commit 616b0dd

Please sign in to comment.