-
Notifications
You must be signed in to change notification settings - Fork 382
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
qa: Support using bitcoind in fedpeg test #415
qa: Support using bitcoind in fedpeg test #415
Conversation
6fdd17f
to
28b89bf
Compare
qa/rpc-tests/feature_fedpeg.py
Outdated
@@ -47,9 +49,30 @@ def __init__(self): | |||
self.setup_clean_chain = True | |||
self.num_nodes = 4 | |||
|
|||
def setup_network(self, split=False): | |||
def add_options(self, parser): | |||
parser.add_option("--bitcoinddir", dest="bitcoinddir", default="", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps use --binpath or something directly instead of appending bitcoind in the test?
That way we could also use another elements binary, perhaps an older one to test compatibility or a newer one for testing rebases.
For that we would need to decouple another option --parent_is_bitcoinlike or something of the sort.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to --parent_bitcoin
and --parent_binpath=
:)
qa/rpc-tests/feature_fedpeg.py
Outdated
] for n in range(2)] | ||
|
||
binary = os.path.join(self.options.bitcoinddir, "bitcoind") | ||
self.nodes = start_nodes(2, self.options.tmpdir, self.extra_args[:2], binary=binary, chain="regtest") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's still no -chain=regtest option in normal bitcoind binaries, so in https://github.com/ElementsProject/elements/blob/elements-0.14.1/qa/rpc-tests/test_framework/util.py#L343 you will need to replace '-chain='+chain with just '-regtest' if chain == 'regtest'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I wanted to try. Is this why it fails? I thought it might just ignore it.
28b89bf
to
66b0299
Compare
d6660ac
to
4e2ac62
Compare
qa/rpc-tests/feature_fedpeg.py
Outdated
self.nodes = start_nodes(2, self.options.tmpdir, self.extra_args[:2], chain='parent') | ||
chain = None | ||
if self.options.parent_bitcoin: | ||
if self.options.parent_binpath == "": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be filtered in rpc-tests.py as well? This way a top-level arg there could trigger this, or not, safely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand your point..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rpc-tests.py will run all tests in sequence. I'd rather catch this argument error up front instead of waiting for this to be run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, you can pass these arguments to rpc-tests.py and they are globally set for all tests??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was my hope, yes
Should be able to just make it some global(?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Euhm, it seems that that's not possible anyway. If you run rpc-tests.py with those arguments, all other tests will complain that they don't know the arguments:
create_cache.py: error: no such option: --parent_bitcoin
Also, I think for now it makes more sense to only use those flags when running this test specifically..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
meh ok
4e2ac62
to
1aeed4b
Compare
qa/rpc-tests/test_framework/util.py
Outdated
args = [ binary, '-chain='+chain, "-datadir="+datadir, "-server", "-keypool=1", "-discover=0", "-rest", "-mocktime="+str(get_mocktime()) ] | ||
args = [ binary, "-datadir="+datadir, "-server", "-keypool=1", "-discover=0", "-rest", "-mocktime="+str(get_mocktime()) ] | ||
if chain != "regtest": #TODO(stevenroose) remove if unnecessary or when bitcoind has -chain | ||
args.append("-chain="+chain) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not?
# Special case for regtest. Remove if bitcoind gets -chain
if chain == 'regtest':
args.append('-regtest')
else:
args.append('-chain=' + chain)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or perhaps just
args.append('-regtest' if chain == 'regtest' else: '-chain=' + chain)
or some more pythonic way to do it (haven't tried this one, but I know there's something like the '?' keyword in C, java and friends).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I made it conditional and put a todo to remove it :)
1aeed4b
to
fe6e6d6
Compare
Like @jtimon pointed out, this also allows to use a custom elements binary for the parent chain. F.e. any liquid binary. |
qa/rpc-tests/feature_fedpeg.py
Outdated
parser.add_option("--parent_bitcoin", dest="parent_bitcoin", default=False, action="store_true", | ||
help="Parent nodes are Bitcoin") | ||
|
||
def start_node(self, idx): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not so sure this adds a lot of readibility, you could just use:
start_node(n, self.options.tmpdir, self.extra_args[n], chain='sidechain')
in one place and
binary = self.options.parent_binpath if self.options.parent_binpath != "" else None
chain = "regtest" if self.options.parent_bitcoin else "parent"
start_node(n, self.options.tmpdir, self.extra_args[n], binary=binary, chain=chain)
In the other, at least for the sidechains case seems unnecessarily complicated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also use it to restart the node lateron.
qa/rpc-tests/feature_fedpeg.py
Outdated
raise Exception("Peg-in with non-matching claim_script should fail.") | ||
except JSONRPCException as e: | ||
print(e.error["message"]) | ||
print('ERROR:', e.error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure removing ['message'] makes the printed error more clear?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit too noisy imo.
let's set |
fe6e6d6
to
94c4a27
Compare
qa/rpc-tests/feature_fedpeg.py
Outdated
help="Parent nodes are Bitcoin") | ||
|
||
def start_node(self, idx): | ||
is_parent = idx < 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't very readable, add a comment or make it more explicit in code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or just get rid of the function as I propose above
qa/rpc-tests/feature_fedpeg.py
Outdated
def setup_network(self, split=False): | ||
if self.options.parent_bitcoin and self.options.parent_binpath == "": | ||
raise "Can't run with --parent_bitcoin without specifying --parent_binpath" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unexpected exception caught during testing: TypeError('exceptions must derive from BaseException',)
Can we handle this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just put the quote in Exception()
Let's also fix up our handling of 0.17 |
94c4a27
to
e380a7f
Compare
I just realized this test isn't setting fedpeg_key="cPxqWyf1HDGpGFH1dnfjz8HbiWxvwG8WXyetbuAiw4thKXUdXLpR" no need to import it or anything, just set it. |
Here's some suggested fixes: instagibbs@af19891 |
this too: instagibbs@d084d36 |
e380a7f
to
42ab8ed
Compare
Can we squash "qa: Fix bug in feature_fedpeg test script"? it isn't really fixing anything, it works the same before and after the change. |
Do we really need rpc: "reject non-hex strings for claim_script" here? |
@jtimon yes we are, |
Ok, either way I had to call it directly from the test to get the 'Given claim_script is not hex' exception. Updated https://github.com/jtimon/elements/tree/pr-415 with that. |
42ab8ed
to
e6d1dec
Compare
qa/rpc-tests/feature_fedpeg.py
Outdated
parent_pubkey = parent.validateaddress(parent_chain_addr)["pubkey"] | ||
parent_chain_p2sh_addr = parent.createmultisig(1, [parent_pubkey])["address"] | ||
self.test_pegout(parent_chain_p2sh_addr, sidechain) | ||
# print("Test pegout P2SH") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
read the commits, perhaps better read the commit tittles in the branch without the squashes: https://github.com/jtimon/elements/tree/pr-415
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please don't disable swaths of tests when it's very possible to retain them
This ports the functionality from pegging.py to the feature_fedpeg.py test. The following two commands are not equivalent: $ ./qa/rpc-tests/pegging.py dir/to/bitcoin $ ./qa/pull-tester/rpc-tests.py feature_fedpeg --parent_bitcoin \ --parent_binpath=bin/to/bitcoin/bitcoind
Updated https://github.com/jtimon/elements/tree/pr-415 with a squashed version that works with 0.17.0 |
e6d1dec
to
498877e
Compare
Tested ACK 498877e |
oh, and I guess you can add an extra commit getting rid of pegging.py |
Done :) |
qa/rpc-tests/feature_fedpeg.py
Outdated
self.extra_args.append([ | ||
# '-printtoconsole', | ||
args = [ | ||
"-printtoconsole", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we set this to 0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a commit to do this. If you want me to squash it with the others, let me know..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You commented out, not put to 0. Bitcoin Core 0.17 defaults to 1
.
@stevenroose Sorry I mean explicitly set to 0. Future Core version are 1 by default. |
We have no coverage of the cookie auth connection to parent node in this test. |
c858a77
to
9545ca3
Compare
tACK 9545ca3 |
9545ca3 qa: Disable -printtoconsole in feature_fedpeg (Steven Roose) 1451e86 qa: Remove pegging.py in favor of feature_fedpeg.py (Steven Roose) 498877e QA: Fix feature_fedpeg.py to work with 0.17.0 (Jorge Timón) a7736f8 QA: Add test to get 'Given claim_script is not hex' error (Jorge Timón) 35364b6 rpc: reject non-hex strings for claim_script (Gregory Sanders) 07c617b qa: Support using bitcoind in fedpeg test (Steven Roose) 729969d QA: Special case for regtest, expected to be used for binaries that lack -chain (Jorge Timón)
I'll follow-up with cookie auth check |
This ports the functionality from pegging.py to the feature_fedpeg.py
test. The following two commands are not equivalent: