While it can be difficult to provide one-to-one correspondences between all the events in Animal Farm and real historical events, Napoleon's sale of the timber to Frederick could represent the 1939 Soviet-German Pact.
In many ways, Napoleon's interactions with Frederick mimic Stalin's with Hitler. Like Stalin with Hitler, Napoleon bitterly denounces Frederick as the worst of enemies, only to enter into a secret agreement with him that is supposed to be mutually beneficial. Like Stalin with Hitler, Napoleon is betrayed by Frederick and played for a fool. Like Hitler, Frederick, after seeming to seek friendship with Napoleon and the farm, turns on them and attacks, blowing up the windmill. Hitler likewise turned on the Soviets in 1941 with a huge military campaign meant to subjugate the country.
The circumstances are not an exact parallel, but they mirror making a secret agreement with a treacherous and deceitful enemy and ending up betrayed and attacked.