Skip to content

Commit

Permalink
test: Retry RPC commands to try to fix MacOS CI jobs (XRPLF#5120)
Browse files Browse the repository at this point in the history
* Retry some failed RPC connections / commands in unit tests
* Remove orphaned `getAccounts` function

Co-authored-by: John Freeman <jfreeman08@gmail.com>
  • Loading branch information
ximinez and thejohnfreeman authored Sep 11, 2024
1 parent cc0177b commit 23991c9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 28 deletions.
28 changes: 18 additions & 10 deletions src/test/jtx/impl/Env.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,16 +317,24 @@ Env::submit(JTx const& jt)
auto const jr = [&]() {
if (jt.stx)
{
txid_ = jt.stx->getTransactionID();
Serializer s;
jt.stx->add(s);
auto const jr = rpc("submit", strHex(s.slice()));

parsedResult = parseResult(jr);
test.expect(parsedResult.ter, "ter uninitialized!");
ter_ = parsedResult.ter.value_or(telENV_RPC_FAILED);

return jr;
// We shouldn't need to retry, but it fixes the test on macOS for
// the moment.
int retries = 3;
do
{
txid_ = jt.stx->getTransactionID();
Serializer s;
jt.stx->add(s);
auto const jr = rpc("submit", strHex(s.slice()));

parsedResult = parseResult(jr);
test.expect(parsedResult.ter, "ter uninitialized!");
ter_ = parsedResult.ter.value_or(telENV_RPC_FAILED);
if (ter_ != telENV_RPC_FAILED ||
parsedResult.rpcCode != rpcINTERNAL ||
jt.ter == telENV_RPC_FAILED || --retries <= 0)
return jr;
} while (true);
}
else
{
Expand Down
18 changes: 0 additions & 18 deletions src/xrpld/app/misc/NetworkOPs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2783,24 +2783,6 @@ NetworkOPsImp::pubProposedTransaction(
pubProposedAccountTransaction(ledger, transaction, result);
}

static void
getAccounts(Json::Value const& jvObj, std::vector<AccountID>& accounts)
{
for (auto& jv : jvObj)
{
if (jv.isObject())
{
getAccounts(jv, accounts);
}
else if (jv.isString())
{
auto account = RPC::accountFromStringStrict(jv.asString());
if (account)
accounts.push_back(*account);
}
}
}

void
NetworkOPsImp::pubLedger(std::shared_ptr<ReadView const> const& lpAccepted)
{
Expand Down

0 comments on commit 23991c9

Please sign in to comment.