当前位置: 首页>>代码示例>>Python>>正文


Python util.start_node函数代码示例

本文整理汇总了Python中test_framework.util.start_node函数的典型用法代码示例。如果您正苦于以下问题:Python start_node函数的具体用法?Python start_node怎么用?Python start_node使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了start_node函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run_test

    def run_test (self):
        tmpdir = self.options.tmpdir

        # Make sure can't switch off usehd after wallet creation
        self.stop_node(1)
        assert_start_raises_init_error(1, self.options.tmpdir, ['-usehd=0'], 'already existing HD wallet')
        self.nodes[1] = start_node(1, self.options.tmpdir, self.node_args[1])
        connect_nodes_bi(self.nodes, 0, 1)

        # Make sure we use hd, keep masterkeyid
        masterkeyid = self.nodes[1].getwalletinfo()['hdmasterkeyid']
        assert_equal(len(masterkeyid), 40)

        # Import a non-HD private key in the HD wallet
        non_hd_add = self.nodes[0].getnewaddress()
        self.nodes[1].importprivkey(self.nodes[0].dumpprivkey(non_hd_add))

        # This should be enough to keep the master key and the non-HD key 
        self.nodes[1].backupwallet(tmpdir + "/hd.bak")
        #self.nodes[1].dumpwallet(tmpdir + "/hd.dump")

        # Derive some HD addresses and remember the last
        # Also send funds to each add
        self.nodes[0].generate(101)
        hd_add = None
        num_hd_adds = 300
        for i in range(num_hd_adds):
            hd_add = self.nodes[1].getnewaddress()
            hd_info = self.nodes[1].validateaddress(hd_add)
            assert_equal(hd_info["hdkeypath"], "m/0'/0'/"+str(i+1)+"'")
            assert_equal(hd_info["hdmasterkeyid"], masterkeyid)
            self.nodes[0].sendtoaddress(hd_add, 1)
            self.nodes[0].generate(1)
        self.nodes[0].sendtoaddress(non_hd_add, 1)
        self.nodes[0].generate(1)

        self.sync_all()
        assert_equal(self.nodes[1].getbalance(), num_hd_adds + 1)

        self.log.info("Restore backup ...")
        self.stop_node(1)
        os.remove(self.options.tmpdir + "/node1/regtest/wallet.dat")
        shutil.copyfile(tmpdir + "/hd.bak", tmpdir + "/node1/regtest/wallet.dat")
        self.nodes[1] = start_node(1, self.options.tmpdir, self.node_args[1])
        #connect_nodes_bi(self.nodes, 0, 1)

        # Assert that derivation is deterministic
        hd_add_2 = None
        for _ in range(num_hd_adds):
            hd_add_2 = self.nodes[1].getnewaddress()
            hd_info_2 = self.nodes[1].validateaddress(hd_add_2)
            assert_equal(hd_info_2["hdkeypath"], "m/0'/0'/"+str(_+1)+"'")
            assert_equal(hd_info_2["hdmasterkeyid"], masterkeyid)
        assert_equal(hd_add, hd_add_2)

        # Needs rescan
        self.stop_node(1)
        self.nodes[1] = start_node(1, self.options.tmpdir, self.node_args[1] + ['-rescan'])
        #connect_nodes_bi(self.nodes, 0, 1)
        assert_equal(self.nodes[1].getbalance(), num_hd_adds + 1)
开发者ID:SergioDemianLerner,项目名称:bitcoin,代码行数:60,代码来源:wallet-hd.py

示例2: setup_network

    def setup_network(self):
        '''
        We'll setup the network to have 3 nodes that all mine with different parameters.
        But first we need to use one node to create a lot of small low priority outputs
        which we will use to generate our transactions.
        '''
        self.nodes = []
        # Use node0 to mine blocks for input splitting
        self.nodes.append(start_node(0, self.options.tmpdir, ["-maxorphantx=1000",
                                                              "-relaypriority=0", "-whitelist=127.0.0.1"]))

        print("This test is time consuming, please be patient")
        print("Splitting inputs to small size so we can generate low priority tx's")
        self.txouts = []
        self.txouts2 = []
        # Split a coinbase into two transaction puzzle outputs
        split_inputs(self.nodes[0], self.nodes[0].listunspent(0), self.txouts, True)

        # Mine
        while (len(self.nodes[0].getrawmempool()) > 0):
            self.nodes[0].generate(1)

        # Repeatedly split those 2 outputs, doubling twice for each rep
        # Use txouts to monitor the available utxo, since these won't be tracked in wallet
        reps = 0
        while (reps < 5):
            #Double txouts to txouts2
            while (len(self.txouts)>0):
                split_inputs(self.nodes[0], self.txouts, self.txouts2)
            while (len(self.nodes[0].getrawmempool()) > 0):
                self.nodes[0].generate(1)
            #Double txouts2 to txouts
            while (len(self.txouts2)>0):
                split_inputs(self.nodes[0], self.txouts2, self.txouts)
            while (len(self.nodes[0].getrawmempool()) > 0):
                self.nodes[0].generate(1)
            reps += 1
        print("Finished splitting")

        # Now we can connect the other nodes, didn't want to connect them earlier
        # so the estimates would not be affected by the splitting transactions
        # Node1 mines small blocks but that are bigger than the expected transaction rate,
        # and allows free transactions.
        # NOTE: the CreateNewBlock code starts counting block size at 1,000 bytes,
        # (17k is room enough for 110 or so transactions)
        self.nodes.append(start_node(1, self.options.tmpdir,
                                     ["-blockprioritysize=1500", "-blockmaxsize=18000",
                                      "-maxorphantx=1000", "-relaypriority=0", "-debug=estimatefee"]))
        connect_nodes(self.nodes[1], 0)

        # Node2 is a stingy miner, that
        # produces too small blocks (room for only 70 or so transactions)
        node2args = ["-blockprioritysize=0", "-blockmaxsize=12000", "-maxorphantx=1000", "-relaypriority=0"]

        self.nodes.append(start_node(2, self.options.tmpdir, node2args))
        connect_nodes(self.nodes[0], 2)
        connect_nodes(self.nodes[2], 1)

        self.is_network_split = False
        self.sync_all()
开发者ID:Whiteblock,项目名称:zcash,代码行数:60,代码来源:smartfees.py

示例3: setup_network

 def setup_network(self):
     args = ["-checkmempool", "-debug=mempool"]
     self.nodes = []
     self.nodes.append(start_node(0, self.options.tmpdir, args))
     self.nodes.append(start_node(1, self.options.tmpdir, args))
     connect_nodes(self.nodes[1], 0)
     self.is_network_split = False
     self.sync_all
开发者ID:Whiteblock,项目名称:zcash,代码行数:8,代码来源:mempool_reorg.py

示例4: setup_network

 def setup_network(self, split=False):
     self.nodes = []
     # Start nodes with tiny block size of 11kb
     self.nodes.append(start_node(0, self.options.tmpdir, ["-blockprioritysize=7000", "-blockmaxsize=11000", "-maxorphantx=1000", "-relaypriority=true", "-printpriority=1"]))
     self.nodes.append(start_node(1, self.options.tmpdir, ["-blockprioritysize=7000", "-blockmaxsize=11000", "-maxorphantx=1000", "-relaypriority=true", "-printpriority=1"]))
     connect_nodes(self.nodes[1], 0)
     self.is_network_split=False
     self.sync_all()
开发者ID:bitcartel,项目名称:zcash,代码行数:8,代码来源:prioritisetransaction.py

示例5: setup_network

 def setup_network(self):
     args = ["-checkmempool", "-debug=mempool", "-mempooltxinputlimit=2", "-nuparams=5ba81b19:110"]
     self.nodes = []
     self.nodes.append(start_node(0, self.options.tmpdir, args))
     self.nodes.append(start_node(1, self.options.tmpdir, args))
     connect_nodes(self.nodes[1], 0)
     self.is_network_split = False
     self.sync_all
开发者ID:bitcartel,项目名称:zcash,代码行数:8,代码来源:mempool_tx_input_limit.py

示例6: start_three

 def start_three(self):
     self.nodes[0] = start_node(0, self.options.tmpdir)
     self.nodes[1] = start_node(1, self.options.tmpdir)
     self.nodes[2] = start_node(2, self.options.tmpdir)
     connect_nodes(self.nodes[0], 3)
     connect_nodes(self.nodes[1], 3)
     connect_nodes(self.nodes[2], 3)
     connect_nodes(self.nodes[2], 0)
开发者ID:Whiteblock,项目名称:zcash,代码行数:8,代码来源:walletbackup.py

示例7: setup_network

 def setup_network(self):
     # Node0 will be used to test behavior of processing unrequested blocks
     # from peers which are not whitelisted, while Node1 will be used for
     # the whitelisted case.
     self.nodes = []
     self.nodes.append(start_node(0, self.options.tmpdir, ["-debug"],
                                  binary=self.options.testbinary))
     self.nodes.append(start_node(1, self.options.tmpdir,
                                  ["-debug", "-whitelist=127.0.0.1"],
                                  binary=self.options.testbinary))
开发者ID:Whiteblock,项目名称:zcash,代码行数:10,代码来源:p2p-acceptblock.py

示例8: setup_network

 def setup_network(self):
     args = ["-checkmempool", "-debug=mempool", "-blockmaxsize=4000",
         "-nuparams=5ba81b19:200", # Overwinter
         "-nuparams=76b809bb:210", # Sapling
     ]
     self.nodes = []
     self.nodes.append(start_node(0, self.options.tmpdir, args))
     self.nodes.append(start_node(1, self.options.tmpdir, args))
     connect_nodes(self.nodes[1], 0)
     self.is_network_split = False
     self.sync_all
开发者ID:Whiteblock,项目名称:zcash,代码行数:11,代码来源:mempool_nu_activation.py

示例9: setup_network

 def setup_network(self, split=False):
     args = ['-debug=zrpcunsafe', '-experimentalfeatures', '-zmergetoaddress']
     self.nodes = []
     self.nodes.append(start_node(0, self.options.tmpdir, args))
     self.nodes.append(start_node(1, self.options.tmpdir, args))
     args2 = ['-debug=zrpcunsafe', '-experimentalfeatures', '-zmergetoaddress', '-mempooltxinputlimit=7']
     self.nodes.append(start_node(2, self.options.tmpdir, args2))
     connect_nodes_bi(self.nodes,0,1)
     connect_nodes_bi(self.nodes,1,2)
     connect_nodes_bi(self.nodes,0,2)
     self.is_network_split=False
     self.sync_all()
开发者ID:Whiteblock,项目名称:zcash,代码行数:12,代码来源:wallet_mergetoaddress.py

示例10: setup_network

 def setup_network(self, split=False):
     args = ['-regtestprotectcoinbase', '-debug=zrpcunsafe']
     self.nodes = []
     self.nodes.append(start_node(0, self.options.tmpdir, args))
     self.nodes.append(start_node(1, self.options.tmpdir, args))
     args2 = ['-regtestprotectcoinbase', '-debug=zrpcunsafe', "-mempooltxinputlimit=7"]
     self.nodes.append(start_node(2, self.options.tmpdir, args2))
     connect_nodes_bi(self.nodes,0,1)
     connect_nodes_bi(self.nodes,1,2)
     connect_nodes_bi(self.nodes,0,2)
     self.is_network_split=False
     self.sync_all()
开发者ID:Whiteblock,项目名称:zcash,代码行数:12,代码来源:wallet_shieldcoinbase.py

示例11: reorg_test

    def reorg_test(self):
        # Node 1 will mine a 300 block chain starting 287 blocks back from Node 0 and Node 2's tip
        # This will cause Node 2 to do a reorg requiring 288 blocks of undo data to the reorg_test chain
        # Reboot node 1 to clear its mempool (hopefully make the invalidate faster)
        # Lower the block max size so we don't keep mining all our big mempool transactions (from disconnected blocks)
        stop_node(self.nodes[1],1)
        self.nodes[1]=start_node(1, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=5000", "-checkblocks=5", "-disablesafemode"], timewait=900)

        height = self.nodes[1].getblockcount()
        print "Current block height:", height

        invalidheight = height-287
        badhash = self.nodes[1].getblockhash(invalidheight)
        print "Invalidating block at height:",invalidheight,badhash
        self.nodes[1].invalidateblock(badhash)

        # We've now switched to our previously mined-24 block fork on node 1, but thats not what we want
        # So invalidate that fork as well, until we're on the same chain as node 0/2 (but at an ancestor 288 blocks ago)
        mainchainhash = self.nodes[0].getblockhash(invalidheight - 1)
        curhash = self.nodes[1].getblockhash(invalidheight - 1)
        while curhash != mainchainhash:
            self.nodes[1].invalidateblock(curhash)
            curhash = self.nodes[1].getblockhash(invalidheight - 1)

        assert(self.nodes[1].getblockcount() == invalidheight - 1)
        print "New best height", self.nodes[1].getblockcount()

        # Reboot node1 to clear those giant tx's from mempool
        stop_node(self.nodes[1],1)
        self.nodes[1]=start_node(1, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=5000", "-checkblocks=5", "-disablesafemode"], timewait=900)

        print "Generating new longer chain of 300 more blocks"
        self.nodes[1].generate(300)

        print "Reconnect nodes"
        connect_nodes(self.nodes[0], 1)
        connect_nodes(self.nodes[2], 1)
        sync_blocks(self.nodes[0:3])

        print "Verify height on node 2:",self.nodes[2].getblockcount()
        print "Usage possibly still high bc of stale blocks in block files:", calc_usage(self.prunedir)

        print "Mine 220 more blocks so we have requisite history (some blocks will be big and cause pruning of previous chain)"
        self.nodes[0].generate(220) #node 0 has many large tx's in its mempool from the disconnects
        sync_blocks(self.nodes[0:3])

        usage = calc_usage(self.prunedir)
        print "Usage should be below target:", usage
        if (usage > 550):
            raise AssertionError("Pruning target not being met")

        return invalidheight,badhash
开发者ID:bitcartel,项目名称:zcash,代码行数:52,代码来源:pruning.py

示例12: run_test

    def run_test (self):
        # Bring all nodes to just before the activation block
        print("Mining blocks...")
        self.nodes[0].generate(8)
        block9 = self.nodes[0].generate(1)[0]
        self.sync_all()

        assert_equal(self.nodes[0].getbestblockhash(), block9)
        assert_equal(self.nodes[1].getbestblockhash(), block9)

        print("Mining diverging blocks")
        block10s = self.nodes[1].generate(1)[0]
        block10o = self.nodes[2].generate(1)[0]
        self.sync_all()

        assert_equal(self.nodes[0].getbestblockhash(), block10o)
        assert_equal(self.nodes[1].getbestblockhash(), block10s)
        assert_equal(self.nodes[2].getbestblockhash(), block10o)

        # Restart node 0 using Sprout instead of Overwinter
        print("Switching node 0 from Overwinter to Sprout")
        self.nodes[0].stop()
        bitcoind_processes[0].wait()
        self.nodes[0] = start_node(0,self.options.tmpdir)
        connect_nodes_bi(self.nodes,0,1)
        connect_nodes_bi(self.nodes,1,2)
        connect_nodes_bi(self.nodes,0,2)

        # Assume node 1 will send block10s to node 0 quickly
        # (if we used self.sync_all() here and there was a bug, the test would hang)
        time.sleep(2)

        # Node 0 has rewound and is now on the Sprout chain
        assert_equal(self.nodes[0].getblockcount(), 10)
        assert_equal(self.nodes[0].getbestblockhash(), block10s)

        # Restart node 0 using Overwinter instead of Sprout
        print("Switching node 0 from Sprout to Overwinter")
        self.nodes[0].stop()
        bitcoind_processes[0].wait()
        self.nodes[0] = start_node(0,self.options.tmpdir, extra_args=['-nuparams=5ba81b19:10'])
        connect_nodes_bi(self.nodes,0,1)
        connect_nodes_bi(self.nodes,1,2)
        connect_nodes_bi(self.nodes,0,2)

        # Assume node 2 will send block10o to node 0 quickly
        # (if we used self.sync_all() here and there was a bug, the test would hang)
        time.sleep(2)

        # Node 0 has rewound and is now on the Overwinter chain again
        assert_equal(self.nodes[0].getblockcount(), 10)
        assert_equal(self.nodes[0].getbestblockhash(), block10o)
开发者ID:bitcartel,项目名称:zcash,代码行数:52,代码来源:rewind_index.py

示例13: setup_network

    def setup_network(self):
        self.nodes = []
        self.alert_filename = os.path.join(self.options.tmpdir, "alert.txt")
        with open(self.alert_filename, 'w'):
            pass  # Just open then close to create zero-length file
        self.nodes.append(start_node(0, self.options.tmpdir,
                            ["-blockversion=2", "-alertnotify=echo %s >> \"" + self.alert_filename + "\""]))
        # Node1 mines block.version=211 blocks
        self.nodes.append(start_node(1, self.options.tmpdir,
                                ["-blockversion=211"]))
        connect_nodes(self.nodes[1], 0)

        self.is_network_split = False
        self.sync_all()
开发者ID:Whiteblock,项目名称:zcash,代码行数:14,代码来源:forknotify.py

示例14: setup_network

 def setup_network(self, test, additional_args=[]):
     args = ['-debug=zrpcunsafe', '-experimentalfeatures', '-zmergetoaddress']
     args += additional_args
     test.nodes = []
     test.nodes.append(start_node(0, test.options.tmpdir, args))
     test.nodes.append(start_node(1, test.options.tmpdir, args))
     args2 = ['-debug=zrpcunsafe', '-experimentalfeatures', '-zmergetoaddress', '-mempooltxinputlimit=7']
     args2 += additional_args
     test.nodes.append(start_node(2, test.options.tmpdir, args2))
     connect_nodes_bi(test.nodes, 0, 1)
     connect_nodes_bi(test.nodes, 1, 2)
     connect_nodes_bi(test.nodes, 0, 2)
     test.is_network_split = False
     test.sync_all()
开发者ID:bitcartel,项目名称:zcash,代码行数:14,代码来源:mergetoaddress_helper.py

示例15: setup_network

    def setup_network(self):
        self.nodes = []
        # Nodes 0/1 are "wallet" nodes
        self.nodes.append(start_node(0, self.options.tmpdir, ["-debug"]))
        self.nodes.append(start_node(1, self.options.tmpdir, ["-debug"]))
        # Nodes 2/3 are used for testing
        self.nodes.append(start_node(2, self.options.tmpdir, ["-debug"]))
        self.nodes.append(start_node(3, self.options.tmpdir, ["-debug", "-txindex"]))
        connect_nodes(self.nodes[0], 1)
        connect_nodes(self.nodes[0], 2)
        connect_nodes(self.nodes[0], 3)

        self.is_network_split = False
        self.sync_all()
开发者ID:Whiteblock,项目名称:zcash,代码行数:14,代码来源:merkle_blocks.py


注:本文中的test_framework.util.start_node函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。