Skip to content

Commit

Permalink
adding foundry test
Browse files Browse the repository at this point in the history
  • Loading branch information
signorecello committed Dec 21, 2023
1 parent e78f72c commit 26152ea
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Nightly drift test
name: Nightly Vite-Hardhat drift test

on:
# Giving ourselves a way to trigger this manually
Expand All @@ -8,7 +8,7 @@ on:
- cron: '0 2 * * *'

jobs:
setup:
vite-hardhat-setup:
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.set-matrix.outputs.versions }}
Expand All @@ -33,30 +33,28 @@ jobs:
echo "::set-output name=versions::$VERSIONS"
echo "::set-output name=versions_map::$VERSIONS_MAP"
test-drift:
needs: setup
vite-hardhat-test-drift:
needs: vite-hardhat-setup
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ matrix.project }}
working-directory: vite-hardhat
strategy:
fail-fast: false
matrix:
version: ${{ fromJson(needs.setup.outputs.versions) }}
project: [vite-hardhat, with-foundry]
version: ${{ fromJson(needs.vite-hardhat-setup.outputs.versions) }}
steps:
- uses: actions/checkout@v4

- name: Set up test environment
uses: ./.github/actions/setup
with:
project: vite-hardhat
version: ${{ matrix.version }}

- name: Get stability
id: get-stability
env:
VERSIONS_MAP: ${{ needs.setup.outputs.versions_map }}
VERSIONS_MAP: ${{ needs.vite-hardhat-setup.outputs.versions_map }}
run: |
VERSION="${{ matrix.version }}"
echo "Version Number: $VERSION"
Expand All @@ -68,7 +66,6 @@ jobs:
IS_STABLE="false"
fi
echo "Is stable: $IS_STABLE"
echo "Project: ${{ matrix.project }}"
echo "::set-output name=is_stable::$IS_STABLE"
- name: Install test version
Expand Down Expand Up @@ -104,7 +101,7 @@ jobs:
with:
payload: |
{
"text": "Once the prerelease becomes stable, projects need updating: ${{ matrix.project }}"
"text": "Once the prerelease becomes stable, projects need updating: vite-hardhat ${{ matrix.version }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
104 changes: 104 additions & 0 deletions .github/workflows/with_foundry_nightly.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Nightly With-Foundry drift test

on:
# Giving ourselves a way to trigger this manually
workflow_dispatch:
schedule:
# Run a nightly release at 2 AM UTC
- cron: '0 2 * * *'

jobs:
with-foundry-setup:
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.set-matrix.outputs.versions }}
versions_map: ${{ steps.set-matrix.outputs.versions_map }}
steps:
- uses: actions/checkout@v4

- name: Get versions to test for drift
id: versions_step
run: |
output=$(node ./.github/scripts/latest.js)
echo "Output from Node.js script: $output"
echo "::set-output name=versionsMap::$output"
- name: Set Up Matrix
id: set-matrix
run: |
VERSIONS_MAP='${{ steps.versions_step.outputs.versionsMap }}'
echo "Versions out of script: $VERSIONS_MAP"
VERSIONS=$(echo "$VERSIONS_MAP" | jq -c '[.[]]')
echo "::set-output name=versions::$VERSIONS"
echo "::set-output name=versions_map::$VERSIONS_MAP"
with-foundry-test-drift:
needs: with-foundry-setup
runs-on: ubuntu-latest
defaults:
run:
working-directory: with-foundry
strategy:
fail-fast: false
matrix:
version: ${{ fromJson(needs.with-foundry-setup.outputs.versions) }}
steps:
- uses: actions/checkout@v4

- name: Set up test environment
uses: ./.github/actions/setup
with:
version: ${{ matrix.version }}

- name: Get stability
id: get-stability
env:
VERSIONS_MAP: ${{ needs.with-foundry-setup.outputs.versions_map }}
run: |
VERSION="${{ matrix.version }}"
echo "Version Number: $VERSION"
STABLE_VERSION=$(echo "$VERSIONS_MAP" | jq -r --arg VERSION "$VERSION" '.stable')
if [ "$STABLE_VERSION" == "$VERSION" ]; then
IS_STABLE="true"
else
IS_STABLE="false"
fi
echo "Is stable: $IS_STABLE"
echo "::set-output name=is_stable::$IS_STABLE"
- name: Install test version
run: |
yarn add \
@noir-lang/noir_js@${{ matrix.version }} \
@noir-lang/backend_barretenberg@${{ matrix.version }} \
@noir-lang/noir_wasm@${{ matrix.version }} \
@noir-lang/types@${{ matrix.version }}
- name: 'Create env file'
run: |
touch .env
echo LOCALHOST_PRIVATE_KEY="${{ secrets.LOCALHOST_PRIVATE_KEY }}" >> .env
echo ANVIL_RPC="${{ secrets.ANVIL_RPC }}" >> .env
- name: Generate proof
run: |
nargo prove
working-directory: with-foundry/circuits

- name: Test with Foundry
run: |
forge test --optimize --optimizer-runs 5000 --evm-version london
- name: Send GitHub Action trigger data to Slack workflow
id: slack
uses: slackapi/[email protected]
if: ${{ failure() && steps.get-stability.outputs.is_stable == 'false' }}
with:
payload: |
{
"text": "Once the prerelease becomes stable, projects need updating: with-foundry ${{ matrix.version }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
3 changes: 1 addition & 2 deletions vite-hardhat/.env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
DEPLOYER_PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
# hardhat acct #0 key, please update
MUMBAI_DEPLOYER_PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
MUMBAI_ALCHEMY_KEY=""
# hardhat acct #0 key, please update
SEPOLIA_DEPLOYER_PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
SEPOLIA_ALCHEMY_KEY=""
SEPOLIA_ALCHEMY_KEY=""
2 changes: 1 addition & 1 deletion vite-hardhat/circuits/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
name = "noirstarter"
type = "bin"
authors = [""]
compiler_version = "0.19.4"
compiler_version = ">0.19.4"

[dependencies]
4 changes: 2 additions & 2 deletions with-foundry/.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ANVIL_RPC=
PRIVATE_KEY=
SEPOLIA_RPC=https://rpc2.sepolia.org
LOCALHOST_PRIVATE_KEY=
SEPOLIA_RPC=https://rpc2.sepolia.org
4 changes: 2 additions & 2 deletions with-foundry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Edit your `.env` file to look like:

```
ANVIL_RPC=http://localhost:8545
PRIVATE_KEY=<the private key you just got from anvil>
LOCALHOST_PRIVATE_KEY=<the private key you just got from anvil>
```

#### (Option 2) Prepare for testnet
Expand All @@ -106,7 +106,7 @@ Edit your `.env` file to look like:

```env
SEPOLIA_RPC=https://rpc2.sepolia.org
PRIVATE_KEY=<the private key of the account with your coins>
LOCALHOST_PRIVATE_KEY=<the private key of the account with your coins>
```

#### Run the deploy script
Expand Down
4 changes: 2 additions & 2 deletions with-foundry/circuits/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
name="with_foundry"
type="bin"
authors = ["critesjosh"]
compiler_version = "~0.11.0"
compiler_version = ">0.19.4"

[dependencies]
[dependencies]
2 changes: 1 addition & 1 deletion with-foundry/script/Starter.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ contract StarterScript is Script {
function setUp() public {}

function run() public {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
uint256 deployerPrivateKey = vm.envUint("LOCALHOST_PRIVATE_KEY");
vm.startBroadcast(deployerPrivateKey);

verifier = new UltraVerifier();
Expand Down
2 changes: 1 addition & 1 deletion with-foundry/script/Verify.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ contract VerifyScript is Script {
function setUp() public {}

function run() public returns (bool) {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
uint256 deployerPrivateKey = vm.envUint("LOCALHOST_PRIVATE_KEY");
vm.startBroadcast(deployerPrivateKey);

verifier = new UltraVerifier();
Expand Down

0 comments on commit 26152ea

Please sign in to comment.