mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Test relay of version 2 transactions
This commit is contained in:
parent
5cb1d8a207
commit
da5fdbb3a2
@ -4,7 +4,7 @@
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#
|
||||
# Test BIP68 implementation (mempool only)
|
||||
# Test BIP68 implementation
|
||||
#
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
@ -26,8 +26,10 @@ class BIP68Test(BitcoinTestFramework):
|
||||
def setup_network(self):
|
||||
self.nodes = []
|
||||
self.nodes.append(start_node(0, self.options.tmpdir, ["-debug", "-blockprioritysize=0"]))
|
||||
self.nodes.append(start_node(1, self.options.tmpdir, ["-debug", "-blockprioritysize=0", "-acceptnonstdtxn=0"]))
|
||||
self.is_network_split = False
|
||||
self.relayfee = self.nodes[0].getnetworkinfo()["relayfee"]
|
||||
connect_nodes(self.nodes[0], 1)
|
||||
|
||||
def run_test(self):
|
||||
# Generate some coins
|
||||
@ -42,10 +44,18 @@ class BIP68Test(BitcoinTestFramework):
|
||||
print "Running test sequence-lock-unconfirmed-inputs"
|
||||
self.test_sequence_lock_unconfirmed_inputs()
|
||||
|
||||
# This test needs to change when BIP68 becomes consensus
|
||||
print "Running test BIP68 not consensus"
|
||||
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 "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
|
||||
@ -333,8 +343,12 @@ class BIP68Test(BitcoinTestFramework):
|
||||
self.nodes[0].invalidateblock(self.nodes[0].getblockhash(cur_height+1))
|
||||
self.nodes[0].generate(10)
|
||||
|
||||
# Make sure that BIP68 isn't being used to validate blocks.
|
||||
# Make sure that BIP68 isn't being used to validate blocks, prior to
|
||||
# versionbits activation. If more blocks are mined prior to this test
|
||||
# being run, then it's possible the test has activated the soft fork, and
|
||||
# this test should be moved to run earlier, or deleted.
|
||||
def test_bip68_not_consensus(self):
|
||||
assert(get_bip9_status(self.nodes[0], 'csv')['status'] != 'active')
|
||||
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 2)
|
||||
|
||||
tx1 = FromHex(CTransaction(), self.nodes[0].getrawtransaction(txid))
|
||||
@ -381,6 +395,30 @@ class BIP68Test(BitcoinTestFramework):
|
||||
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):
|
||||
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)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
BIP68Test().main()
|
||||
|
Loading…
Reference in New Issue
Block a user