コード例 #1
0
    def run_test(self):
        test_node = TestNode()

        connections = []
        connections.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0],
                                    test_node, "regtest", SAPLING_PROTO_VERSION))
        test_node.add_connection(connections[0])

        # Start up network handling in another thread
        NetworkThread().start()

        test_node.wait_for_verack()

        # Verify mininodes are connected to zcashd nodes
        peerinfo = self.nodes[0].getpeerinfo()
        versions = [x["version"] for x in peerinfo]
        assert_equal(1, versions.count(SAPLING_PROTO_VERSION))
        assert_equal(0, peerinfo[0]["banscore"])

        coinbase_blocks = self.nodes[0].generate(1)
        self.nodes[0].generate(100)
        node_address = self.nodes[0].getnewaddress()

        # Mininodes send transaction to zcashd node.
        spendtx = create_transaction(self.nodes[0],
                                     coinbase_blocks[0],
                                     node_address,
                                     1.0,
                                     101)
        test_node.send_message(msg_tx(spendtx))

        time.sleep(3)

        # Verify test mininode has not been dropped
        # and still has a banscore of 0.
        peerinfo = self.nodes[0].getpeerinfo()
        versions = [x["version"] for x in peerinfo]
        assert_equal(1, versions.count(SAPLING_PROTO_VERSION))
        assert_equal(0, peerinfo[0]["banscore"])

        # Mine a block and resend the transaction
        self.nodes[0].generate(1)
        test_node.send_message(msg_tx(spendtx))

        time.sleep(3)

        # Verify test mininode has not been dropped
        # but has a banscore of 10.
        peerinfo = self.nodes[0].getpeerinfo()
        versions = [x["version"] for x in peerinfo]
        assert_equal(1, versions.count(SAPLING_PROTO_VERSION))
        assert_equal(10, peerinfo[0]["banscore"])

        [c.disconnect_node() for c in connections]
コード例 #2
0
    def send_transaction(self, testnode, block, address, expiry_height):
        tx = create_transaction(self.nodes[0], block, address, 10.0,
                                expiry_height)
        testnode.send_message(msg_tx(tx))

        # Sync up with node after p2p messages delivered
        testnode.sync_with_ping()

        # Sync nodes 0 and 1
        sync_blocks(self.nodes[:2])
        sync_mempools(self.nodes[:2])

        return tx
コード例 #3
0
ファイル: p2p_txexpiringsoon.py プロジェクト: bitcartel/zcash
    def send_transaction(self, testnode, block, address, expiry_height):
        tx = create_transaction(self.nodes[0],
                                block,
                                address,
                                10.0,
                                expiry_height)
        testnode.send_message(msg_tx(tx))

        # Sync up with node after p2p messages delivered
        testnode.sync_with_ping()

        # Sync nodes 0 and 1
        sync_blocks(self.nodes[:2])
        sync_mempools(self.nodes[:2])

        return tx