Nicholas Rogers
Nicholas Rogers

Reputation: 360

How do Mock Network Nodes persist data?

It seems that MockNodes created by the MockNetwork are able to persist data without H2 (or some other in-memory DB). Is this just an in-memory class? Or are mock nodes spinning up an H2 instance in the background somewhere?

Where is this defined in the Corda OS codebase? I've looked through MockNetwork, InternalMockNetwork, MockNode, TestStartedNode, MockNodeParameters.

Upvotes: 0

Views: 51

Answers (1)

Austin Moothart
Austin Moothart

Reputation: 378

Generally speaking each Corda class which stores data of any kind has a parallel implementation which uses mock storage. For example the MockTransactionStorage uses an in memory HashMap for storing transaction objects: https://github.com/corda/corda/blob/release/os/4.3/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/MockTransactionStorage.kt

A second example would be MockAttachmentStorage which uses a HashMap to store files: https://github.com/corda/corda/blob/release/os/4.3/testing/test-utils/src/main/kotlin/net/corda/testing/services/MockAttachmentStorage.kt

Upvotes: 1

Related Questions