These are the full reasons why China invaded VN in 1979...
We should have an overview of VN-China relation from 1920-1979...
1920-1945: the Communist movements entered VN and China. A lot of VN's Communist leaders were trained in Guangzou, Guangxi, Hong Kong, Shanghai (Hochiminh established some bases there). They were defended and helped by Chinese communists... When Japan invaded China, VN helped the Chinese fighting Japanese (both Nationlist and Communist) in Southern China
1945-1949: VN gained the independence in 1945, one year later, the French reocuppied Indochina. VN forces (VietMinh) withdrawed to the North, continued their fighting. From 1946-1949, VN and Chinese Communist helped each other (against Frech and Chinese Nationlist).
1949-1954: Chinese Communist won... Then they got great helps from Soviet... They started to supply weapons for Viet Minh... That was an important reason for mass growing of Viet Minh's forces. In 1954, VN claimed their Victory at Dien Bien Phu.
1954-1961: After Geneva agreement, VN divided in 2 parts... The election would be carried out in 1955... But US, fearing that Viet Minh could win (cos they were the only force that had support of most VN people, gained the VN's independence and defeated Frech)... To stop the danger of "Red Wave" in South East Asia, they established an anti-Communist Goverment in the South (republic of VN) and refused to implement the Geneva Agreement. VietMinh (or Democratic Republic of Vietnam) didn't accept that regime and claimed they will re-unite country.The second Indochina War started.
In the North, China helped VN buiding factories, roads, bridges... They adviced VN to carry out the "Land and Field Reform", as Cultural Revolution in China. 4 years after, Hochiminh realized that was a mistake and stopped it, Chinese consultants didn't satisfy, but Hochiminh continued his will.
At that time, China often claim their Sovereignty to the East Sea (or South China Sea), VN tried to keep an neutral attitute, no opposing, no confirming... and they started to realize that China was not impartial friend... VN wanted to get helps from China, but didn't want to depend on China. That's why they found Soviet's helps.
1961-1969: Hochiminh was a genius leader. He was a quite good diplomat. Though very bad relationship between China and Soviet, he still got helps from both countries. Mao, Zhu Anlai, Khrushov and Breznep were his close friend (and Gandi, too). Chinese supplied small arms, clothes, artileries, small AA guns.... Soviet supplied aircrafts, AA missile, gun boat, tanks, AFV...
1969-1972: Hochiminh died... The next leader, Le Duan, continued Hochiminh's way of diplomacy. But he was not good diplomat as Hochiminh, and the situation in China changed. China became closer to USA, so Le Duan began closer to Soviet.
1972-1975: Zhu Anlai met Kissinger in Shanghai, 1972. China officialy became USA's ally. After Shanghai Agreement signed, USA bombed North Vietnam, trying to force North VN back to negotiation, accept terms of conditions given by US. After US's heavy bombing, VN got heavy casualties and USA lost some hundred aircraft (included 34 B-52s), more than 100 pilots were captured. north VN back to negotiation, but with their term of conditions...
1973 Paris Agreement signed. US forces retreated. But, China consultants adviced north VN not to make great invasion, keep guerrila fighting. Le Duan didn't accept, and prepared for the Grand attack. From 1972-1975, Chinese support decreased fast, while Soviet support increase rapidly. VN started recolizing that China didn't want a United Vietnam, they wanted VN to be 'second North Korea". Two countries became "friends outside, unsatistied-parter inside".
In 1974, while the North was busy with their attack, China invaded Paracel Islands, defeat South VN forces, occupied the Islands. VN knew exactly what "Brother China" was...
1975-1978: After liberating Saigon, Vietnam reunited. The economy, which was destroyed, and then became very difficult by US's embago. The Chinese businessmen monopolized the VN economy, especialy in the South. The VN's goverment then nationlized these chinese companies. Then, they claimed that Chinese - Vietnamese must choose one nationlaty : vietnam or China (before 1975, a Chinese Vietnamese in the North could have 2 nationlaties: VN and China). That made great worries from Chinese Vietnamese. At that time, China accused VN's policy and appealed Chinese Vietnamese to go back to China Mainland. Then the Waves of Chinese Vietnamese migration back to China. But then China closed the border, hundred thousands of Chinese Vietnmese stucked at the border and became an humanity catastrophe. China and USA then accused VN to the United Nation and some months after open the border. VN became isolated country, that's why VN strenghthen relationship with Soviet.
In 1975, after claiming victory in Cambodia, Pol Pol establish a pro-China Goverment in Cambodia and carry out a copy of Cultural revolution in Cambodia. With advice from Chinese, Pol Pot started his campaign of purging, kill all Vietnamese Cambodian, pro-Vietnam member in Cambodian Communists.
From 1976-1977, Pol Pot started invading South-West VN. He claim "this land was belonged to Great Khmer Empire hudred years ago and now he will bring it back to Cambodian". The Khmer Rouge forces invaded the provinces of Tay Ninh, An Giang, Kien Giang... kill more than 30.000 Vietnamese people. VN forces pushed them back, but then they attacked again and again...
In 1978, with ammutions and planning from Chinese, Pol Pot mobilized a huge force of 19 divisions, attacked on all South - West provinces of VN. This time, Hanoi could not be patient anymore. VN mobilized 3/4 his army Corps counter-strike and then invaded Cambodia, swept all Khmer Rouge forces out of Cambodian terriory in just 2 weeks, liberating 3 million Cambodian survivors from "dead fields". China and USA condemned "VN invasion of Kampuchea", "VN's intending a Federation of Indochina" and then suppled ammunition to Pol Pot Forces. VN continued to be more isolated in Southest Asia, to be a monster, an agression coutry, a danger of Asia.
And in 1979, the Chinese Leader Deng Xiaoping said "teach VN - "a small super power nation" - a lesson"... in February,1979, 800 thousands of Chinese troops invaded VN...