add autofill + refactor (#54)

This commit is contained in:
Denis Angell
2023-03-28 18:11:13 +00:00
parent e71137fe4a
commit 81d795dcfc
3 changed files with 34 additions and 10 deletions

View File

@@ -47,9 +47,7 @@ public:
void
testNetworkID()
{
testcase(
"Require txn NetworkID to be specified (or not) depending on the "
"network ID of the node");
testcase("network_id");
using namespace jtx;
auto const alice = Account{"alice"};
@@ -67,14 +65,9 @@ public:
jv[jss::Destination] = alice.human();
jv[jss::TransactionType] = "Payment";
jv[jss::Amount] = "10000000000";
if (env.app().config().NETWORK_ID > 1024)
jv[jss::NetworkID] =
std::to_string(env.app().config().NETWORK_ID);
env(jv, fee(1000), sig(env.master));
}
// run tx
env(jv, fee(1000), ter(expectedOutcome));
env.close();
};
@@ -127,11 +120,25 @@ public:
test::jtx::Env env{*this, makeNetworkConfig(1025)};
BEAST_EXPECT(env.app().config().NETWORK_ID == 1025);
// try to submit a txn without network id, this should not work
{
env.fund(XRP(200), alice);
// try to submit a txn without network id, this should not work
Json::Value jvn;
jvn[jss::Account] = alice.human();
jvn[jss::TransactionType] = jss::AccountSet;
jvn[jss::Fee] = to_string(env.current()->fees().base);
jvn[jss::Sequence] = env.seq(alice);
jvn[jss::LastLedgerSequence] = env.current()->info().seq + 2;
auto jt = env.jtnofill(jvn);
Serializer s;
jt.stx->add(s);
BEAST_EXPECT(env.rpc("submit", strHex(s.slice()))[jss::result][jss::engine_result] == "telREQUIRES_NETWORK_ID");
env.close();
}
Json::Value jv;
jv[jss::Account] = alice.human();
jv[jss::TransactionType] = jss::AccountSet;
runTx(env, jv, telREQUIRES_NETWORK_ID);
// try to submit with wrong network id
jv[jss::NetworkID] = 0;