-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Description
segwit.py is supposed to test that "non-segwit miners get a valid GBT response after the fork":
print("Verify non-segwit miners get a valid GBT response after the fork")
send_to_witness(1, self.nodes[0], find_unspent(self.nodes[0], 50), self.pubkey[0], False, Decimal("49.998"))
try:
tmpl = self.nodes[0].getblocktemplate({})
assert(len(tmpl['transactions']) == 1) # Doesn't include witness tx
assert(tmpl['sigoplimit'] == 20000)
assert(tmpl['transactions'][0]['hash'] == txid)
assert(tmpl['transactions'][0]['sigops'] == 2)
assert(('!segwit' in tmpl['rules']) or ('segwit' not in tmpl['rules']))
except JSONRPCException:
# This is an acceptable outcome
passin fact what happens is that bitcoind returns a "Support for 'segwit' rule requires explicit client support" error to the getblocktemplate RPC. We always catch that error in the except: block and continue the test. None of the asserts in the try: branch are ever tested.
I don't know what the intent here is. I would expect non-segwit miners to continue to be able to use getblocktemplate after segwit activation. If that's true, then there's a bug in getblocktemplate(). If miners aren't supposed to be able use getblocktemplate() after segwit activation without setting the rules:['segwit'] option, then we should explicitly test that as follows:
assert_raises_jsonrpc(-8, "Support for 'segwit' rule requires explicit client support", self.nodes[0].getblocktemplate, {})and remove all the test code that isn't being used.