Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

fix: don't return an error from miner_start if already started #1662

Merged
merged 1 commit into from
Nov 25, 2021
Merged
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
11 changes: 8 additions & 3 deletions src/chains/ethereum/ethereum/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -592,9 +592,14 @@ export default class EthereumApi implements Api {
@assertArgLength(0, 1)
async miner_start(threads: number = 1) {
if (this.#options.miner.legacyInstamine === true) {
const { transactions } = await this.#blockchain.resume(threads);
if (transactions != null && this.#options.chain.vmErrorsOnRPCResponse) {
assertExceptionalTransactions(transactions);
const resumption = await this.#blockchain.resume(threads);
// resumption can be undefined if the blockchain isn't currently paused
if (
resumption &&
resumption.transactions != null &&
this.#options.chain.vmErrorsOnRPCResponse
) {
assertExceptionalTransactions(resumption.transactions);
}
} else {
this.#blockchain.resume(threads);
Expand Down
8 changes: 8 additions & 0 deletions src/chains/ethereum/ethereum/tests/api/miner/miner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ describe("api", () => {
const provider = await getProvider({ miner: { blockTime: 1 } });
await testStopStartMining(provider);
}).timeout(4000);

it("should not throw an error when miner was already started when calling miner_start", async () => {
const provider = await getProvider({
miner: { blockTime: 1, legacyInstamine: true }
});
await assert.doesNotReject(provider.send("miner_start"));
await assert.doesNotReject(provider.send("miner_start"));
}).timeout(4000);
});

describe("miner_setEtherbase", () => {
Expand Down