Fixes #6524
Use a unique name for alertnotify.txt tempfile during AlertNotify test
161 | @@ -162,8 +162,8 @@ BOOST_AUTO_TEST_CASE(AlertNotify) 162 | SetMockTime(11); 163 | const std::vector<unsigned char>& alertKey = Params(CBaseChainParams::MAIN).AlertKey(); 164 | 165 | - boost::filesystem::path temp = GetTempPath() / "alertnotify.txt"; 166 | - boost::filesystem::remove(temp); 167 | + boost::filesystem::path temp = GetTempPath() / 168 | + boost::filesystem::unique_path("alertnotify-%%%%.txt");
minor nit: wrong indent (same on L171 / not related to this PR)
Isn't the right indentation four spaces? Or is it different for a line continuation?
Meh. Sorry. I oversaw the line break... all good!
You can always use clang-format -i <file> if you wan't to confirm to the code-style-guidelines.
tested ACK
ACK.
Couldn't find any details about when files generated with boost::filesystem::unique_path are deleted.
I think adding a boost::filesystem::remove(temp); wouldn't harm?
ACK. Using a hardcoded/predictable temporary file name can be dangerous.
And agree with @jonasschnelli that the test should try to clean up after itself.
@jonasschnelli @laanwj It actually does clean up after itself; there's a call to boost::filesystem::remove(temp) at the end of the function.
@casey: Ah. Now i see how this works. The boost::filesystem::remove(temp); removed in this PR was there because the file was not really a random tmp file.
ACK.
Oh! oops. Apologies for the spurious comment, then.