Skip to main content

ResQ.Blockchain

MockNeoClient Class

Mock implementation of INeoClient for testing and development.
public class MockNeoClient : ResQ.Blockchain.INeoClient
Inheritance System.Object → MockNeoClient Implements INeoClient

Example

// Registration with dependency injection
services.AddSingleton<INeoClient, MockNeoClient>();

// Direct usage
var mockClient = new MockNeoClient(logger);
var result = await mockClient.RecordEventAsync(evt);
Console.WriteLine($"Mock TX: {result.TransactionHash}");

Remarks

This mock client provides an in-memory implementation of the Neo N3 blockchain interface, suitable for unit testing and local development without requiring a real blockchain connection. All operations succeed immediately and generate deterministic fake transaction hashes. Events are stored in memory and can be retrieved by incident ID. Block height increments with each transaction. No actual blockchain transactions are performed.
Constructors
MockNeoClient(ILogger<MockNeoClient>)Initializes a new instance of the MockNeoClient class.
Methods
ExtractIncidentId(string)Extracts an incident ID from a JSON payload string.
GenerateTxHash()Generates a random transaction hash for mock purposes.
GetBlockHeightAsync(CancellationToken)Gets the current mock block height.
GetEventsByIncidentAsync(string, CancellationToken)Retrieves mock events by incident ID from the in-memory store.
RecordEventAsync(BlockchainEvent, CancellationToken)Records a mock blockchain event in memory.
RecordEvidenceAsync(EvidenceRecord, CancellationToken)Records mock evidence metadata in memory.
RecordLocationAttestationAsync(LocationAttestation, CancellationToken)Records a mock location attestation in memory.
VerifyLocationAttestationAsync(LocationAttestation, CancellationToken)Verifies a location attestation in mock mode.