Skip to content

Commit

Permalink
Add e2e p1 tests (storyprotocol#26)
Browse files Browse the repository at this point in the history
* add the p1 tests

* add tests for permission and register derivative

* Deploy oov3 sandbox (storyprotocol#31)

* update workflow

* update workflow

* test

* test

* test

* test

* test

* update workflow

* add dispute tests

* Update dispute.test.ts

* Update hardhat_e2e.yml

* Update dispute.test.ts

---------

Co-authored-by: Jacqueline Zhang <131138188+jacqueline-57b@users.noreply.github.com>
Co-authored-by: Jacqueline Zhang <jacqueline@57blocks.com>
  • Loading branch information
3 people authored Jan 16, 2025
1 parent 8cd0128 commit 31f6bc4
Show file tree
Hide file tree
Showing 10 changed files with 606 additions and 48 deletions.
171 changes: 138 additions & 33 deletions .github/workflows/hardhat_e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ on:
required: false
default: ''
type: string
deploy_oov3:
description: 'Deploy Optimistic Oracle V3'
required: false
default: false
type: boolean

workflow_call:
inputs:
Expand All @@ -33,6 +38,7 @@ on:
required: false
default: ''
type: string

jobs:
print-config:
runs-on: ubuntu-latest
Expand All @@ -44,8 +50,134 @@ jobs:
echo "devnet_version: ${{ inputs.devnet_version || github.event.inputs.devnet_version || 'devnet' }}"
echo "erc721_address: ${{ inputs.erc721_address || github.event.inputs.erc721_address || '' }}"
build:
set-devnet-constants:
runs-on: ubuntu-latest
steps:
- name: Devnet Version
id: devnet_version
run: |
declare -A devnet_config=(
["devnet"]="1315 http://r1-d.odyssey-devnet.storyrpc.io:8545"
["mainnet"]="1514 https://public.storyrpc.io"
)
devnet_version="${{ inputs.devnet_version || github.event.inputs.devnet_version || 'devnet' }}"
if [[ -n "${devnet_config[$devnet_version]}" ]]; then
read -r chainid rpcurl <<< "${devnet_config[$devnet_version]}"
echo "CHAINID=$chainid" >> $GITHUB_OUTPUT
echo "RPCURL='$rpcurl'" >> $GITHUB_OUTPUT
else
echo "Unknown devnet version: $devnet_version"
exit 1
fi
- name: Mock ERC20 Address
id: mock_erc20_address
run: |
echo "MOCK_ERC20_ADDRESS=0x688abA77b2daA886c0aF029961Dc5fd219cEc3f6" >> $GITHUB_OUTPUT
outputs:
CHAINID: ${{ steps.devnet_version.outputs.CHAINID }}
RPCURL: ${{ steps.devnet_version.outputs.RPCURL }}
MOCK_ERC20_ADDRESS: ${{ steps.mock_erc20_address.outputs.MOCK_ERC20_ADDRESS }}

deploy-erc721:
name: Deploy ERC721
needs: set-devnet-constants
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [21.x]

steps:
- name: Check Out Repository Code
uses: actions/checkout@v4

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Run install
uses: borales/actions-yarn@v4
with:
cmd: install # will run `yarn install` command

- name: Install Dependencies
run: |
forge compile
- name: Deploy MockERC721 Contract
id: deploy-mock-erc721
run: |
erc721_address=${{ inputs.erc721_address || github.event.inputs.erc721_address || '' }}
if [[ -n "$erc721_address" ]]; then
echo "ERC721 address provided: $erc721_address"
erc721=$erc721_address
else
echo "Deploying MockERC721 contract"
result=$(forge create --rpc-url ${{ needs.set-devnet-constants.outputs.RPCURL }} --broadcast --private-key ${{ secrets.STORY_PRIVATEKEY }} --optimize --optimizer-runs 30000 --legacy --json test/foundry/mocks/token/MockERC721.sol:MockERC721 --constructor-args "MockERC" "MockERC" 2>&1)
echo $result
erc721=$(echo $result | grep deployedTo | jq -r '.deployedTo')
echo "Deployed to: $erc721"
fi
echo "STORY_ERC721=$erc721" >> $GITHUB_OUTPUT
outputs:
STORY_ERC721: ${{ steps.deploy-mock-erc721.outputs.STORY_ERC721 }}

deploy-oov3-sandbox:
name: Deploy UMA Optimistic Oracle V3
if: ${{ inputs.deploy_oov3 == true || github.event.inputs.deploy_oov3 == true }}
needs: set-devnet-constants
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [21.x]

steps:
- name: Check Out Repository Code
uses: actions/checkout@v4

- name: Checkout dev-quickstart-oov3 repository
uses: actions/checkout@v4
with:
repository: UMAprotocol/dev-quickstart-oov3
path: dev-quickstart-oov3

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Install Dependencies
run: |
cd dev-quickstart-oov3
forge install
- name: Deploy UMA Optimistic Oracle V3
id: deploy-oov3-sandbox
run: |
cd dev-quickstart-oov3
echo "DEFAULT_CURRENCY=${{ needs.set-devnet-constants.outputs.MOCK_ERC20_ADDRESS }}" >> .env
echo "DEFAULT_LIVENESS=600" >> .env
echo "MINIMUM_BOND=0" >> .env
source .env
output=$(forge script script/OracleSandbox.s.sol --fork-url ${{ needs.set-devnet-constants.outputs.RPCURL }} --broadcast --private-key ${{ secrets.STORY_PRIVATEKEY }} --priority-gas-price 1 --legacy)
echo "$output"
oov3_address=$(echo "$output" | grep '^ Deployed Optimistic Oracle V3' | awk '{print $NF}')
echo "OOV3_ADDRESS: $oov3_address"
echo "OOV3_ADDRESS=$oov3_address" >> $GITHUB_OUTPUT
outputs:
OOV3_ADDRESS: ${{ steps.deploy-oov3-sandbox.outputs.OOV3_ADDRESS }}

run-hardhat-test:
name: Run E2E Test
runs-on: ubuntu-latest
needs: [set-devnet-constants, deploy-erc721, deploy-oov3-sandbox ]
if: always() && !failure() && !cancelled()

strategy:
matrix:
Expand Down Expand Up @@ -80,37 +212,11 @@ jobs:
echo "SEPOLIA_PRIVATEKEY=${{ secrets.STORY_PRIVATEKEY }}" >> .env
echo "STORY_PRIVATEKEY=${{ secrets.STORY_PRIVATEKEY }}" >> .env
echo "STORY_USER1=${{ secrets.STORY_USER1 }}" >> .env
echo "STORY_USER2=${{ secrets.STORY_USER1 }}" >> .env
- name: Deploy MockERC721 Contract
run: |
devnet_version=${{ inputs.devnet_version || github.event.inputs.devnet_version || 'devnet' }}
if [[ "$devnet_version" == "devnet" ]]; then
rpcurl="http://r1-d.odyssey-devnet.storyrpc.io:8545"
chainid=1315
else
rpcurl="https://public.storyrpc.io"
chainid=1514
fi
echo $rpcurl
echo $chainid
erc721_address=${{ inputs.erc721_address || github.event.inputs.erc721_address || '' }}
if [[ -n "$erc721_address" ]]; then
echo "ERC721 address provided: $erc721_address"
erc721=$erc721_address
else
echo "Deploying MockERC721 contract"
result=$(forge create --rpc-url $rpcurl --private-key ${{ secrets.STORY_PRIVATEKEY }} --optimize --optimizer-runs 30000 --legacy --json test/foundry/mocks/token/MockERC721.sol:MockERC721 --constructor-args "MockERC" "MockERC" 2>&1)
echo $result
erc721=$(echo $result | grep deployedTo | jq -r '.deployedTo')
echo "Deployed to: $erc721"
fi
echo "STORY_URL=$rpcurl" >> .env
echo "STORY_CHAINID=$chainid" >> .env
echo "STORY_ERC721=$erc721" >> .env
echo "STORY_USER2=${{ secrets.STORY_USER2 }}" >> .env
echo "STORY_URL=${{ needs.set-devnet-constants.outputs.RPCURL }}" >> .env
echo "STORY_CHAINID=${{ needs.set-devnet-constants.outputs.CHAINID }}" >> .env
echo "STORY_ERC721=${{ needs.deploy-erc721.outputs.STORY_ERC721 }}" >> .env
echo "STORY_OOV3=${{ needs.deploy-oov3-sandbox.outputs.OOV3_ADDRESS }}" >> .env
# add one more blank line to .env
echo "" >> .env
Expand Down Expand Up @@ -147,4 +253,3 @@ jobs:
publish_dir: ./tmp
publish_branch: gh-pages
keep_files: true

1 change: 1 addition & 0 deletions test/hardhat/e2e/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ export const RoyaltyPolicyLRP = "0x9156e603C949481883B1d3355c6f1132D191fC41";

// Mock ERC721 contract address
export const MockERC721 = process.env.STORY_ERC721 as string;
export const STORY_OOV3 = process.env.STORY_OOV3 as string;
Loading

0 comments on commit 31f6bc4

Please sign in to comment.