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

pyln: Add a fixture for createwallet #4088

Merged

Conversation

jsarenik
Copy link
Contributor

@jsarenik jsarenik commented Sep 24, 2020

When testing against current master (209900), I got errors about a non-existing wallet.

$ pytest tests
...
E           bitcoin.rpc.JSONRPCError: {'code': -32601, 'message': 'Method not found (wallet method is disabled because no wallet is loaded)'}

Changelog-None

@jsarenik jsarenik requested a review from cdecker as a code owner September 24, 2020 11:42
@cdecker cdecker self-assigned this Sep 24, 2020
@jsarenik jsarenik force-pushed the jsn/pyln-fixtures-createwallet branch from 41e84bd to ac18407 Compare September 24, 2020 11:45
@jsarenik jsarenik changed the title Add a pyln fixture for createwallet pyln: Add a fixture for createwallet Sep 24, 2020
@cdecker
Copy link
Member

cdecker commented Sep 30, 2020

Thanks for catching this so early 👍 I just tested it and it works as advertised, with one minor caveat: test_bitcoind_goes_backwards which restarts the bitcoind instance doesn't create/unlock the wallet after restarting, so maybe we need to add this in the BitcoinD.start() function as well.

@jsarenik jsarenik force-pushed the jsn/pyln-fixtures-createwallet branch from ac18407 to ff031f8 Compare September 30, 2020 13:55
@cdecker
Copy link
Member

cdecker commented Oct 1, 2020

Hm, seems createwallet in BitcoinD.start() chokes if the wallet already exists. We should probably createwallet on first startup, and afterwards use loadwalletfor restarts. We can check if a wallet exists usinglistwallets`.

@jsarenik
Copy link
Contributor Author

jsarenik commented Oct 1, 2020

Still reading through git log and figuring out if we are not bending anything and why the error which I noticed appeared now (since createwallet RPC was added back in summer of 2018 as bitcoin/bitcoin#13058)

@jsarenik
Copy link
Contributor Author

jsarenik commented Oct 1, 2020

The last related upstream change seems to be bitcoin/bitcoin#15937 (was looking for createwallet in the git log)

@jsarenik
Copy link
Contributor Author

jsarenik commented Oct 1, 2020

Since then there were a couple of changes. I am retesting again against today's bitcoin master.

Yes, the same error happens on Bitcoin Core version v0.20.99.0-40aab35e9 but I am starting to guess it is rather bitcoin's bug.

@jsarenik
Copy link
Contributor Author

jsarenik commented Oct 1, 2020

I have submitted an issue to bitcoin: bitcoin/bitcoin#20051

@jsarenik
Copy link
Contributor Author

jsarenik commented Oct 1, 2020

Ah, too late :) It is in master for some days but I did not find it in the log looking for createwallet. bitcoin/bitcoin#15454

@jsarenik
Copy link
Contributor Author

jsarenik commented Oct 1, 2020

so the solution seems to be using -wallet argument when starting bitcoind

@jsarenik jsarenik force-pushed the jsn/pyln-fixtures-createwallet branch from ff031f8 to 11656e2 Compare October 1, 2020 12:00
@jsarenik
Copy link
Contributor Author

jsarenik commented Oct 1, 2020

Adding -wallet works both with current bitcoind from master branch and v0.20.1

@jsarenik jsarenik force-pushed the jsn/pyln-fixtures-createwallet branch from 11656e2 to ca69ec3 Compare October 1, 2020 12:05
@jsarenik
Copy link
Contributor Author

jsarenik commented Oct 1, 2020

In the end I set it to wallet="" but feel free to set it to something instead.

@jsarenik
Copy link
Contributor Author

jsarenik commented Oct 1, 2020

Ah, and it still may end up being something else. Using -wallet="something" is considered to be a hack and in future versions it may not create a wallet if it does not exist. See bitcoin/bitcoin#20034

@jsarenik jsarenik force-pushed the jsn/pyln-fixtures-createwallet branch from ca69ec3 to cd5508e Compare October 1, 2020 13:12
@cdecker
Copy link
Member

cdecker commented Oct 6, 2020

ACK cd5508e

@cdecker
Copy link
Member

cdecker commented Oct 6, 2020

Still hunting down some unrelated flaky tests, the failures in CI here are unrelated to this PR 👍

@jsarenik
Copy link
Contributor Author

jsarenik commented Oct 6, 2020

Just a note: it should be OK in long term when things stay as they are now:

  -wallet=<path>
       Specify wallet database path. Can be specified multiple times to load
       multiple wallets. Path is interpreted relative to <walletdir> if
       it is not absolute, and will be created if it does not exist (as
       a directory containing a wallet.dat file and log files). For
       backwards compatibility this will also accept names of existing
       data files in <walletdir>.)

(from bitcoind -help)

"load" and "will be created if it does not exist" are the important parts of this help message.

Copy link
Contributor Author

@jsarenik jsarenik left a comment

Choose a reason for hiding this comment

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

Still hunting down some unrelated flaky tests, the failures in CI here are unrelated to this PR

As long as it helps ... there is no hurry although someone who tests against current bitcoind may notice it already. Others after release of Bitcoin Core 0.21

contrib/pyln-testing/pyln/testing/utils.py Outdated Show resolved Hide resolved
@cdecker
Copy link
Member

cdecker commented Oct 13, 2020

Got Travis working again, rebasing and merging as soon as it passes 👍

@cdecker cdecker force-pushed the jsn/pyln-fixtures-createwallet branch from cd5508e to 3df395f Compare October 13, 2020 15:49
@cdecker
Copy link
Member

cdecker commented Oct 13, 2020

ACK 3df395f

@cdecker cdecker merged commit 90acf50 into ElementsProject:master Oct 13, 2020
@jsarenik
Copy link
Contributor Author

jsarenik commented Nov 8, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants