Example #1
0
    def test_chain(self):
        node = self.nodes[0]
        first_coin = self.coins.pop()
        (chain_hex, chain_txns) = create_raw_chain(node, first_coin,
                                                   self.address, self.privkeys)
        self.log.info(
            "Check that testmempoolaccept requires packages to be sorted by dependency"
        )
        assert_equal(node.testmempoolaccept(rawtxs=chain_hex[::-1]),
                     [{
                         "txid": tx.rehash(),
                         "wtxid": tx.getwtxid(),
                         "package-error": "package-not-sorted"
                     } for tx in chain_txns[::-1]])

        self.log.info("Testmempoolaccept a chain of 25 transactions")
        testres_multiple = node.testmempoolaccept(rawtxs=chain_hex)

        testres_single = []
        # Test accept and then submit each one individually, which should be identical to package test accept
        for rawtx in chain_hex:
            testres = node.testmempoolaccept([rawtx])
            testres_single.append(testres[0])
            # Submit the transaction now so its child should have no problem validating
            node.sendrawtransaction(rawtx)
        assert_equal(testres_single, testres_multiple)

        # Clean up by clearing the mempool
        self.generate(node, 1)
Example #2
0
    def test_submitpackage(self):
        node = self.nodes[0]

        self.log.info(
            "Submitpackage valid packages with 1 child and some number of parents"
        )
        for num_parents in [1, 2, 24]:
            self.test_submit_child_with_parents(num_parents, False)
            self.test_submit_child_with_parents(num_parents, True)

        self.log.info("Submitpackage valid packages with CPFP")
        self.test_submit_cpfp()

        self.log.info(
            "Submitpackage only allows packages of 1 child with its parents")
        # Chain of 3 transactions has too many generations
        chain_hex, _ = create_raw_chain(node, self.coins.pop(), self.address,
                                        self.privkeys, 3)
        assert_raises_rpc_error(-25, "not-child-with-parents",
                                node.submitpackage, chain_hex)