In practice, the peerName API is not updated when ecash-herald calls it on block connected. Try 10 times, 3 seconds apart, to get the peerName from the API. Remove .filter method as you do not need to check every entry from API response, most likely only the first one or two.
Some refactoring required to make wait interval a param so that unit tests to not unnecessarily time out / take longer than needed. Add function param docs to functions where param is added.
Note: since we have the address of the winner from the block, we could avoid this wait interval if we had a peerName by address API.