Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-transaction-ordering.py
Show First 20 Lines • Show All 252 Lines • ▼ Show 20 Lines | def get_tests(self): | ||||
assert_equal(node.getblockheader(forkblockhash)[ | assert_equal(node.getblockheader(forkblockhash)[ | ||||
'mediantime'], MAGNETIC_ANOMALY_START_TIME) | 'mediantime'], MAGNETIC_ANOMALY_START_TIME) | ||||
assert_equal(len(node.getrawmempool()), 15) | assert_equal(len(node.getrawmempool()), 15) | ||||
node.generate(1) | node.generate(1) | ||||
generatedblockhash = node.getbestblockhash() | generatedblockhash = node.getbestblockhash() | ||||
assert(forkblockhash != generatedblockhash) | assert(forkblockhash != generatedblockhash) | ||||
# Reconstruct tip. | |||||
tip_hash = node.getbestblockhash() | |||||
self.tip = CBlock() | |||||
self.tip.sha256 = int(tip_hash, 16) | |||||
self.tip.nTime = timestamp = node.getblock(tip_hash)['time'] | |||||
self.block_heights[self.tip.sha256] = node.getblock(tip_hash)['height'] | |||||
ordered_block(4446, out[18]) | |||||
yield accepted() | |||||
# Generate a block with a duplicated transaction. | |||||
double_tx_block = ordered_block(4447, out[19]) | |||||
assert_equal(len(double_tx_block.vtx), 16) | |||||
double_tx_block.vtx = double_tx_block.vtx[:8] + \ | |||||
[double_tx_block.vtx[8]] + double_tx_block.vtx[8:] | |||||
update_block(4447) | |||||
yield rejected(RejectResult(16, b'bad-txns-duplicate')) | |||||
# Rewind bad block. | |||||
tip(4446) | |||||
# Check over two blocks. | |||||
proper_block = ordered_block(4448, out[20]) | |||||
yield accepted() | |||||
replay_tx_block = ordered_block(4449, out[21]) | |||||
assert_equal(len(replay_tx_block.vtx), 16) | |||||
replay_tx_block.vtx.append(proper_block.vtx[5]) | |||||
replay_tx_block.vtx = [replay_tx_block.vtx[0]] + \ | |||||
sorted(replay_tx_block.vtx[1:], key=lambda tx: tx.get_id()) | |||||
update_block(4449) | |||||
yield rejected(RejectResult(16, b'bad-txns-BIP30')) | |||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
TransactionOrderingTest().main() | TransactionOrderingTest().main() |