Skip to content

Commit

Permalink
Fix BIP68 activation test
Browse files Browse the repository at this point in the history
  • Loading branch information
jnewbery committed Feb 10, 2017
1 parent b860915 commit 99c0e81
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions qa/rpc-tests/bip68-sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,12 @@ def run_test(self):
print("Running test BIP68 not consensus before versionbits activation")
self.test_bip68_not_consensus()

print("Verifying nVersion=2 transactions aren't standard")
self.test_version2_relay(before_activation=True)
print("Verifying nVersion=2 transactions are standard")
self.test_version2_relay()

print("Activating BIP68 (and 112/113)")
self.activateCSV()

print("Verifying nVersion=2 transactions are now standard")
self.test_version2_relay(before_activation=False)

print("Passed\n")

# Test that BIP68 is not in effect if tx version is 1, or if
Expand Down Expand Up @@ -399,30 +396,25 @@ def test_bip68_not_consensus(self):
self.nodes[0].submitblock(ToHex(block))
assert_equal(self.nodes[0].getbestblockhash(), block.hash)

def activateCSV(self):
# activation should happen at block height 432 (3 periods)
min_activation_height = 432
height = self.nodes[0].getblockcount()
assert(height < 432)
self.nodes[0].generate(432-height)
assert(get_bip9_status(self.nodes[0], 'csv')['status'] == 'active')
sync_blocks(self.nodes)

# Use self.nodes[1] to test standardness relay policy
def test_version2_relay(self, before_activation):
# Use self.nodes[1] to test that version 2 transactions are standard even before BIP68 activation.
def test_version2_relay(self):
inputs = [ ]
outputs = { self.nodes[1].getnewaddress() : 1.0 }
rawtx = self.nodes[1].createrawtransaction(inputs, outputs)
rawtxfund = self.nodes[1].fundrawtransaction(rawtx)['hex']
tx = FromHex(CTransaction(), rawtxfund)
tx.nVersion = 2
tx_signed = self.nodes[1].signrawtransaction(ToHex(tx))["hex"]
try:
tx_id = self.nodes[1].sendrawtransaction(tx_signed)
assert(before_activation == False)
except:
assert(before_activation)
tx_id = self.nodes[1].sendrawtransaction(tx_signed)

def activateCSV(self):
# activation should happen at block height 432 (3 periods)
min_activation_height = 432
height = self.nodes[0].getblockcount()
assert(height < 432)
self.nodes[0].generate(432-height)
assert(get_bip9_status(self.nodes[0], 'csv')['status'] == 'active')
sync_blocks(self.nodes)

if __name__ == '__main__':
BIP68Test().main()

0 comments on commit 99c0e81

Please sign in to comment.