Skip to content

Commit

Permalink
chore: use sepolia instead of goerli for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
saihaj committed Mar 20, 2024
1 parent ff9b217 commit 9e30726
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 122 deletions.
14 changes: 7 additions & 7 deletions packages/indexer-agent/src/__tests__/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const TEST_DISPUTE_1: POIDisputeAttributes = {
previousEpochReferenceProof:
'0xd04b5601739a1638719696d0735c92439267a89248c6fd21388d9600f5c942f6',
status: 'potential',
protocolNetwork: 'eip155:5',
protocolNetwork: 'eip155:11155111',
}
const TEST_DISPUTE_2: POIDisputeAttributes = {
allocationID: '0x085fd2ADc1B96c26c266DecAb6A3098EA0eda619',
Expand All @@ -63,7 +63,7 @@ const TEST_DISPUTE_2: POIDisputeAttributes = {
previousEpochReferenceProof:
'0xd04b5601739a1638719696d0735c92439267a89248c6fd21388d9600f5c942f6',
status: 'potential',
protocolNetwork: 'eip155:5',
protocolNetwork: 'eip155:11155111',
}

const POI_DISPUTES_CONVERTERS_FROM_GRAPHQL: Record<
Expand Down Expand Up @@ -116,7 +116,7 @@ let graphNode: GraphNode
let operator: Operator
let metrics: Metrics

const PUBLIC_JSON_RPC_ENDPOINT = 'https://ethereum-goerli.publicnode.com'
const PUBLIC_JSON_RPC_ENDPOINT = 'https://ethereum-sepolia.publicnode.com'

const testProviderUrl =
process.env.INDEXER_TEST_JRPC_PROVIDER_URL ?? PUBLIC_JSON_RPC_ENDPOINT
Expand Down Expand Up @@ -149,7 +149,7 @@ const setup = async () => {
)

const networkSpecification = specification.NetworkSpecification.parse({
networkIdentifier: 'eip155:5',
networkIdentifier: 'eip155:11155111',
gateway: {
url: 'http://127.0.0.1:8030/',
},
Expand All @@ -165,7 +165,7 @@ const setup = async () => {
subgraphs: {
maxBlockDistance: 10000,
networkSubgraph: {
url: 'https://api.thegraph.com/subgraphs/name/graphprotocol/graph-network-goerli',
url: 'https://api.thegraph.com/subgraphs/name/graphprotocol/graph-network-sepolia',
},
epochSubgraph: {
url: 'http://test-url.xyz',
Expand Down Expand Up @@ -244,7 +244,7 @@ describe('Indexer tests', () => {
previousEpochReferenceProof:
'0xd04b5601739a1638719696d0735c92439267a89248c6fd21388d9600f5c942f6',
status: 'potential',
protocolNetwork: 'eip155:5',
protocolNetwork: 'eip155:11155111',
}

const disputes = [badDispute]
Expand Down Expand Up @@ -284,7 +284,7 @@ describe('Indexer tests', () => {
expectedResult,
)
await expect(
operator.fetchPOIDisputes('potential', 205, 'eip155:5'),
operator.fetchPOIDisputes('potential', 205, 'eip155:11155111'),
).resolves.toEqual(expectedFilteredResult)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ describe('Allocation Manager', () => {
// so we set its timeout to a higher value than usual.
jest.setTimeout(30_000)

// Reuse an existing allocation with 25 sextillion allocated GRT
const allocationID = '0x96737b6a31f40edaf96c567efbb98935aa906ab9'
// Reuse an existing allocation allocated GRT
const allocationID = '0x973a6cfb5dc9eb523c5f0734bd6879995a3c0895'

// Redefine test actions to use that allocation ID
const unallocateAction = {
Expand Down Expand Up @@ -147,7 +147,7 @@ describe('Allocation Manager', () => {
expect(unallocate.action.type).toBe(ActionType.UNALLOCATE)
expect(unallocate.allocates.isZero()).toBeTruthy()
expect(unallocate.rewards.isZero()).toBeFalsy()
expect(unallocate.unallocates).toStrictEqual(parseGRT('25000'))
expect(unallocate.unallocates).toStrictEqual(parseGRT('250'))
expect(unallocate.balance).toStrictEqual(
unallocate.allocates.sub(unallocate.unallocates).sub(unallocate.rewards),
)
Expand All @@ -156,8 +156,8 @@ describe('Allocation Manager', () => {
expect(reallocate.action.type).toBe(ActionType.REALLOCATE)
expect(reallocate.allocates).toStrictEqual(parseGRT('10000'))
expect(reallocate.rewards.isZero()).toBeTruthy()
expect(reallocate.unallocates).toStrictEqual(parseGRT('25000'))
expect(reallocate.balance).toStrictEqual(parseGRT('-15000'))
expect(reallocate.unallocates).toStrictEqual(parseGRT('250'))
expect(reallocate.balance).toStrictEqual(parseGRT('9750'))
})

test('validateActionBatchFeasibility() validates and correctly sorts actions based on net token balance', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const setupMonitor = async () => {
async: false,
level: __LOG_LEVEL__ ?? 'error',
})
ethereum = getTestProvider('goerli')
ethereum = getTestProvider('sepolia')
contracts = await connectContracts(ethereum, 5, undefined)

const subgraphFreshnessChecker = new SubgraphFreshnessChecker(
Expand All @@ -86,13 +86,13 @@ const setupMonitor = async () => {
networkSubgraph = await NetworkSubgraph.create({
logger,
endpoint:
'https://api.thegraph.com/subgraphs/name/graphprotocol/graph-network-goerli',
'https://api.thegraph.com/subgraphs/name/graphprotocol/graph-network-sepolia',
deployment: undefined,
subgraphFreshnessChecker,
})

epochSubgraph = new EpochSubgraph(
'https://api.thegraph.com/subgraphs/name/graphprotocol/goerli-epoch-block-oracle',
'https://api.thegraph.com/subgraphs/name/graphprotocol/sepolia-epoch-block-oracle',
subgraphFreshnessChecker,
logger,
)
Expand All @@ -112,7 +112,7 @@ const setupMonitor = async () => {
})

networkMonitor = new NetworkMonitor(
resolveChainId('goerli'),
resolveChainId('sepolia'),
contracts,
indexerOptions,
logger,
Expand Down Expand Up @@ -166,7 +166,7 @@ describe('Indexing Rules', () => {
allocationAmount: '5000',
identifierType: SubgraphIdentifierType.DEPLOYMENT,
decisionBasis: IndexingDecisionBasis.ALWAYS,
protocolNetwork: 'goerli',
protocolNetwork: 'sepolia',
} as Partial<IndexingRuleAttributes>
const setIndexingRuleResult = await upsertIndexingRule(logger, models, indexingRule)
expect(setIndexingRuleResult).toHaveProperty(
Expand All @@ -184,7 +184,9 @@ describe('Indexing Rules', () => {
)

// When reading directly to the database, `protocolNetwork` must be in the CAIP2-ID format.
await expect(fetchIndexingRules(models, false, 'eip155:5')).resolves.toHaveLength(1)
await expect(
fetchIndexingRules(models, false, 'eip155:11155111'),
).resolves.toHaveLength(1)
})
})

Expand Down Expand Up @@ -234,7 +236,7 @@ describe('Actions', () => {
reason: 'indexingRule',
priority: 0,
// When writing directly to the database, `protocolNetwork` must be in the CAIP2-ID format.
protocolNetwork: 'eip155:5',
protocolNetwork: 'eip155:11155111',
}

await models.Action.upsert(action)
Expand Down Expand Up @@ -285,8 +287,8 @@ describe('Types', () => {
expect(resolveChainId('mainnet')).toBe('eip155:1')
})

test('Resolve chain id: `5`', () => {
expect(resolveChainId('5')).toBe('eip155:5')
test('Resolve chain id: `11155111`', () => {
expect(resolveChainId('11155111')).toBe('eip155:11155111')
})

test('Resolve chain alias: `eip155:1`', () => {
Expand All @@ -300,15 +302,15 @@ describe('Types', () => {
})
})

// This test suite requires a graph-node instance connected to Goerli, so we're skipping it for now
// This test suite requires a graph-node instance connected to Sepolia, so we're skipping it for now
// Use this test suite locally to test changes to the NetworkMonitor class
describe.skip('Monitor', () => {
beforeAll(setupMonitor)

test('Fetch currentEpoch for `goerli`', async () => {
test('Fetch currentEpoch for `sepolia`', async () => {
await expect(
networkMonitor.currentEpoch(resolveChainId('goerli')),
).resolves.toHaveProperty('networkID', 'eip155:5')
networkMonitor.currentEpoch(resolveChainId('sepolia')),
).resolves.toHaveProperty('networkID', 'eip155:11155111')
}, 10000)

test('Fail to fetch currentEpoch: chain not supported by graph-node', async () => {
Expand All @@ -328,7 +330,7 @@ describe.skip('Monitor', () => {
test('Fetch network chain current epoch', async () => {
await expect(networkMonitor.networkCurrentEpoch()).resolves.toHaveProperty(
'networkID',
'eip155:5',
'eip155:11155111',
)
})

Expand All @@ -355,9 +357,12 @@ describe('Network layer detection', () => {
}

// Should be true for L1 and false for L2
const l1Networks: NetworkLayer[] = ['mainnet', 'eip155:1', 'goerli', 'eip155:5'].map(
(name: string) => ({ name, l1: true, l2: false }),
)
const l1Networks: NetworkLayer[] = [
'mainnet',
'eip155:1',
'sepolia',
'eip155:11155111',
].map((name: string) => ({ name, l1: true, l2: false }))

// Should be false for L1 and true for L2
const l2Networks: NetworkLayer[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ async function actionInputToExpected(

// We expect the protocol network to be transformed to it's CAIP2-ID
// form for all inputs
if (input.protocolNetwork === 'goerli') {
expected.protocolNetwork = 'eip155:5'
if (input.protocolNetwork === 'sepolia') {
expected.protocolNetwork = 'eip155:11155111'
}

return expected
Expand Down Expand Up @@ -509,7 +509,7 @@ describe('Actions', () => {

test('Reject action with invalid params for action type', async () => {
const inputAction = invalidReallocateAction
const expected = { ...inputAction, protocolNetwork: 'eip155:5' }
const expected = { ...inputAction, protocolNetwork: 'eip155:11155111' }
const fields = JSON.stringify(expected)
await expect(
client.mutation(QUEUE_ACTIONS_MUTATION, { actions: [inputAction] }).toPromise(),
Expand Down Expand Up @@ -632,7 +632,7 @@ describe('Actions', () => {

test('Reject unallocate action with inactive allocationID', async () => {
// This allocation has been closed on chain
const closedAllocation = '0x0001572b5fde192fc1c65630fabb5e13d3ad173e'
const closedAllocation = '0x0641209ae448c710ab8d04a8c8a13053d138d8c6'

// Reuse a valid inputAction but use an allocationID dedicated to this test purpose,
// as the previously used allocationID does not exist on chain.
Expand Down Expand Up @@ -709,7 +709,7 @@ describe('Actions', () => {
reason: 'indexingRule',
priority: 0,
// When writing directly to the database, `protocolNetwork` must be in the CAIP2-ID format.
protocolNetwork: 'eip155:5',
protocolNetwork: 'eip155:11155111',
} as ActionInput

const proposedAction = {
Expand All @@ -720,7 +720,7 @@ describe('Actions', () => {
source: 'indexerAgent',
reason: 'indexingRule',
priority: 0,
protocolNetwork: 'goerli',
protocolNetwork: 'sepolia',
} as ActionInput

await managementModels.Action.create(failedAction, {
Expand Down Expand Up @@ -764,7 +764,7 @@ describe('Actions', () => {
reason: 'indexingRule',
priority: 0,
// When writing directly to the database, `protocolNetwork` must be in the CAIP2-ID format.
protocolNetwork: 'eip155:5',
protocolNetwork: 'eip155:11155111',
} as ActionInput

const proposedAction = {
Expand All @@ -775,7 +775,7 @@ describe('Actions', () => {
source: 'indexerAgent',
reason: 'indexingRule',
priority: 0,
protocolNetwork: 'goerli',
protocolNetwork: 'sepolia',
} as ActionInput

await managementModels.Action.create(successfulAction, {
Expand Down Expand Up @@ -817,7 +817,7 @@ describe('Actions', () => {
reason: 'indexingRule',
priority: 0,
// When writing directly to the database, `protocolNetwork` must be in the CAIP2-ID format.
protocolNetwork: 'eip155:5',
protocolNetwork: 'eip155:11155111',
} as ActionInput

const queuedAllocateAction = {
Expand All @@ -829,7 +829,7 @@ describe('Actions', () => {
source: 'indexerAgent',
reason: 'indexingRule',
priority: 0,
protocolNetwork: 'goerli',
protocolNetwork: 'sepolia',
} as ActionInput

await managementModels.Action.create(queuedUnallocateAction, {
Expand Down
Loading

0 comments on commit 9e30726

Please sign in to comment.