Skip to content

Commit

Permalink
Debug logs in e2e test for utt privacy feature
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrychow committed Nov 15, 2022
1 parent b7891f0 commit cfe5ba1
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions utt/e2e/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#include "wallet.hpp"
#include <iostream>
#include <unistd.h>
#include <xutils/Log.h>

using namespace libutt;

Admin::Channel createAdminChannel(grpc::ClientContext &ctxAdmin) {
Admin::Connection connAdmin;
Expand Down Expand Up @@ -49,21 +52,21 @@ int main(int argc, char *argv[]) {

config = Wallet::getPublicConfig(chanWallet);

std::cout << "Configure wallet 1\n";
logdbg << "Configuring wallets 1 - 3" << std::endl;
wallet1 = std::make_unique<Wallet>("user-1", pki, config);
wallet1->registerUser(chanWallet);

std::cout << "Configure wallet 3\n";
logdbg << "Configuring wallet3" << std::endl;
wallet3 = std::make_unique<Wallet>("user-3", pki, config);
wallet3->registerUser(chanWallet);

std::cout << "Configure wallet 2\n";
logdbg << "Configuring wallet2" << std::endl;
wallet2 = std::make_unique<Wallet>("user-2", pki, config);
wallet2->registerUser(chanWallet);

logdbg << "Wallets configured. Minting and creating privacy budget..." << std::endl;
wallet1->mint(chanWallet, 2000);
Admin::createPrivacyBudget(chanAdmin, "user-1", 10000);
// logdbg << "Private funds minted" << endl;
sleep(5);
uint64_t publicBalance, privateBalance;
const uint64_t EXPECTED_PUBLIC_BALANCE_1_BEFORE = 8000;
Expand All @@ -72,15 +75,16 @@ int main(int argc, char *argv[]) {
const uint64_t EXPECTED_PRIVATE_BALANCE_2_BEFORE = 0;

std::tie(publicBalance, privateBalance) = wallet1->getPublicAndPrivateBalance(chanWallet);
std::cout << "publicBalance1: " << publicBalance << ", privateBalance1: " << privateBalance << "\n";
logdbg << "publicBalance1 before: " << publicBalance << ", privateBalance1 before: " << privateBalance << std::endl;
if (publicBalance != EXPECTED_PUBLIC_BALANCE_1_BEFORE or privateBalance != EXPECTED_PRIVATE_BALANCE_1_BEFORE)
return 1;

std::tie(publicBalance, privateBalance) = wallet2->getPublicAndPrivateBalance(chanWallet);
std::cout << "publicBalance2: " << publicBalance << ", privateBalance2: " << privateBalance << "\n";
logdbg << "publicBalance2 before: " << publicBalance << ", privateBalance2 before: " << privateBalance << std::endl;
if (publicBalance != EXPECTED_PUBLIC_BALANCE_2_BEFORE or privateBalance != EXPECTED_PRIVATE_BALANCE_2_BEFORE)
return 1;

logdbg << "Performing transfer and burn" << std::endl;
wallet1->transfer(chanWallet, 800, "user-2");
wallet1->burn(chanWallet, 700);

Expand All @@ -90,13 +94,13 @@ int main(int argc, char *argv[]) {
const uint64_t EXPECTED_PRIVATE_BALANCE_2_AFTER = 800;

std::tie(publicBalance, privateBalance) = wallet1->getPublicAndPrivateBalance(chanWallet);
std::cout << "publicBalance1: " << publicBalance << ", privateBalance1: " << privateBalance << "\n";
logdbg << "publicBalance1 after: " << publicBalance << ", privateBalance1 after: " << privateBalance << "\n";
if (publicBalance != EXPECTED_PUBLIC_BALANCE_1_AFTER or privateBalance != EXPECTED_PRIVATE_BALANCE_1_AFTER) return 1;

std::tie(publicBalance, privateBalance) = wallet2->getPublicAndPrivateBalance(chanWallet);
std::cout << "publicBalance2: " << publicBalance << ", privateBalance2: " << privateBalance << "\n";
logdbg << "publicBalance2 after: " << publicBalance << ", privateBalance2 after: " << privateBalance << "\n";
if (publicBalance != EXPECTED_PUBLIC_BALANCE_2_AFTER or privateBalance != EXPECTED_PRIVATE_BALANCE_2_AFTER) return 1;

std::cout << "TEST PASSED\n";
logdbg << "TEST PASSED\n";
return 0;
}

0 comments on commit cfe5ba1

Please sign in to comment.