def run_test(self):
    for (i, variant) in enumerate(IMPORT_VARIANTS):
        variant.label = 'label {} {}'.format(i, variant)
        variant.address = self.nodes[1].validateaddress(self.nodes[1].getnewaddress(variant.label))
        variant.key = self.nodes[1].dumpprivkey(variant.address['address'])
        variant.initial_amount = (10 - ((i + 1) / 4.0))
        variant.initial_txid = self.nodes[0].sendtoaddress(variant.address['address'], variant.initial_amount)
    self.nodes[0].generate(1)
    assert_equal(self.nodes[0].getrawmempool(), [])
    timestamp = self.nodes[0].getblockheader(self.nodes[0].getbestblockhash())['time']
    set_node_times(self.nodes, ((timestamp + TIMESTAMP_WINDOW) + 1))
    self.nodes[0].generate(1)
    self.sync_blocks()
    for variant in IMPORT_VARIANTS:
        variant.expect_disabled = ((variant.rescan == Rescan.yes) and variant.prune and (variant.call == Call.single))
        expect_rescan = ((variant.rescan == Rescan.yes) and (not variant.expect_disabled))
        variant.node = self.nodes[(2 + IMPORT_NODES.index(ImportNode(variant.prune, expect_rescan)))]
        variant.do_import(timestamp)
        if expect_rescan:
            variant.expected_balance = variant.initial_amount
            variant.expected_txs = 1
            variant.check(variant.initial_txid, variant.initial_amount, 2)
        else:
            variant.expected_balance = 0
            variant.expected_txs = 0
            variant.check()
    for (i, variant) in enumerate(IMPORT_VARIANTS):
        variant.sent_amount = (10 - (((2 * i) + 1) / 8.0))
        variant.sent_txid = self.nodes[0].sendtoaddress(variant.address['address'], variant.sent_amount)
    self.nodes[0].generate(1)
    assert_equal(self.nodes[0].getrawmempool(), [])
    self.sync_blocks()
    for variant in IMPORT_VARIANTS:
        if (not variant.expect_disabled):
            variant.expected_balance += variant.sent_amount
            variant.expected_txs += 1
            variant.check(variant.sent_txid, variant.sent_amount, 1)
        else:
            variant.check()
def run_test(self):
    for (i, variant) in enumerate(IMPORT_VARIANTS):
        variant.label = 'label {} {}'.format(i, variant)
        variant.address = self.nodes[1].validateaddress(self.nodes[1].getnewaddress(variant.label))
        variant.key = self.nodes[1].dumpprivkey(variant.address['address'])
        variant.initial_amount = (10 - ((i + 1) / 4.0))
        variant.initial_txid = self.nodes[0].sendtoaddress(variant.address['address'], variant.initial_amount)
    self.nodes[0].generate(1)
    assert_equal(self.nodes[0].getrawmempool(), [])
    timestamp = self.nodes[0].getblockheader(self.nodes[0].getbestblockhash())['time']
    set_node_times(self.nodes, ((timestamp + TIMESTAMP_WINDOW) + 1))
    self.nodes[0].generate(1)
    self.sync_blocks()
    for variant in IMPORT_VARIANTS:
        variant.expect_disabled = ((variant.rescan == Rescan.yes) and variant.prune and (variant.call == Call.single))
        expect_rescan = ((variant.rescan == Rescan.yes) and (not variant.expect_disabled))
        variant.node = self.nodes[(2 + IMPORT_NODES.index(ImportNode(variant.prune, expect_rescan)))]
        variant.do_import(timestamp)
        if expect_rescan:
            variant.expected_balance = variant.initial_amount
            variant.expected_txs = 1
            variant.check(variant.initial_txid, variant.initial_amount, 2)
        else:
            variant.expected_balance = 0
            variant.expected_txs = 0
            variant.check()
    for (i, variant) in enumerate(IMPORT_VARIANTS):
        variant.sent_amount = (10 - (((2 * i) + 1) / 8.0))
        variant.sent_txid = self.nodes[0].sendtoaddress(variant.address['address'], variant.sent_amount)
    self.nodes[0].generate(1)
    assert_equal(self.nodes[0].getrawmempool(), [])
    self.sync_blocks()
    for variant in IMPORT_VARIANTS:
        if (not variant.expect_disabled):
            variant.expected_balance += variant.sent_amount
            variant.expected_txs += 1
            variant.check(variant.sent_txid, variant.sent_amount, 1)
        else:
            variant.check()