Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert transaction-utils to anvil #278

Merged
merged 5 commits into from
Jun 27, 2024
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
5 changes: 5 additions & 0 deletions .changeset/nervous-starfishes-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@celo/dev-utils': patch
---

Fix jest force exits,Set default timeout to 1 second
5 changes: 5 additions & 0 deletions .changeset/wise-weeks-applaud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@celo/transactions-uri': patch
---

Bump bn.js
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ jobs:
needs: install-dependencies
steps:
- uses: actions/checkout@v4
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: ${{ env.SUPPORTED_FOUNDRY_VERSION }}
- name: Sync workspace
uses: ./.github/actions/sync-workspace
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@

#### Defined in

[test-utils/setup.global.ts:10](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/transactions-uri/src/test-utils/setup.global.ts#L10)
[test-utils/setup.global.ts:7](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/transactions-uri/src/test-utils/setup.global.ts#L7)
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@

#### Defined in

[test-utils/teardown.global.ts:3](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/transactions-uri/src/test-utils/teardown.global.ts#L3)
[test-utils/teardown.global.ts:1](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/transactions-uri/src/test-utils/teardown.global.ts#L1)
7 changes: 4 additions & 3 deletions packages/dev-utils/src/anvil-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export function createInstance(): Anvil {
balance: TEST_BALANCE,
gasPrice: TEST_GAS_PRICE,
gasLimit: TEST_GAS_LIMIT,
stopTimeout: 1000,
}

instance = createAnvil(options)
Expand All @@ -41,11 +42,11 @@ export function testWithAnvil(name: string, fn: (web3: Web3) => void) {

// for each test case, we start and stop a new anvil instance
return testWithWeb3(name, `http://127.0.0.1:${anvil.port}`, fn, {
beforeAll: () => {
return anvil.start()
beforeAll: async () => {
await anvil.start()
},
afterAll: async () => {
return anvil.stop()
await anvil.stop()
},
})
}
Expand Down
8 changes: 4 additions & 4 deletions packages/dev-utils/src/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ export function testWithWeb3(
if (snapId != null) {
await evmRevert(web3, snapId)
}
if (hooks?.afterAll) {
// hook must be awaited here or jest doesnt actually wait for it and complains of open handles
await hooks.afterAll()
}
})

if (hooks?.afterAll) {
afterAll(hooks.afterAll)
}

fn(web3)
})
}
6 changes: 3 additions & 3 deletions packages/sdk/transactions-uri/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@
"build": "yarn run --top-level tsc -b .",
"clean": "yarn run --top-level tsc -b . --clean",
"docs": "yarn run --top-level typedoc",
"test": "yarn run --top-level jest --runInBand",
"test": "NODE_OPTIONS='--experimental-vm-modules' yarn run --top-level jest --runInBand",
"lint": "yarn run --top-level eslint -c .eslintrc.js ",
"prepublishOnly": "yarn build"
},
"dependencies": {
"@celo/base": "^6.1.0-beta.0",
"@celo/connect": "^6.0.0-beta.0",
"@types/bn.js": "^5.1.0",
"@types/debug": "^4.1.5",
"@types/qrcode": "^1.3.4",
"bn.js": "4.11.9",
"bn.js": "^5.1.0",
"qrcode": "1.4.4",
"web3-eth-abi": "1.10.4"
},
"devDependencies": {
"@celo/celo-devchain": "^7.0.0",
"@celo/contractkit": "^8.1.0-beta.0",
"@celo/dev-utils": "0.0.4-beta.0",
"@celo/typescript": "workspace:^",
Expand Down
13 changes: 1 addition & 12 deletions packages/sdk/transactions-uri/src/test-utils/setup.global.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
import baseSetup from '@celo/dev-utils/lib/ganache-setup'
// Has to import the matchers somewhere so that typescript knows the matchers have been made available
import _must_be_imported from '@celo/dev-utils/lib/matchers'
import { waitForPortOpen } from '@celo/dev-utils/lib/network'
import * as path from 'path'

// Warning: There should be an unused import of '@celo/dev-utils/lib/matchers' above.
// If there is not, then your editor probably deleted it automatically.

export default async function globalSetup() {
const chainDataPath = path.join(path.dirname(require.resolve('@celo/celo-devchain')), '../chains')
// vX refers to core contract release version X
await baseSetup(path.resolve(chainDataPath), 'v11.tar.gz', {
from_targz: true,
})
await waitForPortOpen('localhost', 8545, 60)
console.log('...ganache started')
}
export default async function globalSetup() {}
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
import teardown from '@celo/dev-utils/lib/ganache-teardown'

export default async function globalTeardown() {
await teardown()
}
export default async function globalTeardown() {}
4 changes: 2 additions & 2 deletions packages/sdk/transactions-uri/src/tx-uri.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { CeloTx } from '@celo/connect'
import { CeloContract, newKitFromWeb3 } from '@celo/contractkit'
import { testWithGanache } from '@celo/dev-utils/lib/ganache-test'
import { testWithAnvil } from '@celo/dev-utils/lib/anvil-test'
import { buildUri, parseUri } from './tx-uri'

testWithGanache('URI utils', (web3) => {
testWithAnvil('URI utils', (web3) => {
const recipient = '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef'
const value = '100'

Expand Down
11 changes: 2 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1998,14 +1998,14 @@ __metadata:
resolution: "@celo/transactions-uri@workspace:packages/sdk/transactions-uri"
dependencies:
"@celo/base": "npm:^6.1.0-beta.0"
"@celo/celo-devchain": "npm:^7.0.0"
"@celo/connect": "npm:^6.0.0-beta.0"
"@celo/contractkit": "npm:^8.1.0-beta.0"
"@celo/dev-utils": "npm:0.0.4-beta.0"
"@celo/typescript": "workspace:^"
"@types/bn.js": "npm:^5.1.0"
"@types/debug": "npm:^4.1.5"
"@types/qrcode": "npm:^1.3.4"
bn.js: "npm:4.11.9"
bn.js: "npm:^5.1.0"
cross-fetch: "npm:3.1.5"
dotenv: "npm:^8.2.0"
fetch-mock: "npm:^10.0.7"
Expand Down Expand Up @@ -7534,13 +7534,6 @@ __metadata:
languageName: node
linkType: hard

"bn.js@npm:4.11.9":
version: 4.11.9
resolution: "bn.js@npm:4.11.9"
checksum: c5a2342f0bc3d0bbe53361d57aa51c489589ad2d7c726c1337e9af7f37b6bc2d2d1b63cfb1972a7aacbc053367832037f699f973c81d9c5844af247650968691
languageName: node
linkType: hard

"bn.js@npm:^4.11.6, bn.js@npm:^4.11.8, bn.js@npm:^4.11.9":
version: 4.12.0
resolution: "bn.js@npm:4.12.0"
Expand Down
Loading