Code Monkey home page Code Monkey logo

Comments (7)

startswithaj avatar startswithaj commented on August 24, 2024 1

Yeah I think what you are suggesting is ideal. We're on the same page.

FWIW, I actually found bulloak via https://github.com/defi-wonderland/solidity-foundry-boilerplate (https://github.com/defi-wonderland/solidity-foundry-boilerplate/blob/main/test/unit/Greeter.t.sol) and just cloned that repo to see if they get an error because I based my layout on that example. They do too:

Screenshot 2024-07-25 at 11 16 06 PM

I guess instead of it being a breaking change you could support both?

I'd love to see how others are using bulloak if you know of any other good example repos or public repos using it.

Cheers,

from bulloak.

alexfertel avatar alexfertel commented on August 24, 2024

Hey @startswithaj ! Thanks for using bulloak.

contract "MyErc20" is missing in .sol -- found "UnitMyErc20" instead

Right, so this mainly refers to having different names in the spec vs the test.

If I understand correctly, you only renamed it in the .sol, but not in the spec. If this is the case, just doing:

UnitMyErc20::constructor
└── when contructed
    ├── it deploys
    ├── it sets the owner as sender
    └── it sets the name

Should suffice.

from bulloak.

alexfertel avatar alexfertel commented on August 24, 2024

Do you think we should change the error message a bit? If so, how would you rephrase it to make it easier to understand?

from bulloak.

startswithaj avatar startswithaj commented on August 24, 2024

Heya @alexfertel thanks heaps for your reply.

Nar nar your error message made complete sense. I understood what the issue is/was.

It just didn't feel semantic to write:

UnitMyErc20::constructor

or

UnitMyErc20::mint

It seemed better to write

MyErc20::constructor
...
MyErc20::mint
...

Because that is what we are testing.

And then have the file name as MyErc20.t.sol. Then inside the file have it MyErc20Test/UnitMyErc20...just to avoid the conflict.

I thought there might be some way are the start of the all the trees to give it the Test Contract name.

UnitMyErc20


MyErc20::constructor
└── when contructed
    ├── it deploys
    ├── it sets the owner as sender
    └── it sets the name

...

If we use UnitMyErc20 we end up having:

UnitMyErc20.t.sol
UnitMyErc20.tree

Where as I would prefer:

MyErc20.t.sol
MyErc20.tree

Hope that makes sense. Cheers

from bulloak.

alexfertel avatar alexfertel commented on August 24, 2024

Ah, I see what you mean. That makes sense.

Note that the name of the t.sol is derived from the name of the .tree and not its contents, so I think the exact issue is having something that is not MyErc20 as the contract name. CMIIW.

The idea right now is that users follow Foundry's best practices which means that your test contract would be named MyErc20Test. However, I agree that it would be super nice to just use MyErc20::constructor vs MyErc20Test::constructor.

I don't have a good solution here, other than automatically appending Test to the contract name? Do you think that is a good trade-off?

This is also a breaking change, so I'd rather get this right, and publish v0.8.0, so this may take a while to see production.

from bulloak.

startswithaj avatar startswithaj commented on August 24, 2024

One other question, just while were in the swing of things if I could...

Take:

└── when passing an empty greeting string
    └── it reverts

Will generate a test:

function test_SetGreetingWhenPassingAnEmptyGreetingString() external

In the foundry best practices doc it says:

- test_Revert[If|When]_Condition for tests expecting a revert.

What would be the correct way to write the tree to get this test name?

Thanks again

from bulloak.

alexfertel avatar alexfertel commented on August 24, 2024

FWIW, I actually found bulloak via defi-wonderland/solidity-foundry-boilerplate (defi-wonderland/solidity-foundry-boilerplate@main/test/unit/Greeter.t.sol) and just cloned that repo to see if they get an error because I based my layout on that example. They do too

Oh, interesting. Maybe they are open to tweaking the template after this is fixed.

I guess instead of it being a breaking change you could support both?

Well, yeah, we could add a flag. Need to think what that would look like, but it shouldn't be a big lift.

I thought of it as a breaking change at first, because we also want users to fall into the pit of success. I think this is small enough of a change (and fixable with bulloak check!) that a breaking change is fine.

I'd love to see how others are using bulloak if you know of any other good example repos or public repos using it.

The best example I can think of right now is CreateX.

What would be the correct way to write the tree to get this test name?

Try it should revert, like this:

└── when passing an empty greeting string
    └── it should revert

from bulloak.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.