Skip to content
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

Sketch out approach to testing abigen v2 #11

Draft
wants to merge 19 commits into
base: abigen2
Choose a base branch
from

Conversation

geoknee
Copy link

@geoknee geoknee commented Jul 20, 2023

Includes #10 .

The philosophy here is to mirror the existing test suite, so that the abigen v2 is run against all of the sam inputs, but with a custom set of assertions as to what to expect.

Overall the testing approach is pretty indirect / involved (writing to a temporary directory, building test files by editing raw strings,...). I don't love it, but it matches what is there and isn't too hard to modify.

An alternative I had considered is simply asserting on the output of Bind. If we find exactly what we want in the output, then probably there aren't any bugs. The existing testing system is better because it will check to see if the resulting package is free of bugs, too.

Keen to get feedback before finishing off the test (it still has some notes in the margin / mess from development)

Comment on lines 102 to 103
if b, err := NewToken(common.Address{}, nil); b == nil || err != nil {
t.Fatalf("binding (%v) nil or error (%v) not nil", b, nil)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is currently failing:

    bind_test.go:2204: test 1: failed to generate v2 binding: 77:39: expected ')', found ','

Copy link
Author

@geoknee geoknee Jul 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because the output from abigen v2 is

        	func (_Token *Token) PackConstructor(, initialSupply *big.Int , tokenName string , decimalUnits uint8 , tokenSymbol string ) ([]byte, error) {
        		return _Token.abi.Pack("" , initialSupply, tokenName, decimalUnits, tokenSymbol)
        	}

and we are trying to format the output.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed here ea664d0

geoknee added 2 commits July 20, 2023 14:12
The existing template prints a leading comma before each entry in the range. This works with the old template because there was a preceding variable printed.
Here, we opt for a multilne function definition and use trailing commas.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants