Tests of general relativity with binary black holes from the second LIGO-Virgo gravitational-wave transient catalog