Skip to content

Commit a0711c8

Browse files
test(evm-state): increase unit tests coverage (#1289)
* Test service-provider * Rename variable * Rename parameter * Test state * Fix test * Rename variable
1 parent df56f26 commit a0711c8

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Identifiers } from "@mainsail/constants";
2+
3+
import { Application } from "@mainsail/kernel";
4+
5+
import { describe } from "@mainsail/test-runner";
6+
import { ServiceProvider } from "./service-provider";
7+
8+
describe<{
9+
app: Application;
10+
serviceProvider: ServiceProvider;
11+
}>("ServiceProvider", ({ beforeEach, it, assert }) => {
12+
beforeEach((context) => {
13+
const app = new Application();
14+
15+
context.serviceProvider = app.resolve(ServiceProvider);
16+
context.app = app;
17+
});
18+
19+
it("#register - should be ok", async ({ serviceProvider, app }) => {
20+
await serviceProvider.register();
21+
22+
assert.true(app.isBound(Identifiers.Evm.State));
23+
});
24+
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { Application } from "@mainsail/kernel";
2+
import type { Contracts } from "@mainsail/contracts";
3+
4+
import { describe } from "@mainsail/test-runner";
5+
import { State } from "./state";
6+
7+
describe<{
8+
state: Contracts.Evm.State;
9+
}>("ServiceProvider", ({ beforeEach, it, assert }) => {
10+
beforeEach((context) => {
11+
const app = new Application();
12+
context.state = app.resolve(State);
13+
});
14+
15+
it("#peerCount - should have default value 0", async ({ state }) => {
16+
assert.equal(state.peerCount, 0);
17+
});
18+
19+
it("#peerCount - should be set and read", async ({ state }) => {
20+
state.peerCount = 5;
21+
assert.equal(state.peerCount, 5);
22+
});
23+
});

0 commit comments

Comments
 (0)