Skip to content

Conversation

@jtimon
Copy link
Contributor

@jtimon jtimon commented Aug 22, 2019

Simply avoiding the hardcoded string in more places for consistency.
It can also allow for more easily reusing tests for other chains other than regtest.

Separated from #8994 .
Continues #16509 .

It is still not complete (ie to be complete, we need the -chain parameter in #16680 and make whether acceptnonstdtxs is allowed for that chain or not customizable for regtest [or for custom chains like in #8994 ] ). But while being incomplete like #16509 , it's quite simple to review and another step forward IMO.

@DrahtBot DrahtBot added the Tests label Aug 22, 2019
@jtimon jtimon force-pushed the b19-testchains-tests branch 2 times, most recently from b1f99ad to 5f50425 Compare August 22, 2019 17:48
@jtimon jtimon changed the title QA: Adapt BitcoinTestFramework for chains other than "regtest" Tests: Use self.chain instead of 'regtest' in all current tests Aug 22, 2019
@Sjors
Copy link
Member

Sjors commented Aug 22, 2019

Concept ACK

@DrahtBot
Copy link
Contributor

DrahtBot commented Aug 22, 2019

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #16895 (External signer multisig support by Sjors)
  • #16549 ([WIP] UI external signer support (e.g. hardware wallet) by Sjors)
  • #16546 ([WIP] External signer support - Wallet Box edition by Sjors)
  • #16528 (Native Descriptor Wallets using DescriptorScriptPubKeyMan by achow101)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@jtimon jtimon force-pushed the b19-testchains-tests branch from 5f50425 to 897f7ef Compare September 6, 2019 21:18
@jtimon
Copy link
Contributor Author

jtimon commented Sep 6, 2019

Now also in newly included wallet_reorgsrestore.py

@jtimon jtimon mentioned this pull request Sep 7, 2019
4 tasks
@laanwj
Copy link
Member

laanwj commented Sep 10, 2019

I don't understand the rationale behind this. How much chance do these tests have of working with a non-regtest chain?

@instagibbs
Copy link
Member

@laanwj with a custom testchain, most tests should work out of the box. Only ones that rely on specific genesis block information will break(there are a couple).

By itself it isn't greatly motivated, but it's also not a burden to maintain, so for me concept ACK.

@laanwj
Copy link
Member

laanwj commented Sep 10, 2019

Many of the functional tests depend on specific parameters of the regtest chain to be able to test things: reward schedule, mining difficulty, even address format.

Anyhow, conecpt ACK on this change, I was just wondering.

@jtimon
Copy link
Contributor Author

jtimon commented Sep 10, 2019

I don't understand the rationale behind this. How much chance do these tests have of working with a non-regtest chain?

Well, any custom chain created with #8994 should pass all the tests, like, for example, does -chain=regtest2 (in that PR).
Other chains like signets I guess don't benefit much from this change.
Projects based on bitcoin core that periodically rebase like elements should benefit too (although, yes, they will need further changes, this won't be enough for them).

I guess separating it is mostly about:

  1. Making Testchains: Introduce custom chain whose constructor...  #8994 smaller if this get merged first so that it's easier to review and maintain

  2. hopefully new tests will copy the self.chain from existing tests instead of copying the "regtest". That would mean less work when rebasing Testchains: Introduce custom chain whose constructor...  #8994

In summary, it's basically about #8994 , so if it doesn't make sense separated, I understand too.

@jtimon jtimon force-pushed the b19-testchains-tests branch 2 times, most recently from 010a0e5 to 72d822f Compare September 12, 2019 18:01
@laanwj
Copy link
Member

laanwj commented Sep 26, 2019

Well I think in any case it's better to have the chain configurable instead of hardcoding a magic string "regtest".

ACK 72d822f

@maflcko
Copy link
Member

maflcko commented Oct 2, 2019

+-0 self.chain and regtest are the same for these test and I don't think it will ever change

@jtimon
Copy link
Contributor Author

jtimon commented Oct 2, 2019

@MarcoFalke does that imply a nack to #8994 ?
Because that changes there.

@jtimon
Copy link
Contributor Author

jtimon commented Oct 2, 2019

Also, wouldn't it make sense alone, if anything, for consistency with #16509 ?

@maflcko
Copy link
Member

maflcko commented Oct 2, 2019

does that imply a nack to #8994 ?

Yeah, I am -0 on changing to regtest2.

Also, wouldn't it make sense alone, if anything, for consistency with #16509 ?

Yeah, +0 on this.

So overall +-0

@Sjors
Copy link
Member

Sjors commented Oct 6, 2019

ACK 72d822f. Tests still pass on macOS 10.14.6.

@maflcko
Copy link
Member

maflcko commented Oct 7, 2019

Also, this is not a complete fix, since it is impossible to protect against re-introduction of regtest in new code. E.g. https://github.com/bitcoin/bitcoin/blob/eeecdfa27a14df83c441cb4b04c0ae78a2ccbd2c/test/functional/feature_loadblock.py#L39

@maflcko
Copy link
Member

maflcko commented Oct 7, 2019

So, I'll change to overall -0.1

@laanwj
Copy link
Member

laanwj commented Oct 8, 2019

Also, this is not a complete fix, since it is impossible to protect against re-introduction of regtest in new code. E.g.

Strictly you could: randomize the test chain name every time.
Not sure it's worth it though …

Yeah, I am -0 on changing to regtest2.

I don't think we should change the default name of the regtest network either. The only chain we'd potentially rename would be testnet3, if the rules change, but an instance of regtest is meant to be short-lived.

@jtimon jtimon force-pushed the b19-testchains-tests branch from 72d822f to 83f08b3 Compare October 8, 2019 20:13
@jtimon
Copy link
Contributor Author

jtimon commented Oct 8, 2019

Also, this is not a complete fix,...

Rebased on top of master, but I don't see that test in master. It seems that commit doesn't belong in master unless I'm missing something.

I added jtimon@e889b4b#diff-6651d2553d181295a8570f18069e6b2bR28 for completion when doing the grep.
In any case, even if it's not complete (and it's not complete because it lacks something like jtimon@0943ce0#diff-2a344479dbbded9df5d6a4abde2cd48cL44), it makes #16509 more complete.

I don't think we should change the default name of the regtest network either.

I created #17032 and #17037 separated from #8994 that unlike #8994 don't change the default self.chain to regtest2. Neither of them (#17032 and #17037) need this, but I still think it's worth it for consistency and to complete #16509.

And to reiterate @laanwj 's words:

Well I think in any case it's better to have the chain configurable instead of hardcoding a magic string "regtest".

But if those reasons aren't enough and there's little chances of changing the default "regtest" to "regtest2" in the tests, then #8994 is not a justification for this either (by the way, you can go nack it for that reason, I guess). In that case, I guess we should close this.

Or perhaps we can wait for #17032 or #17037 to be merged first for this to be able to be complete.

To be honest, what I care the most about personally now is #17037, not #8994 anymore.

@maflcko
Copy link
Member

maflcko commented Oct 8, 2019

In that case, I guess we should close this.

Ok, closing then

@maflcko maflcko closed this Oct 8, 2019
@jtimon
Copy link
Contributor Author

jtimon commented Oct 25, 2019 via email

@jtimon jtimon force-pushed the b19-testchains-tests branch from 83f08b3 to 1abcecc Compare October 26, 2019 11:25
@jtimon
Copy link
Contributor Author

jtimon commented Oct 26, 2019

Rebased, adapted new test feature_loadblock.py

@Sjors
Copy link
Member

Sjors commented Oct 27, 2019

re-ACK 1abcecc. I think it's an improvement even if incomplete and if some PR's might accidentally bring "regtest" back. Subsequent improvements hopefully don't have to touch 16 files.

I'd like to break the circular arguments between this and related pull requests. Those are complicated enough to reason about without "but I don't like this name change in the other PR"; using self.chain instead of "regtest" gives us more optionality.

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Code review ACK 1abcecc.

I think one reason a change like this can get stuck in the review process is not stating a motivation or list of practical advantages in the PR description. When a description begins with "Separated from _. continues _. It is incomplete...", it suggests a rabbit hole few people will want to go down.

On the other hand, even though our review process is intentionally conservative, I think if a change is safe and has had sufficient code review that we shouldn't hold neutral or "+0" feedback against it. If as a reviewer you think drawbacks and risks of a change outweigh its benefits, you should actually state that, so we can avoid uncertainty and open PRs sitting in limbo.

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Code review ACK 1abcecc

@jtimon
Copy link
Contributor Author

jtimon commented Feb 4, 2020

I guess if I rebase now there will be more instances, but then I would lose the 2 ACKs.
What should I do?

@elichai
Copy link
Contributor

elichai commented Feb 4, 2020

Code review ACK 1abcecc
I do wonder how many of these tests will fail on testnet (even a custom one with difficulty 1).
Anyhow reducing hard coded strings is good IMHO, and I think even though it's incomplete it will help prevent future hard coded strings just by the fact that a lot of people copy-paste that code.

@ryanofsky
Copy link
Contributor

I guess if I rebase now there will be more instances, but then I would lose the 2 ACKs.
What should I do?

I'd suggest rebasing, the changes here are straightforward and I'm happy to reack.

@maflcko
Copy link
Member

maflcko commented Feb 4, 2020

This has two ACKs, merging now.

maflcko pushed a commit that referenced this pull request Feb 4, 2020
…nt tests

1abcecc Tests: Use self.chain instead of 'regtest' in almost all current tests (Jorge Timón)

Pull request description:

  Simply avoiding the hardcoded string in more places for consistency.
  It can also allow for more easily reusing tests for other chains other than regtest.

  Separated from #8994 .
  Continues #16509 .

  It is still not complete (ie to be complete, we need the -chain parameter in #16680 and make whether acceptnonstdtxs is allowed for that chain or not customizable for regtest [or for custom chains like in #8994 ] ). But while being incomplete like #16509 , it's quite simple to review and another step forward IMO.

ACKs for top commit:
  Sjors:
    re-ACK 1abcecc. I think it's an improvement even if incomplete and if some PR's might accidentally bring "regtest" back. Subsequent improvements hopefully don't have to touch 16 files.
  elichai:
    Code review ACK 1abcecc
  ryanofsky:
    Code review ACK 1abcecc.
  ryanofsky:
    Code review ACK 1abcecc

Tree-SHA512: 5620de6dab235ca8bd8670d6366c7b9f04f0e3ca9c5e7f87765b38e16ed80c17d7d1630c0d5fd7c5526f070830d94dc74cc2096d8ede87dc7180ed20569509ee
@maflcko maflcko merged commit 1abcecc into bitcoin:master Feb 4, 2020
@fanquake fanquake mentioned this pull request Feb 5, 2020
@fanquake
Copy link
Member

fanquake commented Feb 5, 2020

Opened #18068 to track a followup PR.

maflcko pushed a commit that referenced this pull request Feb 5, 2020
eca56f8 test: replace 'regtest' leftovers by self.chain (Sebastian Falbesoner)

Pull request description:

  This is a follow-up PR to #16681 (fixes #18068), replacing all remaining hardcoded `"regtest"` strings in functional tests by `self.chain`.

Top commit has no ACKs.

Tree-SHA512: 96524649b33164938e5a95215991103ed7855ebab55ef788d4816b3fa5cbc03d8f3b0d39f2247a87522f289fd7f4daf25e059900b8462b5127eb154bbee89054
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Feb 9, 2020
…l current tests

1abcecc Tests: Use self.chain instead of 'regtest' in almost all current tests (Jorge Timón)

Pull request description:

  Simply avoiding the hardcoded string in more places for consistency.
  It can also allow for more easily reusing tests for other chains other than regtest.

  Separated from bitcoin#8994 .
  Continues bitcoin#16509 .

  It is still not complete (ie to be complete, we need the -chain parameter in bitcoin#16680 and make whether acceptnonstdtxs is allowed for that chain or not customizable for regtest [or for custom chains like in bitcoin#8994 ] ). But while being incomplete like bitcoin#16509 , it's quite simple to review and another step forward IMO.

ACKs for top commit:
  Sjors:
    re-ACK 1abcecc. I think it's an improvement even if incomplete and if some PR's might accidentally bring "regtest" back. Subsequent improvements hopefully don't have to touch 16 files.
  elichai:
    Code review ACK 1abcecc
  ryanofsky:
    Code review ACK 1abcecc.
  ryanofsky:
    Code review ACK 1abcecc

Tree-SHA512: 5620de6dab235ca8bd8670d6366c7b9f04f0e3ca9c5e7f87765b38e16ed80c17d7d1630c0d5fd7c5526f070830d94dc74cc2096d8ede87dc7180ed20569509ee
sidhujag pushed a commit to syscoin-core/syscoin that referenced this pull request Nov 10, 2020
…l current tests

1abcecc Tests: Use self.chain instead of 'regtest' in almost all current tests (Jorge Timón)

Pull request description:

  Simply avoiding the hardcoded string in more places for consistency.
  It can also allow for more easily reusing tests for other chains other than regtest.

  Separated from bitcoin#8994 .
  Continues bitcoin#16509 .

  It is still not complete (ie to be complete, we need the -chain parameter in bitcoin#16680 and make whether acceptnonstdtxs is allowed for that chain or not customizable for regtest [or for custom chains like in bitcoin#8994 ] ). But while being incomplete like bitcoin#16509 , it's quite simple to review and another step forward IMO.

ACKs for top commit:
  Sjors:
    re-ACK 1abcecc. I think it's an improvement even if incomplete and if some PR's might accidentally bring "regtest" back. Subsequent improvements hopefully don't have to touch 16 files.
  elichai:
    Code review ACK 1abcecc
  ryanofsky:
    Code review ACK 1abcecc.
  ryanofsky:
    Code review ACK 1abcecc

Tree-SHA512: 5620de6dab235ca8bd8670d6366c7b9f04f0e3ca9c5e7f87765b38e16ed80c17d7d1630c0d5fd7c5526f070830d94dc74cc2096d8ede87dc7180ed20569509ee
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Dec 22, 2020
Summary:
This is a backport of Core [[bitcoin/bitcoin#16681 | PR16681]] and [[bitcoin/bitcoin#18069 | PR18069]]

I also replaced one occurence of 'regtest' in test_framework.py, that was missed in the backport of [[bitcoin/bitcoin#16509 | PR16509]] (D5942)

Test Plan: `ninja && ninja check-functional-extended`

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D8738
KolbyML pushed a commit to KolbyML/bitcoin that referenced this pull request Jan 21, 2021
…t' in almost all current tests, revert one TODO while at it
PastaPastaPasta pushed a commit to dashpay/dash that referenced this pull request Jan 22, 2021
* Merge bitcoin#16509: test: Adapt test framework for chains other than "regtest"

faf3683 test: Avoid hardcoding the chain name in combine_logs (MarcoFalke)
fa8a1d7 test: Adapt test framework for chains other than "regtest" (MarcoFalke)
68f5466 test: Fix “local variable 'e' is assigned to but never used” (Ben Woosley)

Pull request description:

  This is required for various work in progress:

  * testchains bitcoin#8994
  * signet bitcoin#16411
  * some of my locally written tests

  While it will be unused in the master branch as of now, it will make all of those pull requests shorter. Thus review for non-regtest tests can focus on the actual changes and not some test framework changes.

ACKs for top commit:
  jonatack:
    ACK faf3683, ran tests and reviewed the code.

Tree-SHA512: 35add66c12cab68f2fac8f7c7d47c604d3f24eae9336ff78f83e2c92b3dc08a25e7f4217199bac5393dd3fb72f945bba9c001d6fbb8efd298c88858075fcb3d6

* Add devnet support for tests

* test: make sure devnet can connect to each other and start

* Partial merge bitcoin#16681: Tests: Use self.chain instead of 'regtest' in almost all current tests, revert one TODO while at it

Co-authored-by: MarcoFalke <[email protected]>
Co-authored-by: Jorge Timón <[email protected]>
nunumichael added a commit to xazabevo/xazab that referenced this pull request Feb 16, 2021
* Merge #16509: test: Adapt test framework for chains other than "regtest"

faf36838bdba7393960fce6ad0c56dc1f93f5870 test: Avoid hardcoding the chain name in combine_logs (MarcoFalke)
fa8a1d7ba30040f8c74f93fc41a61276c255a6a6 test: Adapt test framework for chains other than "regtest" (MarcoFalke)
68f546635d5de2ccfedadeabc7bc79e12e5eca6a test: Fix “local variable 'e' is assigned to but never used” (Ben Woosley)

Pull request description:

  This is required for various work in progress:

  * testchains #8994
  * signet #16411
  * some of my locally written tests

  While it will be unused in the master branch as of now, it will make all of those pull requests shorter. Thus review for non-regtest tests can focus on the actual changes and not some test framework changes.

ACKs for top commit:
  jonatack:
    ACK faf36838bdba7393960fce6ad0c56dc1f93f5870, ran tests and reviewed the code.

Tree-SHA512: 35add66c12cab68f2fac8f7c7d47c604d3f24eae9336ff78f83e2c92b3dc08a25e7f4217199bac5393dd3fb72f945bba9c001d6fbb8efd298c88858075fcb3d6

* Add devnet support for tests

* test: make sure devnet can connect to each other and start

* Partial merge bitcoin/bitcoin#16681: Tests: Use self.chain instead of 'regtest' in almost all current tests, revert one TODO while at it

Co-authored-by: MarcoFalke <[email protected]>
Co-authored-by: Jorge Timón <[email protected]>
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants