Skip to content

Commit

Permalink
⚡ Fix: Add slow call to benchmark tests (#1110)
Browse files Browse the repository at this point in the history
## Description

_Concise description of proposed changes_

## Testing

Explain the quality checks that have been done on the code changes

## Additional Information

- [ ] I read the [contributing docs](../docs/contributing.md) (if this
is your first contribution)

Your ENS/address:



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Introduced benchmarking for initializing a TEVM client and executing
storage-intensive calls, simulating serverless function usage.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: William Cory <williamcory@Williams-MacBook-Pro.local>
  • Loading branch information
roninjin10 and William Cory committed May 21, 2024
1 parent 3c02464 commit 4d3d1c0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/bench/src/slowCallRepo/slowCallRepo.bench.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { bench, describe, expect } from 'vitest'
import { slowCallRepo } from './slowCallRepo.js'

describe('Call repo', async () => {
bench('This call takes 5 seconds locally over 10 seconds when deployed according to a bug report', async () => {
expect(await slowCallRepo()).toEqual({
createdAddress: '0xF52CF539DcAc32507F348aa19eb5173EEA3D4e7c',
createdAddresses: new Set(['0xF52CF539DcAc32507F348aa19eb5173EEA3D4e7c']),
executionGasUsed: 62930n,
gas: 16754885n,
logs: [],
rawData:
'0x6080604052348015600f57600080fd5b506004361060325760003560e01c806301339c211460375780638c59507c14603f575b600080fd5b603d6059565b005b604760005481565b60405190815260200160405180910390f35b7f7c84ba1c5769a0155145414f13e03f1d0d6a3a7e5d4f6d45262df4d9d48c32cd600054604051608b91815260200190565b60405180910390a156fea26469706673582212201509e5f7aed59985fb32c8f48b792565644fc6decb12b235b12226ae2855c4f464736f6c634300080d0033',
selfdestruct: new Set(),
})
})
})
19 changes: 19 additions & 0 deletions test/bench/src/slowCallRepo/slowCallRepo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { getAlchemyUrl } from '@tevm/test-utils'
import { createMemoryClient } from 'tevm'

const rpcUrl = getAlchemyUrl('optimism-sepolia')

export const slowCallRepo = async () => {
// tevm memory client in fork mode
const forkClient = createMemoryClient({
fork: { url: rpcUrl },
})

await forkClient.tevmReady()

return forkClient.tevmCall({
from: '0xef987cde72bc6a9e351d2460214d75f095b1b862',
data: '0x608060405234801561001057600080fd5b5060405161012938038061012983398101604081905261002f91610037565b600055610050565b60006020828403121561004957600080fd5b5051919050565b60cb8061005e6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c806301339c211460375780638c59507c14603f575b600080fd5b603d6059565b005b604760005481565b60405190815260200160405180910390f35b7f7c84ba1c5769a0155145414f13e03f1d0d6a3a7e5d4f6d45262df4d9d48c32cd600054604051608b91815260200190565b60405180910390a156fea26469706673582212201509e5f7aed59985fb32c8f48b792565644fc6decb12b235b12226ae2855c4f464736f6c634300080d0033000000000000000000000000000000000000000000000000000000000000000a',
skipBalance: true,
})
}

0 comments on commit 4d3d1c0

Please sign in to comment.