balpy icon indicating copy to clipboard operation
balpy copied to clipboard

Tests

Open LinuxIsCool opened this issue 2 years ago • 6 comments

There are no tests written for this library. That seems dangerous. I would be happy to start contributing tests. I'm still trying to get a sample running.

LinuxIsCool avatar Nov 20 '22 03:11 LinuxIsCool

Unit tests for balpy have been deprioritized since many of the test cases would involve deploying contracts to specific chains, which would clutter the testnet UIs, cost money on production networks, and require maintaining native asset balances on various chains. Not impossible, but pretty tedious.

Doing the tests locally would require integrating brownie which honestly would be amazing, but it would be a significant undertaking that I don't have time for right now

gerrrg avatar Nov 21 '22 14:11 gerrrg

Do you think it could be done using ApeworkX instead of Brownie?

https://docs.apeworx.io/ape/stable/userguides/testing.html

I would be interested in making this kind of contribution to the repo.

LinuxIsCool avatar Nov 22 '22 20:11 LinuxIsCool

I've heard to ApeworkX but have never gone down the rabbit hole. If we were to move in that direction, we would definitely need to add all the bytecode and ABIs back in. I had previously removed them to make the package more lightweight

gerrrg avatar Nov 22 '22 21:11 gerrrg

I think bytecode and ABIs could be gitignored. The package could stay as is, add ape-eth as a dependency, and compile contracts on the fly when running tests...

LinuxIsCool avatar Nov 23 '22 20:11 LinuxIsCool

@gerrrg Automated unit tests can be implemented by stubbing out external behaviors using pytest. I think it would be of value to test the internal logic of this library, not necessarily the smart contracts or other external behaviors.

pygeek avatar Dec 10 '22 04:12 pygeek

@LinuxIsCool

I have a nice stable env up and running here;

https://github.com/balancer/balpy/pull/55

We can use a local fork from a specific block for tests.

See this suite here;

https://github.com/8ball030/rysk_explorations/blob/5a83dabf0043c174bf553172acc7c7661069fc01/tests/test_contract_calls.py#L44

8ball030 avatar Oct 13 '23 10:10 8ball030