Skip to content

Conversation

@laanwj
Copy link
Member

@laanwj laanwj commented Mar 13, 2017

Convert selected tests to use named arguments in RPC calls. This covers a few of the important ones:

  • assumevalid.py
  • blockchain.py
  • merkle_blocks.py
  • segwit.py

As well as the test framework itself, util.py.

This makes invocations easier to read especially if booleans or lots of arguments are involved.

Reviewing

To review I'd suggest using the command:

git diff --word-diff --word-diff-regex='[^[:space:],\(\)=]+'

This will regard the added argument names as one word, making it trivial to see what is added.

Process

As doing this is a bit of a finnicky process, I'm doing this a few tests at a time. I may add more to this PR later. In case people want to help, I created this list of RPC calls with argument names to avoid having to refer to the individual help all the time.

To make sure a test has no use of positional arguments left you can add these lines to __call__(self, *args, **argsn) in authproxy.py:

        if args:
            raise ValueError('TEST: supporting named arguments')

Every use of positional arguments will then raise that exception.

Convert selected tests to use named arguments in RPC calls.
This covers:

- `assumevalid.py`
- `blockchain.py`
- `merkle_blocks.py`
- `segwit.py`

As well as the test framework itself, `util.py`.

This makes invocations easier to read especially if booleans or lots of
arguments are involved.

To review I'd suggest using the command:

    git diff --word-diff --word-diff-regex='[^[:space:],\(\)=]+'

This will regard the added argument names as one words, making it easy
to see what is added.
@maflcko
Copy link
Member

maflcko commented Mar 13, 2017 via email

@laanwj
Copy link
Member Author

laanwj commented Mar 13, 2017

Concept ACK. Though I think we don't need named args for calls that
only have a single and obvious param, such as generate( $num ) or any
single param call that starts with set*.

I've thought about that. But some of the functions called with one argument are actually multi-arg functions of which only the first is used. And it may happen that more arguments get added to a function in the future. So I thought it better to be consistent and do all of them to move to a fully name-based API.

To aid reviewers even more, maybe in future pulls, a project wide
search and replace of eligible calls makes sense. Potentially one s&r
per commit, but no strong opinion on this.

Yeah, maybe. The advantage of doing it per test is that it is possible to verify that all calls have been converted without having to convert the entire project, which would conflict with every possible PR that changes tests.
I do agree it makes it easier to review per commit.

@maflcko
Copy link
Member

maflcko commented Mar 13, 2017 via email

@laanwj
Copy link
Member Author

laanwj commented Mar 16, 2017

Hmm. As long as downstream projects use the interface with positional args, we can't do that.

I don't say we should deprecate the positional arguments any time soon, just try to use it as our own best practice to use named arguments. Mixing them is kind of messy, IMO.

@laanwj
Copy link
Member Author

laanwj commented Mar 24, 2017

Closing, too much work to rebase all the time.

@laanwj laanwj closed this Mar 24, 2017
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants