Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork18
HTTP testing instances for Ethereum
License
wevm/prool
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
HTTP testing instances for Ethereum
Prool is a library that provides programmatic HTTP testing instances for Ethereum. It is designed to be used in testing environments (e.g.Vitest) where you need to interact with an Ethereum server instance (e.g. Execution Node, 4337 Bundler, Indexer, etc) over HTTP or WebSocket.
Prool contains a set of pre-configured instances that can be used to simulate Ethereum server environments, being:
You can also create your own custom instances by using thedefineInstance function.
npm i prool
pnpm add prool
bun i prool
- Foundry binary installed
- Download:
curl -L https://foundry.paradigm.xyz | bash
- Download:
import{createServer}from'prool'import{anvil}from'prool/instances'constserver=createServer({instance:anvil(),})awaitserver.start()// Instances accessible at:// "http://localhost:8545/1"// "http://localhost:8545/2"// "http://localhost:8545/3"// "http://localhost:8545/n"
SeeAnvilParameters.
@pimlico/alto:npm i @pimlico/alto
import{createServer}from'prool'import{anvil,alto}from'prool/instances'constexecutionServer=createServer({instance:anvil(),port:8545})awaitexecutionServer.start()// Instances accessible at:// "http://localhost:8545/1"// "http://localhost:8545/2"// "http://localhost:8545/3"// "http://localhost:8545/n"constbundlerServer=createServer({instance:(key)=>alto({entrypoints:['0x0000000071727De22E5E9d8BAf0edAc6f37da032'],rpcUrl:`http://localhost:8545/${key}`,executorPrivateKeys:['0x...'],})})awaitbundlerServer.start()// Instances accessible at:// "http://localhost:3000/1" (→ http://localhost:8545/1)// "http://localhost:3000/2" (→ http://localhost:8545/2)// "http://localhost:3000/3" (→ http://localhost:8545/3)// "http://localhost:3000/n" (→ http://localhost:8545/n)
SeeAltoParameters.
import{createServer}from'prool'import{anvil,rundler}from'prool/instances'constexecutionServer=createServer({instance:anvil(),port:8545})awaitexecutionServer.start()// Instances accessible at:// "http://localhost:8545/1"// "http://localhost:8545/2"// "http://localhost:8545/3"// "http://localhost:8545/n"constbundlerServer=createServer({instance:(key)=>rundler({nodeHttp:`http://localhost:8545/${key}`,})})awaitbundlerServer.start()// Instances accessible at:// "http://localhost:3000/1" (→ http://localhost:8545/1)// "http://localhost:3000/2" (→ http://localhost:8545/2)// "http://localhost:3000/3" (→ http://localhost:8545/3)// "http://localhost:3000/n" (→ http://localhost:8545/n)
- Docker
- Silius Docker Image:
docker pull silius-rs/silius
import{createServer}from'prool'import{anvil,silius}from'prool/instances'constexecutionServer=createServer({instance:anvil(),port:8545})awaitexecutionServer.start()// Instances accessible at:// "http://localhost:8545/1"// "http://localhost:8545/2"// "http://localhost:8545/3"// "http://localhost:8545/n"constbundlerServer=createServer({instance:(key)=>silius({ethClientAddress:`http://localhost:8545/${key}`,mnemonicPath:'./keys/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',})})awaitbundlerServer.start()// Instances accessible at:// "http://localhost:4000/1" (→ http://localhost:8545/1)// "http://localhost:4000/2" (→ http://localhost:8545/2)// "http://localhost:4000/3" (→ http://localhost:8545/3)// "http://localhost:4000/n" (→ http://localhost:8545/n)
SeeSiliusParameters.
- Docker
- Stackup Docker Image:
docker pull stackupwallet/stackup-bundler:latest
import{createServer}from'prool'import{anvil,stackup}from'prool/instances'constexecutionServer=createServer({instance:anvil(),port:8545})awaitexecutionServer.start()// Instances accessible at:// "http://localhost:8545/1"// "http://localhost:8545/2"// "http://localhost:8545/3"// "http://localhost:8545/n"constbundlerServer=createServer({instance:(key)=>stackup({ethClientUrl:`http://localhost:8545/${key}`,privateKey:'0x...',})})awaitbundlerServer.start()// Instances accessible at:// "http://localhost:4337/1" (→ http://localhost:8545/1)// "http://localhost:4337/2" (→ http://localhost:8545/2)// "http://localhost:4337/3" (→ http://localhost:8545/3)// "http://localhost:4337/n" (→ http://localhost:8545/n)
Creates a server that manages a pool of instances via a proxy.
import{createServer}from'prool'import{anvil}from'prool/instances'constexecutionServer=createServer({instance:anvil(),})awaitexecutionServer.start()// Instances accessible at:// "http://localhost:8545/1"// "http://localhost:8545/2"// "http://localhost:8545/3"// "http://localhost:8545/n"// "http://localhost:8545/n/start"// "http://localhost:8545/n/stop"// "http://localhost:8545/n/restart"// "http://localhost:8545/healthcheck"
Endpoints:
/:key: Proxy to instance atkey./:key/start: Start instance atkey./:key/stop: Stop instance atkey./:key/restart: Restart instance atkey./healthcheck: Healthcheck endpoint.
| Name | Description | Type |
|---|---|---|
instance | Instance for the server. | Instance | (key: number) => Instance |
limit | Number of instances that can be instantiated in the pool | number |
host | Host for the server. | string |
port | Port for the server. | number |
| returns | Server | CreateServerReturnType |
Creates an instance definition, that can be used withcreateServer ordefinePool.
import{defineInstance}from'prool'constfoo=defineInstance((parameters:FooParameters)=>{return{name:'foo',host:'localhost',port:3000,asyncstart(){// ...},asyncstop(){// ...},}})
| Name | Description | Type |
|---|---|---|
fn | Instance definition. | DefineInstanceFn |
| returns | Instance. | Instance |
Defines a pool of instances. Instances can be started, cached, and stopped against an identifier.
import{definePool}from'prool'import{anvil}from'prool/instances'constpool=definePool({instance:anvil(),})constinstance_1=awaitpool.start(1)constinstance_2=awaitpool.start(2)constinstance_3=awaitpool.start(3)
| Name | Description | Type |
|---|---|---|
instance | Instance for the pool. | Instance |
limit | Number of instances that can be instantiated in the pool | number |
| returns | Pool. | Pool |
MIT License
About
HTTP testing instances for Ethereum
Resources
License
Code of conduct
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Contributors5
Uh oh!
There was an error while loading.Please reload this page.