Skip to content

Commit

Permalink
Replaced BOOST_ASSERT with Assert
Browse files Browse the repository at this point in the history
  • Loading branch information
mxaddict committed Feb 13, 2024
1 parent 62866be commit 89c15f4
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions src/test/blsct/wallet/address_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ BOOST_FIXTURE_TEST_CASE(address_test, BasicTestingSetup)
blsct::PublicKey viewKey;
blsct::PublicKey spendKey;

BOOST_ASSERT(subAddressDoubleKey.GetViewKey(viewKey));
BOOST_ASSERT(subAddressDoubleKey.GetSpendKey(spendKey));
Assert(subAddressDoubleKey.GetViewKey(viewKey));
Assert(subAddressDoubleKey.GetSpendKey(spendKey));

BOOST_CHECK(viewKey.ToString() == "809ad665b3de4e1d44d835f1b8de36aafeea3279871aeceb56dbdda90c0426c022e8a6dda7313dc5e4c1817287805e3b");

Expand Down
4 changes: 2 additions & 2 deletions src/test/blsct/wallet/chain_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ BOOST_FIXTURE_TEST_CASE(SyncTest, TestBLSCTChain100Setup)
auto available_coins = AvailableCoins(*wallet);
std::vector<COutput> coins = available_coins.All();

BOOST_ASSERT(coins.size() == 1);
Assert(coins.size() == 1);

// Create Transaction sending to another address
auto tx = blsct::TxFactory::CreateTransaction(wallet.get(), wallet->GetOrCreateBLSCTKeyMan(), blsct::SubAddress(), 1 * COIN, "test");

BOOST_ASSERT(tx != std::nullopt);
Assert(tx != std::nullopt);

auto block = CreateAndProcessBlock({tx.value()}, walletDestination);

Expand Down
38 changes: 19 additions & 19 deletions src/test/blsct/wallet/txfactory_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ BOOST_FIXTURE_TEST_CASE(ismine_test, TestingSetup)
auto recvAddress = std::get<blsct::DoublePublicKey>(blsct_km->GetNewDestination(0).value());

auto out = blsct::CreateOutput(recvAddress, 1000, "test");
BOOST_ASSERT(blsct_km->IsMine(out.out));
Assert(blsct_km->IsMine(out.out));

auto hashId = blsct_km->GetHashId(out.out);
blsct::SubAddress subAddressId;

BOOST_ASSERT(blsct_km->GetSubAddress(hashId, subAddressId));
Assert(blsct_km->GetSubAddress(hashId, subAddressId));

auto result = blsct_km->RecoverOutputs({out.out});

Expand Down Expand Up @@ -75,36 +75,36 @@ BOOST_FIXTURE_TEST_CASE(createtransaction_test, TestingSetup)
CCoinsViewCache coins_view_cache{&base, /*deterministic=*/true};
coins_view_cache.SetBestBlock(InsecureRand256());
coins_view_cache.AddCoin(outpoint, std::move(coin), true);
BOOST_ASSERT(coins_view_cache.Flush());
Assert(coins_view_cache.Flush());
}

CCoinsViewCache coins_view_cache{&base, /*deterministic=*/true};
BOOST_ASSERT(tx.AddInput(coins_view_cache, outpoint));
Assert(tx.AddInput(coins_view_cache, outpoint));

tx.AddOutput(recvAddress, 900 * COIN, "test");

auto finalTx = tx.BuildTx();

BOOST_ASSERT(finalTx.has_value());
BOOST_ASSERT(blsct::VerifyTx(CTransaction(finalTx.value()), coins_view_cache));
Assert(finalTx.has_value());
Assert(blsct::VerifyTx(CTransaction(finalTx.value()), coins_view_cache));

bool fFoundChange = false;

// Wallet does not have the coins available yet
BOOST_ASSERT(blsct::TxFactory::CreateTransaction(wallet, wallet->GetOrCreateBLSCTKeyMan(), recvAddress, 900 * COIN, "test") == std::nullopt);
Assert(blsct::TxFactory::CreateTransaction(wallet, wallet->GetOrCreateBLSCTKeyMan(), recvAddress, 900 * COIN, "test") == std::nullopt);

auto result = blsct_km->RecoverOutputs(finalTx.value().vout);

for (auto& res : result.amounts) {
if (res.message == "Change" && res.amount == (1000 - 900 - 0.006) * COIN) fFoundChange = true;
}

BOOST_ASSERT(fFoundChange);
Assert(fFoundChange);

wallet->transactionAddedToMempool(MakeTransactionRef(finalTx.value()));

// Wallet does not have the coins available yet (not confirmed in block)
BOOST_ASSERT(blsct::TxFactory::CreateTransaction(wallet, wallet->GetOrCreateBLSCTKeyMan(), recvAddress, 900 * COIN, "test") == std::nullopt);
Assert(blsct::TxFactory::CreateTransaction(wallet, wallet->GetOrCreateBLSCTKeyMan(), recvAddress, 900 * COIN, "test") == std::nullopt);
}

BOOST_FIXTURE_TEST_CASE(addinput_test, TestingSetup)
Expand Down Expand Up @@ -137,18 +137,18 @@ BOOST_FIXTURE_TEST_CASE(addinput_test, TestingSetup)
CCoinsViewCache coins_view_cache{&base, /*deterministic=*/true};
coins_view_cache.SetBestBlock(InsecureRand256());
coins_view_cache.AddCoin(outpoint, std::move(coin), true);
BOOST_ASSERT(coins_view_cache.Flush());
Assert(coins_view_cache.Flush());
}

CCoinsViewCache coins_view_cache{&base, /*deterministic=*/true};
BOOST_ASSERT(tx.AddInput(coins_view_cache, outpoint));
Assert(tx.AddInput(coins_view_cache, outpoint));

tx.AddOutput(recvAddress, 900 * COIN, "test");

auto finalTx = tx.BuildTx();

BOOST_ASSERT(finalTx.has_value());
BOOST_ASSERT(blsct::VerifyTx(CTransaction(finalTx.value()), coins_view_cache));
Assert(finalTx.has_value());
Assert(blsct::VerifyTx(CTransaction(finalTx.value()), coins_view_cache));

bool fFoundChange = false;

Expand All @@ -158,12 +158,12 @@ BOOST_FIXTURE_TEST_CASE(addinput_test, TestingSetup)
if (res.message == "Change" && res.amount == (1000 - 900 - 0.006) * COIN) fFoundChange = true;
}

BOOST_ASSERT(fFoundChange);
Assert(fFoundChange);

wallet->transactionAddedToMempool(MakeTransactionRef(finalTx.value()));

auto wtx = wallet->GetWalletTx(finalTx.value().GetHash());
BOOST_ASSERT(wtx != nullptr);
Assert(wtx != nullptr);

fFoundChange = false;
uint32_t nChangePosition = 0;
Expand All @@ -176,7 +176,7 @@ BOOST_FIXTURE_TEST_CASE(addinput_test, TestingSetup)
}
}

BOOST_ASSERT(fFoundChange);
Assert(fFoundChange);

auto tx2 = blsct::TxFactory(blsct_km);
auto outpoint2 = COutPoint(finalTx.value().GetHash(), nChangePosition);
Expand All @@ -185,16 +185,16 @@ BOOST_FIXTURE_TEST_CASE(addinput_test, TestingSetup)
coin2.out = finalTx.value().vout[nChangePosition];
coins_view_cache.AddCoin(outpoint2, std::move(coin2), true);

BOOST_ASSERT(tx2.AddInput(coins_view_cache, outpoint2));
Assert(tx2.AddInput(coins_view_cache, outpoint2));

blsct::SubAddress randomAddress(blsct::DoublePublicKey(MclG1Point::MapToPoint("test1"), MclG1Point::MapToPoint("test2")));
tx2.AddOutput(randomAddress, 50 * COIN, "test");

auto finalTx2 = tx2.BuildTx();
wallet->transactionAddedToMempool(MakeTransactionRef(finalTx2.value()));

BOOST_ASSERT(wallet->GetDebit(CTransaction(finalTx2.value()), wallet::ISMINE_SPENDABLE_BLSCT) == (1000 - 900 - 0.006) * COIN);
BOOST_ASSERT(TxGetCredit(*wallet, CTransaction(finalTx2.value()), wallet::ISMINE_SPENDABLE_BLSCT) == (1000 - 900 - 0.006 - 50 - 0.006) * COIN);
Assert(wallet->GetDebit(CTransaction(finalTx2.value()), wallet::ISMINE_SPENDABLE_BLSCT) == (1000 - 900 - 0.006) * COIN);
Assert(TxGetCredit(*wallet, CTransaction(finalTx2.value()), wallet::ISMINE_SPENDABLE_BLSCT) == (1000 - 900 - 0.006 - 50 - 0.006) * COIN);
}

BOOST_AUTO_TEST_SUITE_END()
12 changes: 6 additions & 6 deletions src/test/blsct/wallet/validation_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ BOOST_FIXTURE_TEST_CASE(validation_test, TestingSetup)
CCoinsViewCache coins_view_cache{&base, /*deterministic=*/true};
coins_view_cache.SetBestBlock(InsecureRand256());
coins_view_cache.AddCoin(outpoint, std::move(coin), true);
BOOST_ASSERT(coins_view_cache.Flush());
Assert(coins_view_cache.Flush());
}

CCoinsViewCache coins_view_cache{&base, /*deterministic=*/true};
BOOST_ASSERT(tx.AddInput(coins_view_cache, outpoint));
Assert(tx.AddInput(coins_view_cache, outpoint));

tx.AddOutput(recvAddress, 900 * COIN, "test");

auto finalTx = tx.BuildTx();

BOOST_ASSERT(finalTx.has_value());
BOOST_ASSERT(blsct::VerifyTx(CTransaction(finalTx.value()), coins_view_cache));
Assert(finalTx.has_value());
Assert(blsct::VerifyTx(CTransaction(finalTx.value()), coins_view_cache));
}

BOOST_FIXTURE_TEST_CASE(validation_reward_test, TestingSetup)
Expand All @@ -70,8 +70,8 @@ BOOST_FIXTURE_TEST_CASE(validation_reward_test, TestingSetup)
tx.vout.push_back(out.out);
tx.txSig = out.GetSignature();

BOOST_ASSERT(!blsct::VerifyTx(CTransaction(tx), coins_view_cache));
BOOST_ASSERT(blsct::VerifyTx(CTransaction(tx), coins_view_cache, 900 * COIN));
Assert(!blsct::VerifyTx(CTransaction(tx), coins_view_cache));
Assert(blsct::VerifyTx(CTransaction(tx), coins_view_cache, 900 * COIN));
}

BOOST_AUTO_TEST_SUITE_END()
2 changes: 1 addition & 1 deletion src/wallet/test/coinselector_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ BOOST_AUTO_TEST_CASE(bnb_search_test)
CAmount selection_target = 16 * CENT;
const auto& no_res = SelectCoinsBnB(GroupCoins(available_coins.All(), /*subtract_fee_outputs*/true),
selection_target, /*cost_of_change=*/0, MAX_STANDARD_TX_WEIGHT);
BOOST_ASSERT(!no_res);
Assert(!no_res);
BOOST_CHECK(util::ErrorString(no_res).original.find("The inputs size exceeds the maximum weight") != std::string::npos);

// Now add same coin value with a good size and check that it gets selected
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/test/wallet_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,7 @@ BOOST_FIXTURE_TEST_CASE(wallet_sync_tx_invalid_state_test, TestingSetup)

// Add tx to wallet
const auto& op_dest = wallet.GetNewDestination(OutputType::BECH32M, "");
BOOST_ASSERT(op_dest);
Assert(op_dest);

CMutableTransaction mtx;
mtx.vout.push_back({COIN, GetScriptForDestination(*op_dest)});
Expand Down
4 changes: 2 additions & 2 deletions src/wallet/test/walletload_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ BOOST_FIXTURE_TEST_CASE(wallet_load_verif_crypted_key_checksum, TestingSetup)
std::unique_ptr<WalletDatabase> db = get_db(dbs);
{
CPubKey invalid_key;
BOOST_ASSERT(!invalid_key.IsValid());
Assert(!invalid_key.IsValid());
const auto key = std::make_pair(DBKeys::CRYPTED_KEY, invalid_key);
std::pair<std::vector<unsigned char>, uint256> value;
BOOST_CHECK(db->MakeBatch(false)->Write(key, value, /*fOverwrite=*/true));
Expand Down Expand Up @@ -305,7 +305,7 @@ BOOST_FIXTURE_TEST_CASE(wallet_load_verif_crypted_blsct, TestingSetup)
std::unique_ptr<WalletDatabase> db = get_db(dbs);
{
CPubKey invalid_key;
BOOST_ASSERT(!invalid_key.IsValid());
Assert(!invalid_key.IsValid());
const auto key = std::make_pair(DBKeys::CRYPTED_KEY, invalid_key);
std::pair<std::vector<unsigned char>, uint256> value;
BOOST_CHECK(db->MakeBatch(false)->Write(key, value, /*fOverwrite=*/true));
Expand Down

0 comments on commit 89c15f4

Please sign in to comment.