Skip to content
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
48 changes: 48 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Lint

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Deno
uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- name: Run linter
run: deno task lint

- name: Check contracts
run: |
echo "Download the resolc binary"
wget -O resolc https://github.com/paritytech/revive/releases/download/v0.3.0/resolc-x86_64-unknown-linux-musl -q
chmod +x resolc
sudo mv resolc /usr/local/bin
resolc --version

echo "Installing solc"
wget https://github.com/ethereum/solidity/releases/download/v0.8.30/solc-static-linux -q
chmod +x solc-static-linux
sudo mv solc-static-linux /usr/local/bin/solc

echo "Building fixture contracts"
deno task build
deno fmt

echo "Verifying no new files were created (bytecode should be committed)"
if [ -n "$(git status --porcelain)" ]; then
echo "Error: Build created new or modified files. All bytecode should be committed."
git status
exit 1
fi
echo "Success: All contract bytecode is up to date"
6 changes: 0 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# Logs
logs
*.log
abi/*
pvm/*
evm/*
npm-debug.log*
yarn-debug.log*
yarn-error.log*
Expand All @@ -14,9 +11,6 @@ node_modules
dist
dist-ssr
*.local
abi/*
evm/*
pvm/*
!.gitkeep
src/samples

Expand Down
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ This repository contains a test suite for Ethereum rpc methods.

## Prerequisites

- [Deno](https://deno.land/) runtime installed (v1.40 or higher recommended)
- [Deno](https://deno.land/) runtime installed (v1.40 or higher recommended)

## Running Tests

```bash
# build the contracts
deno task build

# start revive and eth rpc, then run tests with pvm bytecode
deno task test:pvm
# start revive and eth rpc, then run tests with evm bytecode
Expand All @@ -20,6 +17,14 @@ deno task test:evm
deno task test:geth
```

## Building contracts

Contracts bytecode and abi is checked in into this repository, if you need to add new contracts, you can simply run the build command:

```bash
deno task build
```

### Linting

To check code formatting and run linter:
Expand All @@ -32,8 +37,8 @@ deno task lint

Tests are configured via environment variables:

- `START_GETH=1` - Automatically start Geth
- `START_REVIVE_DEV_NODE=1` - Automatically start Revive dev node
- `START_ETH_RPC=1` - Automatically start ETH RPC server
- `USE_GETH=1` - Run tests against Geth (uses EVM bytecode)
- `USE_ETH_RPC=1` - Run tests against ETH RPC with both PVM and EVM bytecode
- `START_GETH=1` - Automatically start Geth
- `START_REVIVE_DEV_NODE=1` - Automatically start Revive dev node
- `START_ETH_RPC=1` - Automatically start ETH RPC server
- `USE_GETH=1` - Run tests against Geth (uses EVM bytecode)
- `USE_ETH_RPC=1` - Run tests against ETH RPC with both PVM and EVM bytecode
106 changes: 106 additions & 0 deletions abi/Errors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
[
{
"inputs": [
{
"internalType": "string",
"name": "message",
"type": "string"
}
],
"name": "CustomError",
"type": "error"
},
{
"inputs": [
{
"internalType": "bool",
"name": "newState",
"type": "bool"
}
],
"name": "setState",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "state",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "triggerAssertError",
"outputs": [],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [],
"name": "triggerCustomError",
"outputs": [],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [],
"name": "triggerDivisionByZero",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [],
"name": "triggerOutOfBoundsError",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [],
"name": "triggerRequireError",
"outputs": [],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [],
"name": "triggerRevertError",
"outputs": [],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "valueMatch",
"outputs": [],
"stateMutability": "payable",
"type": "function"
}
]
106 changes: 106 additions & 0 deletions abi/Errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
export const ErrorsAbi = [
{
'inputs': [
{
'internalType': 'string',
'name': 'message',
'type': 'string',
},
],
'name': 'CustomError',
'type': 'error',
},
{
'inputs': [
{
'internalType': 'bool',
'name': 'newState',
'type': 'bool',
},
],
'name': 'setState',
'outputs': [],
'stateMutability': 'nonpayable',
'type': 'function',
},
{
'inputs': [],
'name': 'state',
'outputs': [
{
'internalType': 'bool',
'name': '',
'type': 'bool',
},
],
'stateMutability': 'view',
'type': 'function',
},
{
'inputs': [],
'name': 'triggerAssertError',
'outputs': [],
'stateMutability': 'pure',
'type': 'function',
},
{
'inputs': [],
'name': 'triggerCustomError',
'outputs': [],
'stateMutability': 'pure',
'type': 'function',
},
{
'inputs': [],
'name': 'triggerDivisionByZero',
'outputs': [
{
'internalType': 'uint256',
'name': '',
'type': 'uint256',
},
],
'stateMutability': 'pure',
'type': 'function',
},
{
'inputs': [],
'name': 'triggerOutOfBoundsError',
'outputs': [
{
'internalType': 'uint256',
'name': '',
'type': 'uint256',
},
],
'stateMutability': 'pure',
'type': 'function',
},
{
'inputs': [],
'name': 'triggerRequireError',
'outputs': [],
'stateMutability': 'pure',
'type': 'function',
},
{
'inputs': [],
'name': 'triggerRevertError',
'outputs': [],
'stateMutability': 'pure',
'type': 'function',
},
{
'inputs': [
{
'internalType': 'uint256',
'name': 'value',
'type': 'uint256',
},
],
'name': 'valueMatch',
'outputs': [],
'stateMutability': 'payable',
'type': 'function',
},
] as const
34 changes: 34 additions & 0 deletions abi/EventExample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
},
{
"indexed": false,
"internalType": "string",
"name": "message",
"type": "string"
}
],
"name": "ExampleEvent",
"type": "event"
},
{
"inputs": [],
"name": "triggerEvent",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
34 changes: 34 additions & 0 deletions abi/EventExample.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
export const EventExampleAbi = [
{
'anonymous': false,
'inputs': [
{
'indexed': true,
'internalType': 'address',
'name': 'sender',
'type': 'address',
},
{
'indexed': false,
'internalType': 'uint256',
'name': 'value',
'type': 'uint256',
},
{
'indexed': false,
'internalType': 'string',
'name': 'message',
'type': 'string',
},
],
'name': 'ExampleEvent',
'type': 'event',
},
{
'inputs': [],
'name': 'triggerEvent',
'outputs': [],
'stateMutability': 'nonpayable',
'type': 'function',
},
] as const
Loading