Preheat oven to 350 degrees F. Line bottoms of two 9-inch round cake pans with waxed paper. Grease paper and sides of pans. Dust with flour.
Mix flour, cocoa, baking soda, and salt. In another bowl, beat margarine, granulated sugar, and brown sugar at medium speed until light and fluffy. Add eggs (or the equivalent substitute) one at a time, beating well after each addition. Add vanilla.
At low speed, alternately beat flour mixture and buttermilk into margarine mixture just until blended. Divide batter equally between prepared pans.
Bake cakes until a toothpick inserted in the center comes out clean, 25 to 30 minutes. Transfer pans to wire racks to cool for 10 minutes. Turn out onto racks. Remove paper. Turn the layers topside, and cool completely.
To prepare frosting, beat margarine and confectioner’s sugar at medium speed until fluffy. Add melted chocolate and vanilla. Continue beating until shiny and smooth.
Place 1 cake layer on a serving plate; spread with frosting. Top with remaining cake layer. Spread frosting on top and sides of cake. Let cake stand for at least 30 minutes before sprinkling with chocolate shavings and slicing.