Skip to content

Commit

Permalink
Fix ListCoins test failure due to unset g_address_type, g_change_type
Browse files Browse the repository at this point in the history
New global variables were introduced in bitcoin#11403 and not setting them causes:

    test_bitcoin: wallet/wallet.cpp:4199: CTxDestination GetDestinationForKey(const CPubKey&, OutputType): Assertion `false' failed.
    unknown location(0): fatal error in "ListCoins": signal: SIGABRT (application abort requested)

It's possible to reproduce the failure reliably by running:

    src/test/test_bitcoin --log_level=test_suite --run_test=wallet_tests/ListCoins

Failures happen nondeterministically because boost test framework doesn't run
tests in a specified order, and tests that run previously can set the global
variables and mask the bug.
  • Loading branch information
ryanofsky committed Jan 11, 2018
1 parent d889c03 commit f765bb3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/wallet/test/wallet_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,8 @@ class ListCoinsTestingSetup : public TestChain100Setup
{
CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
::bitdb.MakeMock();
g_address_type = OUTPUT_TYPE_DEFAULT;
g_change_type = OUTPUT_TYPE_DEFAULT;
wallet.reset(new CWallet(std::unique_ptr<CWalletDBWrapper>(new CWalletDBWrapper(&bitdb, "wallet_test.dat"))));
bool firstRun;
wallet->LoadWallet(firstRun);
Expand Down

0 comments on commit f765bb3

Please sign in to comment.