As the U.S.’s credibility and military capacity are tested abroad, China has gained leverage by staying out of the fight and learning from it.