Mock ship keys for usage in e2e tests (#9)
Part of https://plan.wireit.in/deepstack/browse/VUL-294/ Reviewed-on: LaconicNetwork/azimuth-watcher-ts#9 Co-authored-by: Shreerang Kale <shree@deepstacksoft.com> Co-committed-by: Shreerang Kale <shree@deepstacksoft.com>
This commit is contained in:
parent
699bf8ee9f
commit
ce717930c6
@ -30,6 +30,9 @@
|
|||||||
# Flag to enable injecting mock events for testing
|
# Flag to enable injecting mock events for testing
|
||||||
enableMockEvents = false
|
enableMockEvents = false
|
||||||
|
|
||||||
|
# Flag to enable mocking ship keys for testing
|
||||||
|
enableMockShipKeys = false
|
||||||
|
|
||||||
# GQL cache settings
|
# GQL cache settings
|
||||||
[server.gql.cache]
|
[server.gql.cache]
|
||||||
enabled = true
|
enabled = true
|
||||||
|
|||||||
@ -27,6 +27,12 @@ import { mockEventStore, MockEventInput } from './mock-event-store';
|
|||||||
|
|
||||||
const log = debug('vulcanize:resolver');
|
const log = debug('vulcanize:resolver');
|
||||||
|
|
||||||
|
// Mock ship keys environment variables
|
||||||
|
const TEST_MOCK_POINT = process.env.TEST_MOCK_POINT;
|
||||||
|
const TEST_MOCK_ENCRYPTION_KEY = process.env.TEST_MOCK_ENCRYPTION_KEY;
|
||||||
|
const TEST_MOCK_AUTHENTICATION_KEY = process.env.TEST_MOCK_AUTHENTICATION_KEY;
|
||||||
|
const TEST_MOCK_LIFE = process.env.TEST_MOCK_LIFE;
|
||||||
|
|
||||||
const executeAndRecordMetrics = async (
|
const executeAndRecordMetrics = async (
|
||||||
indexer: Indexer,
|
indexer: Indexer,
|
||||||
gqlLogger: winston.Logger,
|
gqlLogger: winston.Logger,
|
||||||
@ -80,6 +86,7 @@ export const createResolvers = async (
|
|||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
const gqlConfig = indexer.serverConfig.gql;
|
const gqlConfig = indexer.serverConfig.gql;
|
||||||
|
const mockShipKeysEnabled = (gqlConfig as any).enableMockShipKeys;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
BigInt: GraphQLBigInt,
|
BigInt: GraphQLBigInt,
|
||||||
@ -134,6 +141,17 @@ export const createResolvers = async (
|
|||||||
// Set cache-control hints
|
// Set cache-control hints
|
||||||
// setGQLCacheHints(info, {}, gqlCacheConfig);
|
// setGQLCacheHints(info, {}, gqlCacheConfig);
|
||||||
|
|
||||||
|
// Check if we should return mocked active status for this point
|
||||||
|
const shouldMock = mockShipKeysEnabled && TEST_MOCK_POINT && _point === BigInt(TEST_MOCK_POINT);
|
||||||
|
|
||||||
|
if (shouldMock) {
|
||||||
|
log('isActive: returning mocked value (true) for point:', _point.toString());
|
||||||
|
return Promise.resolve({
|
||||||
|
value: true,
|
||||||
|
proof: undefined
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return executeAndRecordMetrics(
|
return executeAndRecordMetrics(
|
||||||
indexer,
|
indexer,
|
||||||
gqlLogger,
|
gqlLogger,
|
||||||
@ -156,6 +174,22 @@ export const createResolvers = async (
|
|||||||
// Set cache-control hints
|
// Set cache-control hints
|
||||||
// setGQLCacheHints(info, {}, gqlCacheConfig);
|
// setGQLCacheHints(info, {}, gqlCacheConfig);
|
||||||
|
|
||||||
|
// Check if we should return mocked keys for this point
|
||||||
|
const shouldMock = mockShipKeysEnabled && TEST_MOCK_POINT && _point === BigInt(TEST_MOCK_POINT);
|
||||||
|
|
||||||
|
if (shouldMock) {
|
||||||
|
log('getKeys: returning mocked keys for point:', _point.toString());
|
||||||
|
return Promise.resolve({
|
||||||
|
value: {
|
||||||
|
value0: TEST_MOCK_ENCRYPTION_KEY,
|
||||||
|
value1: TEST_MOCK_AUTHENTICATION_KEY,
|
||||||
|
value2: BigInt(0),
|
||||||
|
value3: BigInt(TEST_MOCK_LIFE ?? 1)
|
||||||
|
},
|
||||||
|
proof: undefined
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return executeAndRecordMetrics(
|
return executeAndRecordMetrics(
|
||||||
indexer,
|
indexer,
|
||||||
gqlLogger,
|
gqlLogger,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user