The news that North Korea tested a hydrogen bomb on January 5 has raised fresh concerns about the stability of the Korean peninsula. While it remains doubtful that North Korea has actually succeeded in building the most destructive weapon in the world, what is certain is that the alleged test has exploded the myth of the Beijing-Pyongyang alliance.

Whenever North Korea is mentioned in connection with China, the world’s most brutal family dictatorship is often described as Beijing’s “ally.” But if we closely examine Pyongyang’s behavior, including its latest nuclear gambit, we have to wonder whether, with allies like North Korea, China really needs enemies.

On paper, of course, North Korea is the only country China is bound by a security treaty to defend. But in reality, this has been a troubled alliance from the very beginning.

In 1950, Kim Il-sung, the grandfather of Pyongyang’s current leader, Kim Jong-un, dragged China into a bloody war with the U.S. after his surprise attack on the south ended in a military disaster. The price China paid was horrific. Official Chinese sources claim a total of 360,000 casualties, but Western estimates put the Chinese casualties at 400,000 killed and 486,000 wounded.

Yet despite huge Chinese losses, the Kim dynasty has shown little appreciation of its savior. In North Korean museums, for example, there are few displays praising the heroism and sacrifice of the Chinese “People’s Volunteers,” the official title of the military forces Mao Zedong sent to Korea. And during the Cold War, Kim Il-sung cozied up to Moscow while keeping Beijing at arm’s length.

Ties between Beijing and Pyongyang did not improve much under Kim Jong-il, who succeeded his father in 1994. The “Dear Leader,” as the younger Kim was called in the official press, inflicted a different kind of damage on Beijing: his unrelenting and duplicitous quest for nuclear weapons.

Alarmed by North Korea’s nuclear ambitions, Beijing initiated the so-called “Six Party Talks” that included negotiators from China, the U.S., Japan, Russia, South Korea, and North Korea, in an ultimately futile attempt to persuade Pyongyang to give up its nuclear weapons program.

What made Chinese negotiators mad during the Six Party process was that North Korean negotiators deliberately and repeatedly shunned the Chinese while eagerly seeking out the Americans to strike a separate deal. (Fortunately, the Americans met the North Koreans separately but rejected their overtures for a side deal.)

Kim Jong-il further humiliated China with North Korea’s first nuclear test in October 2006 (he followed up with a second in May 2009). Things got even worse after the “Dear Leader” died in December 2011 and was succeeded by his twenty-something son, Kim Jong-un (the “Wise Leader” in North Korean parlance). Kim Jong-un immediately purged—and executed—many senior officials, including his uncle, who reportedly was Beijing’s closest ally in Pyongyang. Then, to demonstrate his control of the North Korean military, Kim tested another nuclear device in February 2013, only months after China’s current leader, Xi Jinping, assumed power.

To the Chinese, these reckless acts were seen as a direct affront to their new leader. Subsequently, ties chilled dramatically between the two so-called allies. The “Dear Leader” has not been extended an invitation to Beijing, a gesture that would have conveyed Beijing’s endorsement of his authority.

In recent months, however, there were signs of a thaw in Pyongyang-Beijing ties. China dispatched a senior leader to Pyongyang last October, and in December, Kim Jong-un sent his favorite ensemble, Moranbong Band, to Beijing. But the scheduled performance of the troupe was suddenly canceled and the band left Beijing in a hurry. It was widely speculated that China sent the band packing unceremoniously after Kim surprised Chinese leaders with the announcement that North Korea had developed a hydrogen bomb.

Now that Kim has detonated another nuclear device, officially billed as a hydrogen bomb, the question is whether this would be the last straw for Beijing.

In all likelihood, the Chinese government will do what it has done before: loud condemnation but no substantive punishment. Of course, China will support sanctions against Pyongyang, but not ones that would precipitate an economic collapse. For all the trouble the Kim dynasty has caused Beijing, leaders of the Chinese Communist Party (CCP) continue to see Pyongyang as more of a strategic asset than a liability.

Militarily, the Kim regime is touted as a security buffer against the U.S. in northeast Asia, even though in recent years more perceptive Chinese strategists have sounded the alarm about North Korea’s growing nuclear arsenal and the safety of its nuclear facilities (most of them located near the borders with China).

Economically, North Korea’s raw materials can be had at attractive terms, thanks to sanctions that have crippled its international trade. Ideologically, the collapse of a communist dictatorship on its doorstep and its replacement by a democracy would be a nightmare for the CCP.

Of course, Kim Jong-un, like his father and grandfather, understands perfectly Beijing’s strategic calculus and dilemma. That is why he keeps thumbing his nose at his only patron—with virtual impunity.

Minxin Pei is the Tom and Margot Pritzker ’72 Professor of Government at Claremont McKenna College and a non-resident senior fellow of the German Marshall Fund of the United States.