“We know that God does not listen to sinners, but He does listen to the one who worships Him and does His will” John 9:31
God is love. Perfected love cast out fear.
David realized that the ultimate purpose of God’s testing was to bring him to everlasting life. Remember, your momentary afflictions are achieving an eternal glory that far outweighs them all (2 Corinthians 4:17)