-
-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tests fail with --coverage while they are 100% pass without --coverage #1777
Comments
Can you try again on 0.7 if possible? We have fixed some things, at least.. failing to get coverage on a tx should no longer cause the test to fail anyway. |
I've tested with this setup: Python 3.10.13 I upgraded the entire toolchain, deleted old python versions / libs like this Uninstalled then reinstalled all the ape plugins. Coverage is working and I no longer get the scenario where test fail with a non-owner/deployer account on a function that doesn't check for msg.sender at all. :-) |
Me again, reopening again :-) getting a did not revert using coverage while the test passes without coverage. Tried with the 0.7.1 version and also did a pip3 install git+ Bit of a peculiar error messages, depending if we have set a revert message or not in the # with a revert message:
with ape.reverts():
E AssertionError: Transaction did not revert.
E However, an exception of type <class 'OverflowError'> occurred: Python int too large to convert to C ssize_t.
# without a revert message
with ape.reverts():
E AssertionError: Transaction did not revert.
E However, an exception of type <class 'ape.exceptions.DecodingError'> occurred: Tried to read 32 bytes, only got 0 bytes.. It's checking denyList: HashMap[address, bool]
@view
@internal
def _denied() -> bool:
return self.denyList[msg.sender]
@view
@internal
def _checkAccess() -> bool:
assert not self._denied(), 'optional revert message'
# rest of checks I call an external function Running the tests without |
with -pdb I get some more hints
|
If you run with |
I think this is the relevant section, let me know if you need more details :-) with
and without
Interesting enough without coverage there's still (sort of) an error but it seems to pass the test. |
I am jus having trouble reproducing any of this :( Are you able to possible create a reproduction repo I can work off of? |
here is my example project, piecing together bits here to try and reproduce: https://github.com/antazoey/ape-playground/pull/3/files but the tests never fail, not even with |
The plot thickens: I am running the tests against shibarium, which is a bor/heimdalld based chain. Pretty much polygon with a different base token. I switched to my ethereum node and now it forks mainnet and tests with coverage without any issues. Polygon's bor doesn't support the latest EVM, but (I think) up to the London fork and I know they're working to release an update to bor to support newer EVM versions. Not sure if that is mainnet already. Currently I'm not in a position to test with polygon if the behaviour is the same. I'll try as soon as I get a chance. |
I just tried polygon mainnet fork and ran the tests but still didnt have an issue, but maybe i should use something already deployed to mainnet before forking? I pushed my config changes to the repro branch on the PR I commented above. |
Environment information
ape
and plugin versions: 0.6.20ape-config.yaml
(NOTE: do not post anything private like RPC urls or secrets!):What went wrong?
When I run my tests without
--coverage
, I get 100% PASS as a result. When I add --coverage, I get errors.It happens when I call my function that accepts an address as the only input parameter.
So in short:
def myFunction(_address: address):
And I test it with
myContract.myFunction(address_to_check, sender=address_in_adminlist)
Ape tells me:
from field must match key's 0x1e59ce931B4CFea3fe4B875411e280e173cB7A9C, but it was 0xc89D42189f0450C2b2c3c61f58Ec5d628176A1E7
Long version below
The contract function is literally this: Return a stored struct for the account that got passed.
There is no assertion that only the owner address can request their profile.
And the error message is
And the way profiles are stored:
So for some reason it doesn't allow not_owner to call the getProfile function and pass not_owner as the sender and requesting the profile created by sender. Which doesn't make sense with the vyper function.
Also it should either succeed or fail in both scenarios, wether I test with or without --coverage.
So not consistent.
To make things more exciting I fork shibarium with ape-hardhat (even though it's called ethereum in the ape-config. I just flipped the IP)
ape test --network ethereum:mainnet-fork:hardhat --coverage
How can it be fixed?
Not entirely sure, seems like the address passed as a parameter (owner) is overwritten with the sender= address (not_owner).
This only gets triggered when I use --coverage.
The text was updated successfully, but these errors were encountered: