Repository: dogecoin/dogecoin
File: qa/rpc-tests/paytxfee.py (Python)

Code before:
        self.nodes.append(start_node(3, self.options.tmpdir,
            ["-mintxfee=0.01", "-paytxfee=0.1", "-minrelaytxfee=0.1", "-debug"]))

        # connect nodes
        connect_nodes_bi(self.nodes,0,1)
        connect_nodes_bi(self.nodes,1,2)
        connect_nodes_bi(self.nodes,0,2)
        connect_nodes_bi(self.nodes,0,3)
        connect_nodes_bi(self.nodes,1,3)
        connect_nodes_bi(self.nodes,2,3)

        self.is_network_split=False
        self.sync_all()

    def run_test(self):

        seed = 1000 # the amount to seed wallets with
        amount = 995 # the amount to send back
        targetAddress = self.nodes[0].getnewaddress()

        # mine some blocks and prepare some coins
        self.nodes[0].generate(102)
        self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), seed)
        self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), seed)
        self.nodes[0].sendtoaddress(self.nodes[3].getnewaddress(), seed)
        self.nodes[0].generate(5)
        self.sync_all()

        # create transactions
        txid1 = self.nodes[1].sendtoaddress(targetAddress, amount)
        txid2 = self.nodes[2].sendtoaddress(targetAddress, amount)
        txid3 = self.nodes[3].sendtoaddress(targetAddress, amount)
        self.sync_all()

        # make sure correct fees were paid
        tx1 = self.nodes[0].getrawtransaction(txid1, True)
        tx2 = self.nodes[0].getrawtransaction(txid2, True)
        tx3 = self.nodes[0].getrawtransaction(txid3, True)

        assert_equal(tx1['vout'][0]['value'] + tx1['vout'][1]['value'], Decimal("999.9"))
        assert_equal(tx2['vout'][0]['value'] + tx2['vout'][1]['value'], Decimal("999"))
        assert_equal(tx3['vout'][0]['value'] + tx3['vout'][1]['value'], Decimal("999.9"))

        # mine a block
        self.nodes[0].generate(1);
        self.sync_all()

        # make sure all fees were mined
        block = self.nodes[0].getblock(self.nodes[0].getbestblockhash())
        coinbaseTx = self.nodes[0].getrawtransaction(block['tx'][0], True)


Review comment (suggestion):
```suggestion
        self.nodes[0].generate(1)
```
Think you can reduce the number of blocks here, slightly faster.


Code after:
        nodes.append(start_node(3, self.options.tmpdir,
            ["-mintxfee=0.01", "-paytxfee=0.1", "-debug"]))

        return nodes

    def run_test(self):

        seed = 1000 # the amount to seed wallets with
        amount = 995 # the amount to send back
        targetAddress = self.nodes[0].getnewaddress()

        # mine some blocks and prepare some coins
        self.nodes[0].generate(102)
        self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), seed)
        self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), seed)
        self.nodes[0].sendtoaddress(self.nodes[3].getnewaddress(), seed)
        self.nodes[0].generate(1)
        self.sync_all()

        # create transactions
        txid1 = self.nodes[1].sendtoaddress(targetAddress, amount)
        txid2 = self.nodes[2].sendtoaddress(targetAddress, amount)
        txid3 = self.nodes[3].sendtoaddress(targetAddress, amount)
        self.sync_all()

        # make sure correct fees were paid
        tx1 = self.nodes[0].getrawtransaction(txid1, True)
        tx2 = self.nodes[0].getrawtransaction(txid2, True)
        tx3 = self.nodes[0].getrawtransaction(txid3, True)

        assert_equal(tx1['vout'][0]['value'] + tx1['vout'][1]['value'], Decimal("999.9"))
        assert_equal(tx2['vout'][0]['value'] + tx2['vout'][1]['value'], Decimal("999"))
        assert_equal(tx3['vout'][0]['value'] + tx3['vout'][1]['value'], Decimal("999.9"))

        # mine a block
        self.nodes[0].generate(1);
        self.sync_all()

        # make sure all fees were mined
        block = self.nodes[0].getblock(self.nodes[0].getbestblockhash())
        coinbaseTx = self.nodes[0].getrawtransaction(block['tx'][0], True)

        assert_equal(coinbaseTx['vout'][0]['value'], Decimal("500001.2"))

if __name__ == '__main__':
    PayTxFeeTest().main()