Stress testing the resilience of financial networks