azimuth-watcher-ts/packages/azimuth-watcher/MOCK_EVENTS.md
Nabarun 48210eed8e Add GQL mutation to mock sponsorship and ownership change events (#4)
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>
2025-10-24 10:20:05 +00:00

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 sponsor
  • ESCAPE_ACCEPTED - New galaxy accepts the star
  • ESCAPE_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

  1. Set the azimuth-watcher endpoint:

    export AZIMUTH_WATCHER_ENDPOINT=http://localhost:3001/graphql
    
  2. Inject mock events via GraphQL playground (step 2 above)

  3. Run zenithd tests - it will receive the mock events through normal GraphQL queries

Files Modified

  • src/mock-event-store.ts - In-memory event storage
  • src/schema.gql - Added mutation and types
  • src/resolvers.ts - Added mutation resolver and modified eventsInRange query