Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-replay-protection.py
Show All 13 Lines | |||||
from test_framework.comptool import TestManager, TestInstance, RejectResult | from test_framework.comptool import TestManager, TestInstance, RejectResult | ||||
from test_framework.blocktools import * | from test_framework.blocktools import * | ||||
import time | import time | ||||
from test_framework.key import CECKey | from test_framework.key import CECKey | ||||
from test_framework.script import * | from test_framework.script import * | ||||
# far into the future | # far into the future | ||||
REPLAY_PROTECTION_START_TIME = 2000000000 | REPLAY_PROTECTION_START_TIME = 2000000000 | ||||
MAGNETIC_ANOMALY_START_TIME = 4000000000 | |||||
# Error due to invalid signature | # Error due to invalid signature | ||||
INVALID_SIGNATURE_ERROR = b'mandatory-script-verify-flag-failed (Signature must be zero for failed CHECK(MULTI)SIG operation)' | INVALID_SIGNATURE_ERROR = b'mandatory-script-verify-flag-failed (Signature must be zero for failed CHECK(MULTI)SIG operation)' | ||||
RPC_INVALID_SIGNATURE_ERROR = "16: " + \ | RPC_INVALID_SIGNATURE_ERROR = "16: " + \ | ||||
INVALID_SIGNATURE_ERROR.decode("utf-8") | INVALID_SIGNATURE_ERROR.decode("utf-8") | ||||
class PreviousSpendableOutput(object): | class PreviousSpendableOutput(object): | ||||
def __init__(self, tx=CTransaction(), n=-1): | def __init__(self, tx=CTransaction(), n=-1): | ||||
self.tx = tx | self.tx = tx | ||||
self.n = n # the output we're spending | self.n = n # the output we're spending | ||||
class ReplayProtectionTest(ComparisonTestFramework): | class ReplayProtectionTest(ComparisonTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.num_nodes = 1 | self.num_nodes = 1 | ||||
self.setup_clean_chain = True | self.setup_clean_chain = True | ||||
self.block_heights = {} | self.block_heights = {} | ||||
self.tip = None | self.tip = None | ||||
self.blocks = {} | self.blocks = {} | ||||
self.extra_args = [['-whitelist=127.0.0.1', | self.extra_args = [['-whitelist=127.0.0.1', | ||||
"-magneticanomalyactivationtime=%d" % MAGNETIC_ANOMALY_START_TIME, | |||||
"-replayprotectionactivationtime=%d" % REPLAY_PROTECTION_START_TIME]] | "-replayprotectionactivationtime=%d" % REPLAY_PROTECTION_START_TIME]] | ||||
def run_test(self): | def run_test(self): | ||||
self.test = TestManager(self, self.options.tmpdir) | self.test = TestManager(self, self.options.tmpdir) | ||||
self.test.add_all_connections(self.nodes) | self.test.add_all_connections(self.nodes) | ||||
# Start up network handling in another thread | # Start up network handling in another thread | ||||
NetworkThread().start() | NetworkThread().start() | ||||
self.nodes[0].setmocktime(REPLAY_PROTECTION_START_TIME) | self.nodes[0].setmocktime(REPLAY_PROTECTION_START_TIME) | ||||
▲ Show 20 Lines • Show All 229 Lines • Show Last 20 Lines |