Skip to content

Commit 8313843

Browse files
committed
Fail load gen if soroban invoke without setup.
1 parent fdd833d commit 8313843

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

src/simulation/LoadGenerator.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,11 @@ LoadGenerator::start(GeneratedLoadConfig& cfg)
352352
{
353353
// start is incomplete, so reset to avoid leaving the
354354
// LoadGenerator in an invalid state.
355-
reset();
356-
throw std::runtime_error(
357-
"Before running MODE::SOROBAN_INVOKE, please run "
358-
"MODE::SOROBAN_INVOKE_SETUP to set up your contract "
359-
"first.");
355+
CLOG_ERROR(LoadGen, "Before running MODE::SOROBAN_INVOKE, "
356+
"please run MODE::SOROBAN_INVOKE_SETUP to "
357+
"set up your contract first.");
358+
emitFailure(/*resetSoroban=*/true);
359+
return;
360360
}
361361
releaseAssert(mContractInstances.empty());
362362
releaseAssert(mAccountsAvailable.size() >= cfg.nAccounts);

src/simulation/test/LoadGeneratorTests.cpp

+12-11
Original file line numberDiff line numberDiff line change
@@ -225,17 +225,18 @@ TEST_CASE("generate soroban load", "[loadgen][soroban]")
225225
SECTION("misconfigured soroban loadgen mode usage")
226226
{
227227
// Users are required to run SOROBAN_INVOKE_SETUP_LOAD before running
228-
// SOROBAN_INVOKE_LOAD. Running a SOROBAN_INVOKE_LOAD without a prior
229-
// SOROBAN_INVOKE_SETUP_LOAD should throw a helpful exception explaining
230-
// the misconfiguration.
231-
auto invokeLoadCfg =
232-
GeneratedLoadConfig::txLoad(LoadGenMode::SOROBAN_INVOKE,
233-
/* nAccounts*/ 1, /* numSorobanTxs */ 1,
234-
/* txRate */ 1);
235-
REQUIRE_THROWS_WITH(
236-
loadGen.generateLoad(invokeLoadCfg),
237-
"Before running MODE::SOROBAN_INVOKE, please run "
238-
"MODE::SOROBAN_INVOKE_SETUP to set up your contract first.");
228+
// SOROBAN_INVOKE_LOAD. If they do not, load generation will fail. An
229+
// error message will be logged and `loadgen.run.failed` will be
230+
// incremented.
231+
auto invokeLoadCfg = GeneratedLoadConfig::txLoad(
232+
LoadGenMode::SOROBAN_INVOKE,
233+
/* nAccounts */ 1, /* numSorobanTxs */ 1,
234+
/* txRate */ 1);
235+
auto& loadGenFailed =
236+
app.getMetrics().NewMeter({"loadgen", "run", "failed"}, "run");
237+
auto failedCount = loadGenFailed.count();
238+
loadGen.generateLoad(invokeLoadCfg);
239+
REQUIRE(loadGenFailed.count() == failedCount + 1);
239240
}
240241
int64_t numTxsBefore = getSuccessfulTxCount();
241242

0 commit comments

Comments
 (0)