jtx: json, memo funclets, fixes, improvements:

* Add json funclet
* Add memo funclet
* Add Env::trace
* Add PrettAmount regression test
* Fix PrettyAmount construction
* Make Env::trust balance-neutral
* Log parse errors during signing
This commit is contained in:
Vinnie Falco
2015-06-18 12:47:39 -07:00
parent 0062a260b9
commit cd5e36045c
12 changed files with 466 additions and 5 deletions

View File

@@ -175,10 +175,17 @@ void
Env::trust (STAmount const& amount,
Account const& account)
{
auto const start = balance(account);
apply(jtx::trust(account, amount),
jtx::seq(jtx::autofill),
fee(jtx::autofill),
sig(jtx::autofill));
apply(pay(master, account,
drops(ledger->getBaseFee())),
jtx::seq(jtx::autofill),
fee(jtx::autofill),
sig(jtx::autofill));
test.expect(balance(account) == start);
}
void
@@ -211,6 +218,12 @@ Env::submit (JTx const& jt)
// we didn't get the expected result.
return;
}
if (trace_)
{
if (trace_ > 0)
--trace_;
test.log << pretty(jt.jv);
}
for (auto const& f : jt.requires)
f(*this);
}
@@ -243,7 +256,17 @@ Env::autofill (JTx& jt)
if(jt.fill_seq)
jtx::fill_seq(jv, *ledger);
// Must come last
autofill_sig(jt);
try
{
autofill_sig(jt);
}
catch (parse_error const&)
{
test.log <<
"parse failed:\n" <<
pretty(jv);
throw;
}
}
std::shared_ptr<STTx>