Skip to content

Commit

Permalink
chore: remove MinerEnabled variant from StratusError (#1738)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospb19-cw authored Sep 27, 2024
1 parent 0cd8c5f commit a040285
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ describe("Leader & Follower change integration test", function () {
"100ms",
]);
expect(response.data.error.code).to.equal(-32603);
expect(response.data.error.message).to.equal("Miner is enabled.");
expect(response.data.error.message.split("\n")[0]).to.equal(
"Unexpected error: can't change miner mode from Interval without pausing it first",
);
});

it("Change Leader to Follower should succeed", async function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ describe("Miner mode change integration test", function () {
updateProviderUrl("stratus");
const response = await sendAndGetFullResponse("stratus_changeMinerMode", ["external"]);
expect(response.data.error.code).eq(-32603);
expect(response.data.error.message).eq("Miner is enabled.");
expect(response.data.error.message.split("\n")[0]).to.equal(
"Unexpected error: can't change miner mode from Interval without pausing it first",
);
});

it("Miner change to Interval on Follower should fail because importer wasn't stopped", async function () {
Expand Down
4 changes: 2 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,13 @@ e2e-leader-follower-up test="brlc":
mkdir e2e_logs

# Start Stratus with leader flag
RUST_LOG=info cargo run --release --bin stratus --features dev -- --leader --block-mode 1s --perm-storage=rocks --rocks-path-prefix=temp_3000 --tokio-console-address=0.0.0.0:6668 --metrics-exporter-address=0.0.0.0:9000 -a 0.0.0.0:3000 > e2e_logs/stratus.log &
RUST_BACKTRACE=1 RUST_LOG=info cargo run --release --bin stratus --features dev -- --leader --block-mode 1s --perm-storage=rocks --rocks-path-prefix=temp_3000 --tokio-console-address=0.0.0.0:6668 --metrics-exporter-address=0.0.0.0:9000 -a 0.0.0.0:3000 > e2e_logs/stratus.log &

# Wait for Stratus with leader flag to start
just _wait_for_stratus 3000

# Start Stratus with follower flag
RUST_LOG=info cargo run --release --bin stratus --features dev -- --follower --perm-storage=rocks --rocks-path-prefix=temp_3001 --tokio-console-address=0.0.0.0:6669 --metrics-exporter-address=0.0.0.0:9001 -a 0.0.0.0:3001 -r http://0.0.0.0:3000/ -w ws://0.0.0.0:3000/ > e2e_logs/importer.log &
RUST_BACKTRACE=1 RUST_LOG=info cargo run --release --bin stratus --features dev -- --follower --perm-storage=rocks --rocks-path-prefix=temp_3001 --tokio-console-address=0.0.0.0:6669 --metrics-exporter-address=0.0.0.0:9001 -a 0.0.0.0:3001 -r http://0.0.0.0:3000/ -w ws://0.0.0.0:3000/ > e2e_logs/importer.log &

# Wait for Stratus with follower flag to start
just _wait_for_stratus 3001
Expand Down
4 changes: 0 additions & 4 deletions src/eth/primitives/stratus_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,6 @@ pub enum StratusError {
#[strum(props(kind = "internal"))]
MinerModeParamInvalid,

#[error("Miner is enabled.")]
#[strum(props(kind = "internal"))]
MinerEnabled,

// -------------------------------------------------------------------------
// Importer
// -------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/eth/rpc/rpc_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ use crate::ext::SerdeResultExt;
use crate::infra::build_info;
use crate::infra::metrics;
use crate::infra::tracing::SpanExt;
use crate::log_and_err;
use crate::GlobalState;
use crate::NodeMode;
// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -474,8 +475,7 @@ async fn change_miner_mode(new_mode: MinerMode, ctx: &RpcContext) -> Result<Json
}

if not(ctx.miner.is_paused()) && previous_mode.is_interval() {
tracing::error!("cannot change miner mode from Interval Mode to another mode without pausing it first");
return Err(StratusError::MinerEnabled);
return log_and_err!("can't change miner mode from Interval without pausing it first").map_err(Into::into);
}

match new_mode {
Expand Down

0 comments on commit a040285

Please sign in to comment.