Fix some overly-strict privacy policies in btest

These were introduced earlier in this PR, but they were incorrect.
This commit is contained in:
Greg Pfeil 2023-01-31 13:05:52 -07:00
parent 47f15811d8
commit 71c0dad1a1
No known key found for this signature in database
GPG Key ID: 1193ACD196ED61F2
1 changed files with 14 additions and 15 deletions

View File

@ -87,8 +87,6 @@ static SaplingPaymentAddress DefaultSaplingAddress(CWallet* pwallet) {
.FindAddress(libzcash::diversifier_index_t(0)).first; .FindAddress(libzcash::diversifier_index_t(0)).first;
} }
auto FULL_PRIVACY = TransactionStrategy(PrivacyPolicy::FullPrivacy);
BOOST_FIXTURE_TEST_SUITE(rpc_wallet_tests, WalletTestingSetup) BOOST_FIXTURE_TEST_SUITE(rpc_wallet_tests, WalletTestingSetup)
BOOST_AUTO_TEST_CASE(rpc_addmultisig) BOOST_AUTO_TEST_CASE(rpc_addmultisig)
@ -158,7 +156,7 @@ BOOST_AUTO_TEST_CASE(rpc_wallet)
BOOST_CHECK_THROW(CallRPC("getbalance " + keyIO.EncodeDestination(demoAddress)), runtime_error); BOOST_CHECK_THROW(CallRPC("getbalance " + keyIO.EncodeDestination(demoAddress)), runtime_error);
/********************************* /*********************************
* listunspent * listunspent
*********************************/ *********************************/
BOOST_CHECK_NO_THROW(CallRPC("listunspent")); BOOST_CHECK_NO_THROW(CallRPC("listunspent"));
BOOST_CHECK_THROW(CallRPC("listunspent string"), runtime_error); BOOST_CHECK_THROW(CallRPC("listunspent string"), runtime_error);
@ -169,7 +167,7 @@ BOOST_AUTO_TEST_CASE(rpc_wallet)
BOOST_CHECK(r.get_array().empty()); BOOST_CHECK(r.get_array().empty());
/********************************* /*********************************
* listreceivedbyaddress * listreceivedbyaddress
*********************************/ *********************************/
BOOST_CHECK_NO_THROW(CallRPC("listreceivedbyaddress")); BOOST_CHECK_NO_THROW(CallRPC("listreceivedbyaddress"));
BOOST_CHECK_NO_THROW(CallRPC("listreceivedbyaddress 0")); BOOST_CHECK_NO_THROW(CallRPC("listreceivedbyaddress 0"));
@ -203,22 +201,22 @@ BOOST_AUTO_TEST_CASE(rpc_wallet)
BOOST_CHECK_NO_THROW(CallRPC("listaddressgroupings")); BOOST_CHECK_NO_THROW(CallRPC("listaddressgroupings"));
/********************************* /*********************************
* walletconfirmbackup * walletconfirmbackup
*********************************/ *********************************/
BOOST_CHECK_THROW(CallRPC(string("walletconfirmbackup \"badmnemonic\"")), runtime_error); BOOST_CHECK_THROW(CallRPC(string("walletconfirmbackup \"badmnemonic\"")), runtime_error);
/********************************* /*********************************
* getrawchangeaddress * getrawchangeaddress
*********************************/ *********************************/
BOOST_CHECK_NO_THROW(CallRPC("getrawchangeaddress")); BOOST_CHECK_NO_THROW(CallRPC("getrawchangeaddress"));
/********************************* /*********************************
* getnewaddress * getnewaddress
*********************************/ *********************************/
BOOST_CHECK_NO_THROW(CallRPC("getnewaddress")); BOOST_CHECK_NO_THROW(CallRPC("getnewaddress"));
/********************************* /*********************************
* signmessage + verifymessage * signmessage + verifymessage
*********************************/ *********************************/
BOOST_CHECK_NO_THROW(retValue = CallRPC("signmessage " + keyIO.EncodeDestination(demoAddress) + " mymessage")); BOOST_CHECK_NO_THROW(retValue = CallRPC("signmessage " + keyIO.EncodeDestination(demoAddress) + " mymessage"));
BOOST_CHECK_THROW(CallRPC("signmessage"), runtime_error); BOOST_CHECK_THROW(CallRPC("signmessage"), runtime_error);
@ -238,7 +236,7 @@ BOOST_AUTO_TEST_CASE(rpc_wallet)
BOOST_CHECK(CallRPC("verifymessage " + keyIO.EncodeDestination(demoAddress) + " " + retValue.get_str() + " mymessage").get_bool() == true); BOOST_CHECK(CallRPC("verifymessage " + keyIO.EncodeDestination(demoAddress) + " " + retValue.get_str() + " mymessage").get_bool() == true);
/********************************* /*********************************
* listaddresses * listaddresses
*********************************/ *********************************/
BOOST_CHECK_NO_THROW(retValue = CallRPC("listaddresses")); BOOST_CHECK_NO_THROW(retValue = CallRPC("listaddresses"));
UniValue arr = retValue.get_array(); UniValue arr = retValue.get_array();
@ -260,7 +258,7 @@ BOOST_AUTO_TEST_CASE(rpc_wallet)
} }
/********************************* /*********************************
* fundrawtransaction * fundrawtransaction
*********************************/ *********************************/
BOOST_CHECK_THROW(CallRPC("fundrawtransaction 28z"), runtime_error); BOOST_CHECK_THROW(CallRPC("fundrawtransaction 28z"), runtime_error);
BOOST_CHECK_THROW(CallRPC("fundrawtransaction 01000000000180969800000000001976a91450ce0a4b0ee0ddeb633da85199728b940ac3fe9488ac00000000"), runtime_error); BOOST_CHECK_THROW(CallRPC("fundrawtransaction 01000000000180969800000000001976a91450ce0a4b0ee0ddeb633da85199728b940ac3fe9488ac00000000"), runtime_error);
@ -804,7 +802,8 @@ void CheckHaveAddr(const std::optional<libzcash::PaymentAddress>& addr) {
auto addr_of_type = std::get_if<ADDR_TYPE>(&(addr.value())); auto addr_of_type = std::get_if<ADDR_TYPE>(&(addr.value()));
BOOST_ASSERT(addr_of_type != nullptr); BOOST_ASSERT(addr_of_type != nullptr);
BOOST_CHECK(pwalletMain->ZTXOSelectorForAddress(*addr_of_type, true, false, FULL_PRIVACY).has_value()); TransactionStrategy strategy(PrivacyPolicy::FullPrivacy);
BOOST_CHECK(pwalletMain->ZTXOSelectorForAddress(*addr_of_type, true, false, strategy).has_value());
} }
BOOST_AUTO_TEST_CASE(rpc_wallet_z_getnewaddress) { BOOST_AUTO_TEST_CASE(rpc_wallet_z_getnewaddress) {
@ -1238,10 +1237,10 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals)
// there are no utxos to spend // there are no utxos to spend
{ {
auto selector = pwalletMain->ZTXOSelectorForAddress(taddr1, true, false, FULL_PRIVACY).value(); TransactionStrategy strategy(PrivacyPolicy::AllowRevealedSenders);
auto selector = pwalletMain->ZTXOSelectorForAddress(taddr1, true, false, strategy).value();
WalletTxBuilder builder(Params(), *pwalletMain, minRelayTxFee); WalletTxBuilder builder(Params(), *pwalletMain, minRelayTxFee);
std::vector<Payment> recipients = { Payment(zaddr1, 100*COIN, Memo::FromHexOrThrow("DEADBEEF")) }; std::vector<Payment> recipients = { Payment(zaddr1, 100*COIN, Memo::FromHexOrThrow("DEADBEEF")) };
TransactionStrategy strategy;
std::shared_ptr<AsyncRPCOperation> operation(new AsyncRPCOperation_sendmany(std::move(builder), selector, recipients, 1, 1, strategy)); std::shared_ptr<AsyncRPCOperation> operation(new AsyncRPCOperation_sendmany(std::move(builder), selector, recipients, 1, 1, strategy));
operation->main(); operation->main();
BOOST_CHECK(operation->isFailed()); BOOST_CHECK(operation->isFailed());
@ -1251,10 +1250,10 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals)
// there are no unspent notes to spend // there are no unspent notes to spend
{ {
auto selector = pwalletMain->ZTXOSelectorForAddress(zaddr1, true, false, FULL_PRIVACY).value(); TransactionStrategy strategy(PrivacyPolicy::AllowRevealedRecipients);
auto selector = pwalletMain->ZTXOSelectorForAddress(zaddr1, true, false, strategy).value();
WalletTxBuilder builder(Params(), *pwalletMain, minRelayTxFee); WalletTxBuilder builder(Params(), *pwalletMain, minRelayTxFee);
std::vector<Payment> recipients = { Payment(taddr1, 100*COIN, Memo::FromHexOrThrow("DEADBEEF")) }; std::vector<Payment> recipients = { Payment(taddr1, 100*COIN, Memo::FromHexOrThrow("DEADBEEF")) };
TransactionStrategy strategy(PrivacyPolicy::AllowRevealedRecipients);
std::shared_ptr<AsyncRPCOperation> operation(new AsyncRPCOperation_sendmany(std::move(builder), selector, recipients, 1, 1, strategy)); std::shared_ptr<AsyncRPCOperation> operation(new AsyncRPCOperation_sendmany(std::move(builder), selector, recipients, 1, 1, strategy));
operation->main(); operation->main();
BOOST_CHECK(operation->isFailed()); BOOST_CHECK(operation->isFailed());