Skip to content

Commit

Permalink
fix: fix scenario env setup, allow e2e config override
Browse files Browse the repository at this point in the history
Signed-off-by: Tomás Migone <[email protected]>
  • Loading branch information
tmigone committed Sep 5, 2022
1 parent bfd2014 commit edd5808
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion e2e/scenarios/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function getGraphOptsFromArgv(): {
const argv = process.argv.slice(2)

const getArgv = (index: number) =>
argv[index] && argv[index] !== 'undefined' ? argv[0] : undefined
argv[index] && argv[index] !== 'undefined' ? argv[index] : undefined

return {
graphConfig: getArgv(0),
Expand Down
4 changes: 2 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ const config: HardhatUserConfig = {
},
},
graph: {
addressBook: process.env.ADDRESS_BOOK,
l1GraphConfig: process.env.GRAPH_CONFIG,
addressBook: process.env.ADDRESS_BOOK ?? 'addresses.json',
l1GraphConfig: process.env.GRAPH_CONFIG ?? 'config/graph.localhost.yml',
l2GraphConfig: process.env.L2_GRAPH_CONFIG,
},
etherscan: {
Expand Down
25 changes: 17 additions & 8 deletions scripts/e2e
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
set -eo pipefail
source $(pwd)/scripts/evm

# Allow overriding config
GRAPH_CONFIG=${1:-"config/graph.localhost.yml"}
ADDRESS_BOOK=${2:-"addresses.json"}

### Setup
# Compile contracts
yarn build
Expand All @@ -13,21 +17,26 @@ evm_start
sleep 5

# Pre-deploy actions
npx hardhat migrate:accounts --network localhost --graph-config config/graph.localhost.yml
npx hardhat migrate:accounts --network localhost --graph-config "$GRAPH_CONFIG"

# Deploy protocol
npx hardhat migrate --network localhost --skip-confirmation --graph-config config/graph.localhost.yml --auto-mine
npx hardhat migrate \
--network localhost \
--skip-confirmation \
--auto-mine \
--graph-config "$GRAPH_CONFIG" \
--address-book "$ADDRESS_BOOK"

# Post deploy actions
npx hardhat migrate:ownership --network localhost --graph-config config/graph.localhost.yml
npx hardhat migrate:unpause --network localhost --graph-config config/graph.localhost.yml
npx hardhat migrate:ownership --network localhost --graph-config "$GRAPH_CONFIG" --address-book "$ADDRESS_BOOK"
npx hardhat migrate:unpause --network localhost --graph-config "$GRAPH_CONFIG" --address-book "$ADDRESS_BOOK"

### Test
# Run tests using the localhost evm instance and the localhost graph config
npx hardhat e2e --network localhost --graph-config config/graph.localhost.yml
npx hardhat e2e:scenario create-subgraphs --network localhost --graph-config config/graph.localhost.yml
npx hardhat e2e:scenario open-allocations --network localhost --graph-config config/graph.localhost.yml
npx hardhat e2e:scenario close-allocations --network localhost --graph-config config/graph.localhost.yml
npx hardhat e2e --network localhost --graph-config "$GRAPH_CONFIG" --address-book "$ADDRESS_BOOK"
npx hardhat e2e:scenario create-subgraphs --network localhost --graph-config "$GRAPH_CONFIG" --address-book "$ADDRESS_BOOK"
npx hardhat e2e:scenario open-allocations --network localhost --graph-config "$GRAPH_CONFIG" --address-book "$ADDRESS_BOOK"
npx hardhat e2e:scenario close-allocations --network localhost --graph-config "$GRAPH_CONFIG" --address-book "$ADDRESS_BOOK"

### Cleanup
# Exit error mode so the evm instance always gets killed
Expand Down
7 changes: 1 addition & 6 deletions tasks/e2e/e2e.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { task } from 'hardhat/config'
import { HardhatRuntimeEnvironment, TaskArguments } from 'hardhat/types'
import { TASK_TEST, TASK_RUN } from 'hardhat/builtin-tasks/task-names'
import { TASK_TEST } from 'hardhat/builtin-tasks/task-names'
import glob from 'glob'
import { cliOpts } from '../../cli/defaults'
import fs from 'fs'
Expand Down Expand Up @@ -85,11 +85,6 @@ task('e2e:scenario', 'Run scenario scripts and e2e tests')
args.graphConfig,
args.addressBook,
])
// await hre.run(TASK_RUN, {
// script: script,
// noCompile: true,
// ...args,
// })
} else {
console.log(`No script found for scenario ${args.scenario}`)
}
Expand Down

0 comments on commit edd5808

Please sign in to comment.