本文整理汇总了C++中accountframe::pointer::getBalance方法的典型用法代码示例。如果您正苦于以下问题:C++ pointer::getBalance方法的具体用法?C++ pointer::getBalance怎么用?C++ pointer::getBalance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类accountframe::pointer
的用法示例。
在下文中一共展示了pointer::getBalance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: delta
static void
doInflation(Application& app, int nbAccounts,
std::function<int64(int)> getBalance,
std::function<int(int)> getVote, int expectedWinnerCount)
{
using xdr::operator==;
// simulate the expected inflation based off the current ledger state
std::map<int, int64> balances;
// load account balances
for (int i = 0; i < nbAccounts; i++)
{
if (getBalance(i) < 0)
{
balances[i] = -1;
requireNoAccount(getTestAccount(i), app);
}
else
{
AccountFrame::pointer act;
act = loadAccount(getTestAccount(i), app);
balances[i] = act->getBalance();
// double check that inflationDest is setup properly
if (act->getAccount().inflationDest)
{
REQUIRE(getTestAccount(getVote(i)).getPublicKey() ==
*act->getAccount().inflationDest);
}
else
{
REQUIRE(getVote(i) < 0);
}
}
}
LedgerManager& lm = app.getLedgerManager();
LedgerHeader& cur = lm.getCurrentLedgerHeader();
cur.feePool = 10000;
int64 expectedTotcoins = cur.totalCoins;
int64 expectedFees = cur.feePool;
std::vector<int64> expectedBalances;
auto root = getRoot(app.getNetworkID());
TransactionFramePtr txFrame = createInflation(
app.getNetworkID(), root, getAccountSeqNum(root, app) + 1);
expectedFees += txFrame->getFee();
expectedBalances =
simulateInflation(nbAccounts, expectedTotcoins, expectedFees,
[&](int i)
{
return balances[i];
},
getVote);
// perform actual inflation
{
LedgerDelta delta(lm.getCurrentLedgerHeader(), app.getDatabase());
REQUIRE(applyCheck(txFrame, delta, app));
delta.commit();
}
// verify ledger state
LedgerHeader& cur2 = lm.getCurrentLedgerHeader();
REQUIRE(cur2.totalCoins == expectedTotcoins);
REQUIRE(cur2.feePool == expectedFees);
// verify balances
InflationResult const& infResult =
getFirstResult(*txFrame).tr().inflationResult();
auto const& payouts = infResult.payouts();
int actualChanges = 0;
for (int i = 0; i < nbAccounts; i++)
{
auto const& k = getTestAccount(i);
if (expectedBalances[i] < 0)
{
requireNoAccount(k, app);
REQUIRE(balances[i] < 0); // account didn't get deleted
}
else
{
AccountFrame::pointer act;
act = loadAccount(k, app);
REQUIRE(expectedBalances[i] == act->getBalance());
if (expectedBalances[i] != balances[i])
{
REQUIRE(balances[i] >= 0);
actualChanges++;
bool found = false;
for (auto const& p : payouts)
{
if (p.destination == k.getPublicKey())
{
//.........这里部分代码省略.........
示例2: delta
Asset idrCur = makeAsset(gateway, "IDR");
Asset usdCur = makeAsset(gateway, "USD");
// sets up gateway account
const int64_t gatewayPayment = minBalance2 + morePayment;
applyCreateAccountTx(app, root, gateway, rootSeq++, gatewayPayment);
SequenceNumber gateway_seq = getAccountSeqNum(gateway, app) + 1;
AccountFrame::pointer a1Account, rootAccount;
rootAccount = loadAccount(root, app);
a1Account = loadAccount(a1, app);
REQUIRE(rootAccount->getMasterWeight() == 1);
REQUIRE(rootAccount->getHighThreshold() == 0);
REQUIRE(rootAccount->getLowThreshold() == 0);
REQUIRE(rootAccount->getMediumThreshold() == 0);
REQUIRE(a1Account->getBalance() == paymentAmount);
REQUIRE(a1Account->getMasterWeight() == 1);
REQUIRE(a1Account->getHighThreshold() == 0);
REQUIRE(a1Account->getLowThreshold() == 0);
REQUIRE(a1Account->getMediumThreshold() == 0);
// root did 2 transactions at this point
REQUIRE(rootAccount->getBalance() ==
(100000000000000000 - paymentAmount - gatewayPayment - txfee * 2));
LedgerDelta delta(app.getLedgerManager().getCurrentLedgerHeader(),
app.getDatabase());
SECTION("Create account")
{
SECTION("Success")
{