def run_test(self):
    for (i, variant) in enumerate(IMPORT_VARIANTS):
        variant.label = 'label {} {}'.format(i, variant)
        variant.address = self.nodes[1].getaddressinfo(self.nodes[1].getnewaddress(label=variant.label, address_type=variant.address_type.value))
        variant.key = self.nodes[1].dumpprivkey(variant.address['address'])
        variant.initial_amount = get_rand_amount()
        variant.initial_txid = self.nodes[0].sendtoaddress(variant.address['address'], variant.initial_amount)
        self.nodes[0].generate(1)
        variant.confirmation_height = self.nodes[0].getblockcount()
        variant.timestamp = self.nodes[0].getblockheader(self.nodes[0].getbestblockhash())['time']
    assert_equal(self.nodes[0].getrawmempool(), [])
    set_node_times(self.nodes, ((self.nodes[0].getblockheader(self.nodes[0].getbestblockhash())['time'] + TIMESTAMP_WINDOW) + 1))
    self.nodes[0].generate(1)
    self.sync_all()
    for variant in IMPORT_VARIANTS:
        self.log.info('Run import for variant {}'.format(variant))
        expect_rescan = (variant.rescan == Rescan.yes)
        variant.node = self.nodes[(2 + IMPORT_NODES.index(ImportNode(variant.prune, expect_rescan)))]
        variant.do_import(variant.timestamp)
        if expect_rescan:
            variant.expected_balance = variant.initial_amount
            variant.expected_txs = 1
            variant.check(variant.initial_txid, variant.initial_amount, variant.confirmation_height)
        else:
            variant.expected_balance = 0
            variant.expected_txs = 0
            variant.check()
    for (i, variant) in enumerate(IMPORT_VARIANTS):
        variant.sent_amount = get_rand_amount()
        variant.sent_txid = self.nodes[0].sendtoaddress(variant.address['address'], variant.sent_amount)
        self.nodes[0].generate(1)
        variant.confirmation_height = self.nodes[0].getblockcount()
    assert_equal(self.nodes[0].getrawmempool(), [])
    self.sync_all()
    for variant in IMPORT_VARIANTS:
        self.log.info('Run check for variant {}'.format(variant))
        variant.expected_balance += variant.sent_amount
        variant.expected_txs += 1
        variant.check(variant.sent_txid, variant.sent_amount, variant.confirmation_height)
def run_test(self):
    for (i, variant) in enumerate(IMPORT_VARIANTS):
        variant.label = 'label {} {}'.format(i, variant)
        variant.address = self.nodes[1].getaddressinfo(self.nodes[1].getnewaddress(label=variant.label, address_type=variant.address_type.value))
        variant.key = self.nodes[1].dumpprivkey(variant.address['address'])
        variant.initial_amount = get_rand_amount()
        variant.initial_txid = self.nodes[0].sendtoaddress(variant.address['address'], variant.initial_amount)
        self.nodes[0].generate(1)
        variant.confirmation_height = self.nodes[0].getblockcount()
        variant.timestamp = self.nodes[0].getblockheader(self.nodes[0].getbestblockhash())['time']
    assert_equal(self.nodes[0].getrawmempool(), [])
    set_node_times(self.nodes, ((self.nodes[0].getblockheader(self.nodes[0].getbestblockhash())['time'] + TIMESTAMP_WINDOW) + 1))
    self.nodes[0].generate(1)
    self.sync_all()
    for variant in IMPORT_VARIANTS:
        self.log.info('Run import for variant {}'.format(variant))
        expect_rescan = (variant.rescan == Rescan.yes)
        variant.node = self.nodes[(2 + IMPORT_NODES.index(ImportNode(variant.prune, expect_rescan)))]
        variant.do_import(variant.timestamp)
        if expect_rescan:
            variant.expected_balance = variant.initial_amount
            variant.expected_txs = 1
            variant.check(variant.initial_txid, variant.initial_amount, variant.confirmation_height)
        else:
            variant.expected_balance = 0
            variant.expected_txs = 0
            variant.check()
    for (i, variant) in enumerate(IMPORT_VARIANTS):
        variant.sent_amount = get_rand_amount()
        variant.sent_txid = self.nodes[0].sendtoaddress(variant.address['address'], variant.sent_amount)
        self.nodes[0].generate(1)
        variant.confirmation_height = self.nodes[0].getblockcount()
    assert_equal(self.nodes[0].getrawmempool(), [])
    self.sync_all()
    for variant in IMPORT_VARIANTS:
        self.log.info('Run check for variant {}'.format(variant))
        variant.expected_balance += variant.sent_amount
        variant.expected_txs += 1
        variant.check(variant.sent_txid, variant.sent_amount, variant.confirmation_height)