Part of https://plan.wireit.in/deepstack/browse/VUL-266/ Co-authored-by: Pranav <jadhavpranav89@gmail.com> Reviewed-on: LaconicNetwork/azimuth-watcher-ts#4 Co-authored-by: Nabarun <nabarun@deepstacksoft.com> Co-committed-by: Nabarun <nabarun@deepstacksoft.com>
2.6 KiB
2.6 KiB
Mock Sponsorship Events
This document describes how to inject mock sponsorship change events into the azimuth-watcher for testing purposes.
Overview
The azimuth-watcher supports injecting mock events for sponsorship changes (EscapeRequested, EscapeAccepted, EscapeCanceled, LostSponsor) via a GraphQL mutation.
Usage
Inject Mock Events
Open the GraphQL playground and run the injectMockEvents mutation:
mutation {
injectMockEvents(
events: [
{
type: ESCAPE_REQUESTED
point: 256
sponsor: 1
blockNumber: 1000
}
{
type: ESCAPE_ACCEPTED
point: 256
sponsor: 1
blockNumber: 1001
}
]
) {
success
eventsInjected
}
}
Event Types
The following event types are supported:
Sponsorship Events
ESCAPE_REQUESTED- Star requests to change sponsorESCAPE_ACCEPTED- New galaxy accepts the starESCAPE_CANCELED- Escape request is canceled (by star or rejected by galaxy)LOST_SPONSOR- Current galaxy stops sponsoring the star
Ownership Events
OWNER_CHANGED- Ownership of a point changes
Example Scenarios
Successful Sponsor Change
mutation {
injectMockEvents(
events: [
{ type: ESCAPE_REQUESTED, point: 256, sponsor: 1, blockNumber: 1000 }
{ type: ESCAPE_ACCEPTED, point: 256, sponsor: 1, blockNumber: 1001 }
]
) {
success
eventsInjected
}
}
Galaxy Detaches Star
mutation {
injectMockEvents(
events: [
{ type: LOST_SPONSOR, point: 512, sponsor: 0, blockNumber: 2000 }
]
) {
success
eventsInjected
}
}
Canceled Escape
mutation {
injectMockEvents(
events: [
{ type: ESCAPE_REQUESTED, point: 768, sponsor: 2, blockNumber: 3000 }
{ type: ESCAPE_CANCELED, point: 768, sponsor: 2, blockNumber: 3001 }
]
) {
success
eventsInjected
}
}
Ownership Change
mutation {
injectMockEvents(
events: [
{ type: OWNER_CHANGED, point: 256, owner: "0x1234567890123456789012345678901234567890", blockNumber: 4000 }
]
) {
success
eventsInjected
}
}
Testing from zenithd
-
Set the azimuth-watcher endpoint:
export AZIMUTH_WATCHER_ENDPOINT=http://localhost:3001/graphql -
Inject mock events via GraphQL playground (step 2 above)
-
Run zenithd tests - it will receive the mock events through normal GraphQL queries
Files Modified
src/mock-event-store.ts- In-memory event storagesrc/schema.gql- Added mutation and typessrc/resolvers.ts- Added mutation resolver and modifiedeventsInRangequery