Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail load gen if soroban invoke without setup #4564

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/simulation/LoadGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,11 @@ LoadGenerator::start(GeneratedLoadConfig& cfg)
{
// start is incomplete, so reset to avoid leaving the
// LoadGenerator in an invalid state.
reset();
throw std::runtime_error(
"Before running MODE::SOROBAN_INVOKE, please run "
"MODE::SOROBAN_INVOKE_SETUP to set up your contract "
"first.");
CLOG_ERROR(LoadGen, "Before running MODE::SOROBAN_INVOKE, "
"please run MODE::SOROBAN_INVOKE_SETUP to "
"set up your contract first.");
emitFailure(/*resetSoroban=*/true);
return;
}
releaseAssert(mContractInstances.empty());
releaseAssert(mAccountsAvailable.size() >= cfg.nAccounts);
Expand Down
23 changes: 12 additions & 11 deletions src/simulation/test/LoadGeneratorTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,17 +225,18 @@ TEST_CASE("generate soroban load", "[loadgen][soroban]")
SECTION("misconfigured soroban loadgen mode usage")
{
// Users are required to run SOROBAN_INVOKE_SETUP_LOAD before running
// SOROBAN_INVOKE_LOAD. Running a SOROBAN_INVOKE_LOAD without a prior
// SOROBAN_INVOKE_SETUP_LOAD should throw a helpful exception explaining
// the misconfiguration.
auto invokeLoadCfg =
GeneratedLoadConfig::txLoad(LoadGenMode::SOROBAN_INVOKE,
/* nAccounts*/ 1, /* numSorobanTxs */ 1,
/* txRate */ 1);
REQUIRE_THROWS_WITH(
loadGen.generateLoad(invokeLoadCfg),
"Before running MODE::SOROBAN_INVOKE, please run "
"MODE::SOROBAN_INVOKE_SETUP to set up your contract first.");
// SOROBAN_INVOKE_LOAD. If they do not, load generation will fail. An
// error message will be logged and `loadgen.run.failed` will be
// incremented.
auto invokeLoadCfg = GeneratedLoadConfig::txLoad(
LoadGenMode::SOROBAN_INVOKE,
/* nAccounts */ 1, /* numSorobanTxs */ 1,
/* txRate */ 1);
auto& loadGenFailed =
app.getMetrics().NewMeter({"loadgen", "run", "failed"}, "run");
auto failedCount = loadGenFailed.count();
loadGen.generateLoad(invokeLoadCfg);
REQUIRE(loadGenFailed.count() == failedCount + 1);
}
int64_t numTxsBefore = getSuccessfulTxCount();

Expand Down
Loading