Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: L2 tests #265

Merged
merged 3 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/tests-l2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Tests (L2)

on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

# Install commands
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
registry-url: https://registry.npmjs.org
- name: yarn add ts-node
run: yarn add ts-node
- name: yarn install
run: yarn install

# Run scripts
- name: Prep addressess
run: ./node_modules/.bin/ts-node config/testAddressesL2.ts && ./node_modules/.bin/mustache ./config/generatedAddresses.json ./config/addresses.template.ts > ./config/addresses.ts
- name: Prep test L2
run: ./node_modules/.bin/mustache ./config/generatedAddresses.json subgraph.template.yaml > subgraph.yaml && ./node_modules/@graphprotocol/graph-cli/bin/run codegen --output-dir src/types/
- name: Test
run: ./node_modules/@graphprotocol/graph-cli/bin/run test -v 0.6.0-rc.2
5 changes: 4 additions & 1 deletion tests/curation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,15 @@ createMockedFunction(controllerAddress, 'getGovernor', 'getGovernor():(address)'
// L2 graph network init EpochManager call
createMockedFunction(graphAddress, 'blockNum', 'blockNum():(uint256)')
.withArgs([])
.returns([ethereum.Value.fromI32(0)])
.returns([ethereum.Value.fromI32(5)])

describe('Signalled', () => {
beforeAll(() => {
// We need epoch length and delegation ratio to be nonzero for these tests
let graphNetwork = createOrLoadGraphNetwork(blockNumber, controllerAddress)
graphNetwork.delegationRatio = delegationRatio
graphNetwork.epochLength = epochLength
graphNetwork.lastLengthUpdateBlock = 1
graphNetwork.save()

// When _stake is successfully run, before any event we are considering here can be emitted
Expand Down Expand Up @@ -202,6 +203,7 @@ describe('Burned', () => {
let graphNetwork = createOrLoadGraphNetwork(blockNumber, controllerAddress)
graphNetwork.delegationRatio = delegationRatio
graphNetwork.epochLength = epochLength
graphNetwork.lastLengthUpdateBlock = 1
graphNetwork.save()

// When _stake is successfully run, before any event we are considering here can be emitted
Expand Down Expand Up @@ -313,6 +315,7 @@ describe('ParameterUpdated', () => {
let graphNetwork = createOrLoadGraphNetwork(blockNumber, controllerAddress)
graphNetwork.delegationRatio = delegationRatio
graphNetwork.epochLength = epochLength
graphNetwork.lastLengthUpdateBlock = 1
graphNetwork.save()

// When _stake is successfully run, before any event we are considering here can be emitted
Expand Down
2 changes: 1 addition & 1 deletion tests/gns.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ createMockedFunction(controllerAddress, 'getGovernor', 'getGovernor():(address)'
// L2 graph network init EpochManager call
createMockedFunction(graphAddress, 'blockNum', 'blockNum():(uint256)')
.withArgs([])
.returns([ethereum.Value.fromI32(0)])
.returns([ethereum.Value.fromI32(5)])

// CONSTANTS
const blockNumber = BigInt.fromI32(1)
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ createMockedFunction(controllerAddress, 'getGovernor', 'getGovernor():(address)'
// L2 graph network init EpochManager call
createMockedFunction(graphAddress, 'blockNum', 'blockNum():(uint256)')
.withArgs([])
.returns([ethereum.Value.fromI32(0)])
.returns([ethereum.Value.fromI32(1)])

afterAll(() => {
// Clear the store in order to start the next test off on a clean slate
Expand Down
11 changes: 10 additions & 1 deletion tests/staking.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ createMockedFunction(controllerAddress, 'getGovernor', 'getGovernor():(address)'
// L2 graph network init EpochManager call
createMockedFunction(graphAddress, 'blockNum', 'blockNum():(uint256)')
.withArgs([])
.returns([ethereum.Value.fromI32(0)])
.returns([ethereum.Value.fromI32(5)])

// INDEXER STAKE RELATED TESTS
describe('INDEXER STAKE', () => {
Expand Down Expand Up @@ -180,6 +180,7 @@ describe('INDEXER STAKE', () => {
let graphNetwork = createOrLoadGraphNetwork(blockNumber, controllerAddress)
graphNetwork.delegationRatio = delegationRatio
graphNetwork.epochLength = epochLength
graphNetwork.lastLengthUpdateBlock = 1
graphNetwork.save()

// When _stake is successfully run, before any event we are considering here can be emitted
Expand Down Expand Up @@ -233,6 +234,7 @@ describe('INDEXER STAKE', () => {
let graphNetwork = createOrLoadGraphNetwork(blockNumber, controllerAddress)
graphNetwork.delegationRatio = delegationRatio
graphNetwork.epochLength = epochLength
graphNetwork.lastLengthUpdateBlock = 1
graphNetwork.save()

// When _stake is successfully run, before any event we are considering here can be emitted
Expand Down Expand Up @@ -282,6 +284,7 @@ describe('INDEXER STAKE', () => {
let graphNetwork = createOrLoadGraphNetwork(blockNumber, controllerAddress)
graphNetwork.delegationRatio = delegationRatio
graphNetwork.epochLength = epochLength
graphNetwork.lastLengthUpdateBlock = 1
graphNetwork.save()

// When _stake is successfully run, before any event we are considering here can be emitted
Expand Down Expand Up @@ -342,6 +345,7 @@ describe('INDEXER STAKE', () => {
let graphNetwork = createOrLoadGraphNetwork(blockNumber, controllerAddress)
graphNetwork.delegationRatio = delegationRatio
graphNetwork.epochLength = epochLength
graphNetwork.lastLengthUpdateBlock = 1
graphNetwork.save()

// When _stake is successfully run, before any event we are considering here can be emitted
Expand Down Expand Up @@ -382,6 +386,7 @@ describe('DELEGATOR STAKE', () => {
let graphNetwork = createOrLoadGraphNetwork(blockNumber, controllerAddress)
graphNetwork.delegationRatio = delegationRatio
graphNetwork.epochLength = epochLength
graphNetwork.lastLengthUpdateBlock = 1
graphNetwork.save()

// When _stake is successfully run, before any event we are considering here can be emitted
Expand Down Expand Up @@ -453,6 +458,7 @@ describe('DELEGATOR STAKE', () => {
let graphNetwork = createOrLoadGraphNetwork(blockNumber, controllerAddress)
graphNetwork.delegationRatio = delegationRatio
graphNetwork.epochLength = epochLength
graphNetwork.lastLengthUpdateBlock = 1
graphNetwork.save()

// When _stake is successfully run, before any event we are considering here can be emitted
Expand Down Expand Up @@ -543,6 +549,7 @@ describe('DELEGATOR STAKE', () => {
let graphNetwork = createOrLoadGraphNetwork(blockNumber, controllerAddress)
graphNetwork.delegationRatio = delegationRatio
graphNetwork.epochLength = epochLength
graphNetwork.lastLengthUpdateBlock = 1
graphNetwork.save()

// When _stake is successfully run, before any event we are considering here can be emitted
Expand Down Expand Up @@ -600,6 +607,7 @@ describe('ALLOCATION LIFE CYCLE', () => {
let graphNetwork = createOrLoadGraphNetwork(blockNumber, controllerAddress)
graphNetwork.delegationRatio = delegationRatio
graphNetwork.epochLength = epochLength
graphNetwork.lastLengthUpdateBlock = 1
graphNetwork.save()

// When _stake is successfully run, before any event we are considering here can be emitted
Expand Down Expand Up @@ -670,6 +678,7 @@ describe('ALLOCATION LIFE CYCLE', () => {
let graphNetwork = createOrLoadGraphNetwork(blockNumber, controllerAddress)
graphNetwork.delegationRatio = delegationRatio
graphNetwork.epochLength = epochLength
graphNetwork.lastLengthUpdateBlock = 1
graphNetwork.save()

// When _stake is successfully run, before any event we are considering here can be emitted
Expand Down
Loading