Skip to content

Commit 607303c

Browse files
committed
Get tests passing.
1 parent 1fc1cf8 commit 607303c

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

packages/protocol/src/protocol/Protocol.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,6 @@ export class Protocol<
132132
public create(childContainerProvider: ChildContainerProvider) {
133133
super.create(childContainerProvider);
134134

135-
const runtime: ModuleContainer<any> = this.container.resolve("Runtime");
136-
runtime.moduleNames.forEach((runtimeModuleName) => {
137-
this.container.register(runtimeModuleName, {
138-
useFactory: (dependencyContainer) => {
139-
return runtime.resolve(runtimeModuleName);
140-
},
141-
});
142-
});
143-
144135
// Register the BlockModules seperately since we need to
145136
// inject them differently later
146137
const ABSTRACT_MODULE_TYPES = [
@@ -189,6 +180,15 @@ export class Protocol<
189180
);
190181
}
191182
});
183+
184+
const runtime: ModuleContainer<any> = this.container.resolve("Runtime");
185+
runtime.moduleNames.forEach((runtimeModuleName) => {
186+
this.container.register(runtimeModuleName, {
187+
useFactory: (dependencyContainer) => {
188+
return runtime.resolve(runtimeModuleName);
189+
},
190+
});
191+
});
192192
}
193193

194194
public async start() {

packages/protocol/test/TestingProtocol.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1-
import { WithZkProgrammable, ZkProgrammable } from "@proto-kit/common";
21
import { container } from "tsyringe";
2+
import { Runtime } from "@proto-kit/module";
3+
import { Balance } from "@proto-kit/sequencer/test/integration/mocks/Balance";
4+
import { NoopRuntime } from "@proto-kit/sequencer/test/integration/mocks/NoopRuntime";
35

46
import {
57
AccountStateHook,
68
BlockHeightHook,
79
BlockProver,
810
LastStateRootBlockHook,
9-
MethodPublicOutput,
1011
Protocol,
1112
StateTransitionProver,
1213
} from "../src";
1314

14-
class RuntimeMock implements WithZkProgrammable<undefined, MethodPublicOutput> {
15-
zkProgrammable: ZkProgrammable<undefined, MethodPublicOutput> =
16-
undefined as unknown as ZkProgrammable<undefined, MethodPublicOutput>;
17-
}
18-
1915
export function createAndInitTestingProtocol() {
2016
const ProtocolClass = Protocol.from({
2117
modules: {
@@ -35,11 +31,22 @@ export function createAndInitTestingProtocol() {
3531
StateTransitionProver: {},
3632
LastStateRoot: {},
3733
});
38-
protocol.create(() => container.createChildContainer());
3934

40-
protocol.registerValue({
41-
Runtime: new RuntimeMock(),
35+
const appChain = container.createChildContainer();
36+
37+
appChain.register("Runtime", {
38+
useClass: Runtime.from({
39+
modules: {
40+
Balance,
41+
NoopRuntime,
42+
},
43+
config: {
44+
Balance: {},
45+
NoopRuntime: {},
46+
},
47+
}),
4248
});
49+
protocol.create(() => appChain.createChildContainer());
4350

4451
return protocol;
4552
}

0 commit comments

Comments
 (0)