def setup_network(self): self.setup_nodes() mine_until_pop_enabled(self.nodes[0]) for i in range(self.num_nodes - 1): connect_nodes(self.nodes[i + 1], i) self.sync_all()
def _can_endorse(self): self.log.warning("starting _can_endorse()") connect_nodes(self.nodes[0], 1) self.sync_all() disconnect_nodes(self.nodes[1], 0) mine_until_pop_enabled(self.nodes[0]) lastblock = self.nodes[0].getblockcount() # endorse block 200 (fork A tip) addr0 = self.nodes[0].getnewaddress() txid = endorse_block(self.nodes[0], self.apm, lastblock, addr0) self.log.info("node0 endorsed block {} (fork A tip)".format(lastblock)) # mine pop tx on node0 self.nodes[0].generate(nblocks=1) tip = self.get_best_block(self.nodes[0]) self.log.info("node0 tip is {}".format(tip['height'])) self.nodes[1].generate(nblocks=250) tip2 = self.get_best_block(self.nodes[1]) self.log.info("node1 tip is {}".format(tip2['height'])) connect_nodes(self.nodes[0], 1) self.sync_all() bestblocks = [self.get_best_block(x) for x in self.nodes] assert_equal(bestblocks[0]['hash'], bestblocks[1]['hash']) self.log.info("all nodes switched to common block") for i in range(len(bestblocks)): assert bestblocks[i]['height'] == tip['height'], \ "node[{}] expected to select shorter chain ({}) with higher pop score\n" \ "but selected longer chain ({})".format(i, tip['height'], bestblocks[i]['height']) self.log.info("all nodes selected fork A as best chain") self.log.warning("_can_endorse() succeeded!")
def setup_network(self): self.setup_nodes() mine_until_pop_enabled(self.nodes[0]) # nodes[0,1] will be restarted # node[2] is a control node # all nodes connected and synced for i in range(self.num_nodes - 1): connect_nodes(self.nodes[i + 1], i) self.sync_all(self.nodes, timeout=60)
def setup_network(self): self.setup_nodes() mine_until_pop_enabled(self.nodes[0]) connect_nodes(self.nodes[0], 1) self.sync_all(self.nodes)
def setup_network(self): self.add_nodes(self.num_nodes) self.start_node(0) # POP should be enabled because merkle root calculation differs for non-POP blocks mine_until_pop_enabled(self.nodes[0])