1

I'm writing a Roulette contract as a learning activity in Vyper. My contract seems to be working through manual testing, and now I'm starting to write unit tests.

I have an internal helper function used to map tile number to their colors.

@pure
@internal
def color_of(n: uint256) -> Color:
    """ Helper function to determine the color of a roulette tile """

    if n == 0 or n == 37:
        return Color.GREEN
    elif n == 1 or n == 3 or n == 5 or n == 7 or n == 9 or n == 12 or n == 14 or n == 16 or n == 18 or n == 19 or n == 21 or n == 23 or n == 25 or n == 27 or n == 30 or n == 32 or n == 34 or n == 36:
        return Color.RED
    else:
        return Color.BLACK

This function is not meant to be a user-callable transaction. IT is merely a helpful subroutine for calculating a tile's color, that I have abstracted out into a separate function.

The problem I'm facing is that when I write my unit tests, I can't see to call this function. Currently I'm using brownie for the tests, but I would happily switch if anyone can recommend something that solves this issue. Running brownie test fails with "AttributeError: Contract 'Roulette' object has no attribute 'color_of'"

Previously, when I worked with Solidity, I used foundry for my testing framework, and solved this problem using inheritance as they recommend. But Vyper doesn't have inheritance, so I'm not sure how to proceed.

1
  • I'm realizing this is not a framework issue (brownie, foundry, etc). It is a language issue. Solidity has inheritance and Vyper doesn't. That's the crux of it. Commented Jul 13, 2023 at 1:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.