Add a test that would fail, should #567 resurface.
Also, add a comment and dedup a long expression.
How to test this:
Find your own way. Don’t let me misguide you.
src/qt/test/test_bitcoin-qt
and observe the newly added test passing:0PASS : OptionTests::parametersInteraction()
0--- i/src/qt/optionsmodel.cpp
1+++ w/src/qt/optionsmodel.cpp
2@@ -168,13 +168,13 @@ void OptionsModel::Init(bool resetSettings)
3 //
4 // OptionsModel::Init()
5 // this method, can flip -listen from 1 to 0 if fListen=false
6 //
7 // AppInitParameterInteraction()
8 // error if -listen=0 and -listenonion=1
9- gArgs.SoftSetBoolArg("-listenonion", false);
10+ //gArgs.SoftSetBoolArg("-listenonion", false);
11 }
12
13 if (!settings.contains("server")) {
14 settings.setValue("server", false);
15 }
16 if (!gArgs.SoftSetBoolArg("-server", settings.value("server").toBool())) {
and observe the test failing:
0FAIL! : OptionTests::parametersInteraction() 'gArgs.IsArgSet("-listenonion")' returned FALSE. ()
1 Loc: [qt/test/optiontests.cpp(53)]
0--- i/src/qt/test/optiontests.cpp
1+++ w/src/qt/test/optiontests.cpp
2@@ -47,14 +47,14 @@ void OptionTests::parametersInteraction()
3
4 const bool expected{false};
5
6 QVERIFY(gArgs.IsArgSet("-listen"));
7 QCOMPARE(gArgs.GetBoolArg("-listen", !expected), expected);
8
9- QVERIFY(gArgs.IsArgSet("-listenonion"));
10- QCOMPARE(gArgs.GetBoolArg("-listenonion", !expected), expected);
11+ //QVERIFY(gArgs.IsArgSet("-listenonion"));
12+ //QCOMPARE(gArgs.GetBoolArg("-listenonion", !expected), expected);
13
14 QVERIFY(AppInitParameterInteraction(gArgs));
15
16 // cleanup
17 settings.remove("fListen");
18 QVERIFY(!settings.contains("fListen"));
and observe the second check failing:
0Error: Cannot set -listen=0 together with -listenonion=1
1FAIL! : OptionTests::parametersInteraction() 'AppInitParameterInteraction(gArgs)' returned FALSE. ()
2 Loc: [qt/test/optiontests.cpp(56)]
I am puzzled why on macOS 12 native [gui, system sqlite only] [no depends]
the newly added test fails with:
0Error: Specified blocks directory "" does not exist.
1FAIL! : OptionTests::parametersInteraction() 'AppInitParameterInteraction(gArgs)' returned FALSE. ()
2 Loc: [qt/test/optiontests.cpp(56)]
While on my computer and on 32-bit + dash [gui] [CentOS 8]
(at least) the test passes.
:confused:
Thank you for following up with this! :partying_face:
I am puzzled why on
macOS 12 native [gui, system sqlite only] [no depends]
the newly added test fails
This is mysterious, but actually less mysterious than it appears at first, because of a terrible error message on the following line that checks if one directory exists (GetBlocksDirPath
), but then prints the error message about a different directory ("-blocksdir"
):
I think this error just happens if tests run in a different order, and I would try adding a gArgs.ClearPathCache()
call and forced_settings.erase("data");
to the top of the failing test(s).
170+ //
171+ // OptionsModel::Init()
172+ // this method, can flip -listen from 1 to 0 if fListen=false
173+ //
174+ // AppInitParameterInteraction()
175+ // error if -listen=0 and -listenonion=1
nit suggestion
0 // OptionsModel::Init()
1- // this method, can flip -listen from 1 to 0 if fListen=false
2+ // this method can flip -listen from 1 to 0 if fListen=false
3 //
4 // AppInitParameterInteraction()
5- // error if -listen=0 and -listenonion=1
6+ // raises an error if -listen=0 and -listenonion=1
34+void OptionTests::parametersInteraction()
35+{
36+ gArgs.LockSettings([&](util::Settings& s) {
37+ s.forced_settings.erase("listen");
38+ s.forced_settings.erase("listenonion");
39+ });
Added asserts here as a sanity check, maybe good to add in case the defaults in test_main.cpp
change.
0 void OptionTests::parametersInteraction()
1 {
2+ QVERIFY(gArgs.IsArgSet("-listen"));
3+ QVERIFY(gArgs.IsArgSet("-listenonion"));
4 gArgs.LockSettings([&](util::Settings& s) {
5 s.forced_settings.erase("listen");
6 s.forced_settings.erase("listenonion");
7 }
ACK cb018e75864c973d4d3e9591d7d2347a60aee122 modulo the macOS CI
Note that reverting #568 and running ./src/qt/test/test_bitcoin-qt
also prints a couple of Error: Cannot set -listen=0 together with -listenonion=1
messages in the RPCNestedTests and WalletTests output, though the tests don’t fail outright.
I could be missing a command line argument to do this, but added the following to make it easier to see if any test failures happened:
0--- a/src/qt/test/test_main.cpp
1+++ b/src/qt/test/test_main.cpp
2@@ -112,6 +112,10 @@ int main(int argc, char* argv[])
3 fInvalid = true;
4 }
5 #endif
6
7+ if (fInvalid) {
8+ qWarning("\nThere were errors in some of the tests above.\n");
9+ } else {
10+ qDebug("\nAll tests executed successfully.\n");
11+ }
A followup to https://github.com/bitcoin-core/gui/pull/568
Co-authored-by: Jon Atack <jon@atack.com>
cb018e7586...cae12fc803
: attempt to fix the CI failure and address suggestions
Invalidates ACK from @jonatack
Thanks for the suggestion, @ryanofsky! I added just gArgs.ClearPathCache()
as I think that alone should resolve it.
@jonatack I look up the exit status of the test executable (echo $?
) and if 1
then search the output for FAIL!
, yeah, not very convenient. I too noticed the printout Error: Cannot set -listen=0 together with -listenonion=1
from other tests if the bug resurfaces. I think it is ok.
29@@ -29,3 +30,35 @@ void OptionTests::optionTests()
30 });
31 gArgs.WriteSettingsFile();
32 }
33+
34+void OptionTests::parametersInteraction()
This name is fine with me, although it implied general parameter interaction testing.
Absolutely not critical, but while here, as this test is regression specific; maybe we could add a comment similar to the one in the test above?
reACK 4d4dca43fc
only change since my last review is the addition of a comment for the added test
ACK 4d4dca43fc591bf8fae7af74670f6e96650ef34b
Unfortunately, the test_bitcoin-qt.exe
fails on Windows (v26.1rc1):
0FAIL! : OptionTests::parametersInteraction() 'gArgs.IsArgSet("-listen")' returned FALSE.