Skip to content

Commit 1921eda

Browse files
committed
fix: cleanup from rebase
1 parent 23a35ee commit 1921eda

File tree

15 files changed

+51
-79
lines changed

15 files changed

+51
-79
lines changed

packages/subgraph-service/hardhat.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const config: HardhatUserConfig = {
2222
settings: {
2323
optimizer: {
2424
enabled: true,
25-
runs: 1,
25+
runs: 50,
2626
},
2727
},
2828
},

packages/subgraph-service/scripts/test/integration

+12-9
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,25 @@ if [ "$SUBGRAPH_DEPLOYMENT_EXISTS" = true ] || [ "$HORIZON_DEPLOYMENT_EXISTS" =
5959
fi
6060
fi
6161

62+
# Check required env variables
63+
BLOCKCHAIN_RPC=${BLOCKCHAIN_RPC:-$(npx hardhat vars get ARBITRUM_SEPOLIA_RPC)}
64+
if [ -z "$BLOCKCHAIN_RPC" ]; then
65+
echo "BLOCKCHAIN_RPC environment variable is required"
66+
exit 1
67+
fi
68+
69+
echo "Starting integration tests..."
70+
6271
# Check if hardhat node is already running on port 8545
6372
STARTED_NODE=false
6473
if lsof -i:8545 > /dev/null 2>&1; then
6574
echo "Hardhat node already running on port 8545, using existing node"
6675
# Get the PID of the process using port 8545
6776
NODE_PID=$(lsof -t -i:8545)
6877
else
69-
# Check required env variables only if we need to start the node
70-
if [ -z "$ARBITRUM_SEPOLIA_RPC" ]; then
71-
echo "ARBITRUM_SEPOLIA_RPC environment variable is required to start hardhat node"
72-
exit 1
73-
fi
74-
7578
# Start local hardhat node forked from Arbitrum Sepolia
7679
echo "Starting local hardhat node..."
77-
npx hardhat node --fork $ARBITRUM_SEPOLIA_RPC > node.log 2>&1 &
80+
npx hardhat node --fork $BLOCKCHAIN_RPC > node.log 2>&1 &
7881
NODE_PID=$!
7982
STARTED_NODE=true
8083

@@ -114,9 +117,9 @@ npx hardhat deploy:migrate --network localhost --step 2 --subgraph-service-confi
114117
cd ../horizon
115118
npx hardhat deploy:migrate --network localhost --horizon-config e2e-test --step 4 --patch-config --account-index 1 --hide-banner
116119

117-
# Run Subgraph Service post-upgrade steps
120+
# Run Subgraph Service seed steps
118121
cd ../subgraph-service
119-
npx hardhat test:post-upgrade --network localhost
122+
npx hardhat test:seed --network localhost
120123

121124
# Run integration tests - During transition period
122125
npx hardhat test:integration --phase during-transition-period --network localhost

packages/subgraph-service/tasks/test/post-upgrade.ts renamed to packages/subgraph-service/tasks/test/seed.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { IHorizonStaking } from '@graphprotocol/horizon'
66

77
import { indexers } from './fixtures/indexers'
88

9-
task('test:post-upgrade', 'Test the post-upgrade state for integration tests')
9+
task('test:seed', 'Seed the test environment, must be run after deployment')
1010
.setAction(async (_, hre) => {
1111
// Get contracts
1212
const graph = hre.graph()

packages/subgraph-service/test/integration/after-transition-period/dispute-manager/governance.test.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,8 @@ describe('DisputeManager Governance', () => {
2020
disputeManager = graph.subgraphService.contracts.DisputeManager as unknown as DisputeManager
2121

2222
// Get signers
23-
const signers = await ethers.getSigners()
24-
governor = signers[1]
25-
nonOwner = signers[2]
26-
newArbitrator = signers[3]
27-
newSubgraphService = signers[4]
23+
governor = await graph.accounts.getGovernor()
24+
;[nonOwner, newArbitrator, newSubgraphService] = await graph.accounts.getTestAccounts()
2825
})
2926

3027
beforeEach(async () => {

packages/subgraph-service/test/integration/after-transition-period/dispute-manager/indexing-disputes.test.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ describe('Indexing Disputes', () => {
3737
subgraphService = graph.subgraphService.contracts.SubgraphService as unknown as SubgraphService
3838

3939
// Get signers
40-
const signers = await ethers.getSigners()
41-
fisherman = signers[0]
42-
arbitrator = signers[2]
40+
arbitrator = await graph.accounts.getArbitrator()
41+
;[fisherman] = await graph.accounts.getTestAccounts()
4342

4443
// Get indexer
4544
const indexerFixture = indexers[0]

packages/subgraph-service/test/integration/after-transition-period/dispute-manager/query-conflict-disputes.test.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ describe('Query Conflict Disputes', () => {
4242
subgraphService = graph.subgraphService.contracts.SubgraphService as unknown as SubgraphService
4343

4444
// Get signers
45-
const signers = await ethers.getSigners()
46-
fisherman = signers[0]
47-
arbitrator = signers[2]
45+
arbitrator = await graph.accounts.getArbitrator()
46+
;[fisherman] = await graph.accounts.getTestAccounts()
4847

4948
// Get indexers
5049
const indexerFixture = indexers[0]

packages/subgraph-service/test/integration/after-transition-period/dispute-manager/query-disputes.test.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ describe('Query Disputes', () => {
4141
subgraphService = graph.subgraphService.contracts.SubgraphService as unknown as SubgraphService
4242

4343
// Get signers
44-
const signers = await ethers.getSigners()
45-
fisherman = signers[0]
46-
arbitrator = signers[2]
44+
arbitrator = await graph.accounts.getArbitrator()
45+
;[fisherman] = await graph.accounts.getTestAccounts()
4746

4847
// Get indexer
4948
const indexerFixture = indexers[0]

packages/subgraph-service/test/integration/after-transition-period/subgraph-service/governance.test.ts

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { ethers } from 'hardhat'
22
import { expect } from 'chai'
3-
import { HDNodeWallet } from 'ethers'
43
import hre from 'hardhat'
54

65
import { SignerWithAddress } from '@nomicfoundation/hardhat-ethers/signers'
@@ -12,20 +11,16 @@ describe('Subgraph Service Governance', () => {
1211

1312
// Test addresses
1413
let governor: SignerWithAddress
15-
let nonOwner: HDNodeWallet
16-
let pauseGuardian: HDNodeWallet
14+
let nonOwner: SignerWithAddress
15+
let pauseGuardian: SignerWithAddress
1716

1817
before(async () => {
1918
const graph = hre.graph()
2019
subgraphService = graph.subgraphService.contracts.SubgraphService as unknown as SubgraphService
2120

2221
// Get signers
23-
const signers = await ethers.getSigners()
24-
governor = signers[1]
25-
nonOwner = ethers.Wallet.createRandom()
26-
nonOwner = nonOwner.connect(ethers.provider)
27-
pauseGuardian = ethers.Wallet.createRandom()
28-
pauseGuardian = pauseGuardian.connect(ethers.provider)
22+
governor = await graph.accounts.getGovernor()
23+
;[nonOwner, pauseGuardian] = await graph.accounts.getTestAccounts()
2924

3025
// Set eth balance for non-owner and pause guardian
3126
await ethers.provider.send('hardhat_setBalance', [nonOwner.address, '0x56BC75E2D63100000'])

packages/subgraph-service/test/integration/after-transition-period/subgraph-service/operator.test.ts

+10-16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { ethers } from 'hardhat'
22
import { expect } from 'chai'
3-
import { HDNodeWallet } from 'ethers'
43
import hre from 'hardhat'
54

65
import { DisputeManager, IGraphToken, IHorizonStaking, IPaymentsEscrow, SubgraphService } from '../../../../typechain-types'
@@ -24,8 +23,8 @@ describe('Operator', () => {
2423

2524
// Test addresses
2625
let indexer: SignerWithAddress
27-
let authorizedOperator: HDNodeWallet
28-
let unauthorizedOperator: HDNodeWallet
26+
let authorizedOperator: SignerWithAddress
27+
let unauthorizedOperator: SignerWithAddress
2928
let allocationId: string
3029
let subgraphDeploymentId: string
3130
let allocationTokens: bigint
@@ -34,24 +33,14 @@ describe('Operator', () => {
3433
const { provision } = graph.horizon.actions
3534
const { collect, generateAllocationProof } = graph.subgraphService.actions
3635

37-
before(async () => {
36+
before(() => {
3837
// Get contracts
3938
subgraphService = graph.subgraphService.contracts.SubgraphService as unknown as SubgraphService
4039
staking = graph.horizon.contracts.HorizonStaking as unknown as IHorizonStaking
4140
graphToken = graph.horizon.contracts.GraphToken as unknown as IGraphToken
4241
escrow = graph.horizon.contracts.PaymentsEscrow as unknown as IPaymentsEscrow
4342
graphTallyCollector = graph.horizon.contracts.GraphTallyCollector as unknown as GraphTallyCollector
4443
disputeManager = graph.subgraphService.contracts.DisputeManager as unknown as DisputeManager
45-
46-
// Get signers
47-
authorizedOperator = ethers.Wallet.createRandom()
48-
authorizedOperator = authorizedOperator.connect(ethers.provider)
49-
unauthorizedOperator = ethers.Wallet.createRandom()
50-
unauthorizedOperator = unauthorizedOperator.connect(ethers.provider)
51-
52-
// Set balances for authorized operator
53-
await ethers.provider.send('hardhat_setBalance', [authorizedOperator.address, '0x56BC75E2D63100000'])
54-
await ethers.provider.send('hardhat_setBalance', [unauthorizedOperator.address, '0x56BC75E2D63100000'])
5544
})
5645

5746
beforeEach(async () => {
@@ -67,8 +56,11 @@ describe('Operator', () => {
6756
describe('New indexer', () => {
6857
beforeEach(async () => {
6958
// Get indexer
70-
const signers = await ethers.getSigners()
71-
indexer = await ethers.getSigner(signers[19].address)
59+
[indexer, authorizedOperator, unauthorizedOperator] = await graph.accounts.getTestAccounts()
60+
61+
// Set balances for operators
62+
await ethers.provider.send('hardhat_setBalance', [authorizedOperator.address, '0x56BC75E2D63100000'])
63+
await ethers.provider.send('hardhat_setBalance', [unauthorizedOperator.address, '0x56BC75E2D63100000'])
7264

7365
// Create provision
7466
const disputePeriod = await disputeManager.getDisputePeriod()
@@ -124,6 +116,8 @@ describe('Operator', () => {
124116
// Get indexer
125117
const indexerFixture = indexers[0]
126118
indexer = await ethers.getSigner(indexerFixture.address)
119+
120+
;[authorizedOperator, unauthorizedOperator] = await graph.accounts.getTestAccounts()
127121
})
128122

129123
describe('New allocation', () => {

packages/subgraph-service/test/integration/after-transition-period/subgraph-service/paused.test.ts

+4-14
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,15 @@ describe('Paused Protocol', () => {
3434
subgraphService = graph.subgraphService.contracts.SubgraphService as unknown as SubgraphService
3535

3636
// Get signers
37-
const signers = await ethers.getSigners()
38-
pauseGuardian = signers[3]
37+
pauseGuardian = await graph.accounts.getPauseGuardian()
3938
})
4039

4140
beforeEach(async () => {
4241
// Take a snapshot before each test
4342
snapshotId = await ethers.provider.send('evm_snapshot', [])
4443

4544
// Get indexer
46-
const signers = await ethers.getSigners()
47-
indexer = signers[18]
48-
49-
// Get allocation
50-
const wallet = ethers.Wallet.createRandom()
51-
allocationId = wallet.address
52-
subgraphDeploymentId = indexers[0].allocations[0].subgraphDeploymentID
53-
allocationTokens = 1000n
45+
;[indexer] = await graph.accounts.getTestAccounts()
5446
})
5547

5648
afterEach(async () => {
@@ -193,8 +185,7 @@ describe('Paused Protocol', () => {
193185
describe('New indexer', () => {
194186
beforeEach(async () => {
195187
// Get indexer
196-
const signers = await ethers.getSigners()
197-
indexer = await ethers.getSigner(signers[19].address)
188+
[indexer] = await graph.accounts.getTestAccounts()
198189

199190
// Create provision
200191
const disputePeriod = await disputeManager.getDisputePeriod()
@@ -225,8 +216,7 @@ describe('Paused Protocol', () => {
225216

226217
before(async () => {
227218
// Get anyone address
228-
const signers = await ethers.getSigners()
229-
anyone = signers[3]
219+
[anyone] = await graph.accounts.getTestAccounts()
230220
})
231221

232222
it('should not allow anyone to close a stale allocation while paused', async () => {

packages/subgraph-service/test/integration/after-transition-period/subgraph-service/permisionless.test.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ describe('Permissionless', () => {
2626
subgraphService = graph.subgraphService.contracts.SubgraphService as unknown as SubgraphService
2727

2828
// Get anyone address
29-
const signers = await ethers.getSigners()
30-
anyone = signers[3]
29+
;[anyone] = await graph.accounts.getTestAccounts()
3130
})
3231

3332
beforeEach(async () => {

packages/subgraph-service/test/integration/during-transition-period/governance.test.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ describe('Governance', () => {
1717
let allocationId: string
1818
let subgraphDeploymentId: string
1919

20-
before(() => {
21-
const graph = hre.graph()
20+
const graph = hre.graph()
2221

22+
before(() => {
2323
subgraphService = graph.subgraphService.contracts.SubgraphService as unknown as ISubgraphService
2424
// Get proxy admin with SubgraphServiceInterface
2525
})
@@ -29,10 +29,8 @@ describe('Governance', () => {
2929
snapshotId = await ethers.provider.send('evm_snapshot', [])
3030

3131
// Get signers
32-
const signers = await ethers.getSigners()
33-
governor = signers[1]
34-
indexer = signers[2]
35-
nonOwner = signers[3]
32+
governor = await graph.accounts.getGovernor()
33+
;[indexer, nonOwner] = await graph.accounts.getTestAccounts()
3634

3735
// Generate test addresses
3836
allocationId = ethers.Wallet.createRandom().address

packages/subgraph-service/test/integration/during-transition-period/indexer.test.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ describe('Indexer', () => {
2626
subgraphService = graph.subgraphService.contracts.SubgraphService as unknown as ISubgraphService
2727

2828
// Get governor and non-owner
29-
const signers = await ethers.getSigners()
30-
governor = signers[1]
29+
governor = await graph.accounts.getGovernor()
3130
})
3231

3332
beforeEach(async () => {

packages/toolshed/src/core/attestations.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ethers, HDNodeWallet, Wallet } from "ethers"
1+
import { ethers, Wallet } from "ethers"
22

33
import { IDisputeManager } from "@graphprotocol/subgraph-service"
44

@@ -13,7 +13,7 @@ import { IDisputeManager } from "@graphprotocol/subgraph-service"
1313
*/
1414
export async function createAttestationData(
1515
disputeManager: IDisputeManager,
16-
signer: Wallet | HDNodeWallet,
16+
signer: Wallet,
1717
requestCID: string,
1818
responseCID: string,
1919
subgraphDeploymentId: string

packages/toolshed/src/deployments/subgraph-service/actions.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ethers, HDNodeWallet, Wallet } from 'ethers'
1+
import { ethers } from 'ethers'
22

33
import type { ISubgraphService } from '@graphprotocol/subgraph-service'
44
import type { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers'
@@ -13,7 +13,7 @@ export function loadActions(contracts: { SubgraphService: ISubgraphService }) {
1313
* - `[indexer, paymentType, data]` - The collect parameters
1414
* @returns The payment collected
1515
*/
16-
collect: (signer: HardhatEthersSigner | HDNodeWallet, args: Parameters<ISubgraphService['collect']>): Promise<bigint> => collect(contracts, signer, args),
16+
collect: (signer: HardhatEthersSigner, args: Parameters<ISubgraphService['collect']>): Promise<bigint> => collect(contracts, signer, args),
1717

1818
/**
1919
* Generates an allocation proof for the subgraph services
@@ -29,7 +29,7 @@ export function loadActions(contracts: { SubgraphService: ISubgraphService }) {
2929
// Collects payment from the subgraph service
3030
async function collect(
3131
contracts: { SubgraphService: ISubgraphService },
32-
signer: HardhatEthersSigner | HDNodeWallet,
32+
signer: HardhatEthersSigner,
3333
args: Parameters<ISubgraphService['collect']>,
3434
): Promise<bigint> {
3535
const { SubgraphService } = contracts

0 commit comments

Comments
 (0)