message: Speed up knapsack_solver_test by not recreating wallet 100 times.
  Moved the code for creating the wallet out of the 100-times repetition loop, for the most time-consuming tests.
diff: @@ -452,6 +452,7 @@ BOOST_AUTO_TEST_CASE(knapsack_solver_test)
  BOOST_CHECK(testWallet.SelectCoinsMinConf(MIN_CHANGE * 9990 / 100, filter_confirmed, GroupCoins(vCoins), setCoinsRet, nValueRet, coin_selection_params, bnb_used));
  BOOST_CHECK_EQUAL(nValueRet, 101 * MIN_CHANGE);
  BOOST_CHECK_EQUAL(setCoinsRet.size(), 2U);
  + }
  // test with many inputs
  for (CAmount amt=1500; amt < COIN; amt*=10) {
  @@ -459,7 +460,11 @@ BOOST_AUTO_TEST_CASE(knapsack_solver_test)
  // Create 676 inputs (= (old MAX_STANDARD_TX_SIZE == 100000) / 148 bytes per input)
  for (uint16_t j = 0; j < 676; j++)
  add_coin(amt);
  +
  + // We only create the wallet once to save time, but we still run the coin selection RUN_TESTS times.
  + for (int i = 0; i < RUN_TESTS; i++) {
  BOOST_CHECK(testWallet.SelectCoinsMinConf(2000, filter_confirmed, GroupCoins(vCoins), setCoinsRet, nValueRet, coin_selection_params, bnb_used));
  +
  if (amt - 2000 < MIN_CHANGE) {
  // needs more than one input:
  uint16_t returnSize = std::ceil((2000.0 + MIN_CHANGE)/amt);
  @@ -472,6 +477,7 @@ BOOST_AUTO_TEST_CASE(knapsack_solver_test)
  BOOST_CHECK_EQUAL(setCoinsRet.size(), 1U);
  }
  }
  + }
  // test randomness
  {
  @@ -479,6 +485,8 @@ BOOST_AUTO_TEST_CASE(knapsack_solver_test)
  for (int i2 = 0; i2 < 100; i2++)
  add_coin(COIN);
  + // Again, we only create the wallet once to save time, but we still run the coin selection RUN_TESTS times.
  + for (int i = 0; i < RUN_TESTS; i++) {
  // picking 50 from 100 coins doesn't depend on the shuffle,
  // but does depend on randomness in the stochastic approximation code
  BOOST_CHECK(testWallet.SelectCoinsMinConf(50 * COIN, filter_standard, GroupCoins(vCoins), setCoinsRet , nValueRet, coin_selection_params, bnb_used));
  @@ -496,6 +504,7 @@ BOOST_AUTO_TEST_CASE(knapsack_solver_test)
  fails++;
  }
  BOOST_CHECK_NE(fails, RANDOM_REPEATS);
  + }
  // add 75 cents in small change. not enough to make 90 cents,
  // then try making 90 cents. there are multiple competing "smallest bigger" coins,
  @@ -506,7 +515,8 @@ BOOST_AUTO_TEST_CASE(knapsack_solver_test)
  add_coin(20 * CENT);
  add_coin(25 * CENT);
  - fails = 0;
  + for (int i = 0; i < RUN_TESTS; i++) {
  + int fails = 0;
  for (int j = 0; j < RANDOM_REPEATS; j++)
  {
  // selecting 1 from 100 identical coins depends on the shuffle; this test will fail 1% of the time
  @@ -519,6 +529,7 @@ BOOST_AUTO_TEST_CASE(knapsack_solver_test)
  BOOST_CHECK_NE(fails, RANDOM_REPEATS);
  }
  }
  +
  empty_wallet();
  }
  