Beat together the granulated sugar, cornflour, cocoa powder and eggs in a heatproof bowl. Heat the milk until boiling, then whisk into the egg mixture. Pour the mixture into a pan and cook for 3–5 minutes until thickened, making sure it doesn't boil. Pour the hot custard over the chocolate in a heatproof bowl and stir until smooth. Cover and chill for at least 1 hour.
Make the churros. Sift the flours into a bowl and make a well in the centre. Mix together the melted butter and measurement water in a jug, then pour into the well, beating to form a smooth dough. Leave to rest for 10 minutes.
Pour the oil into a large, deep saucepan to a depth of at least 7 cm (3 inches) and heat to 180–190°C (350–375°F), or until a cube of bread browns in 30 seconds. Spoon the dough into a piping bag, then squeeze 5 cm (2 inch) lengths into the oil, cutting off the ends with scissors – only cook 5 at a time. Deep-fry for about 3 minutes until golden, then remove with a slotted spoon. Drain on kitchen paper and keep warm while you cook the remaining dough. Sprinkle the churros with the caster sugar. Serve the warm churros with the chocolate custard in small serving dishes on the side for dunking.