-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
93cb53b
commit 8d0290e
Showing
20 changed files
with
639 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Third party libraries testing workflow | ||
description: "Tests one library at a time" | ||
inputs: | ||
library: | ||
required: true | ||
version: | ||
default: 'latest' | ||
description: Version to test again or 'latest' | ||
required: false | ||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: '18' | ||
- name: 'enable corepack for yarn' | ||
run: sudo corepack enable yarn | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: '18' | ||
cache: 'yarn' | ||
- name: Restore node cache | ||
uses: actions/cache@v4 | ||
id: cache_node | ||
with: | ||
# We need to cache all the artifacts generated by yarn install+build | ||
# Update this list also in .github/actions/sync-workspace/action.yml with exactly the same list | ||
path: | | ||
./.yarn/cache | ||
./.yarn/install-state.gz | ||
node_modules | ||
packages/**/node_modules | ||
key: node-${{ runner.os }}-${{ runner.arch }}-${{ env.NODE_MODULE_CACHE_VERSION }}-${{ hashFiles('yarn.lock') }} | ||
restore-keys: | | ||
node-${{ runner.os }}-${{ runner.arch }}-${{ env.NODE_MODULE_CACHE_VERSION }}- | ||
- name: Install yarn dependencies | ||
run: git config --global url."https://".insteadOf ssh:// && yarn install | ||
if: steps.cache_node.outputs.cache-hit != 'true' | ||
- name: Run yarn postinstall if cache hitted | ||
run: yarn run postinstall | ||
if: steps.cache_node.outputs.cache-hit == 'true' | ||
|
||
- run: | | ||
cd packages/e2e | ||
yarn | ||
yarn add ${{ github.event.input.library }}@${{ github.env.input.version }} | ||
yarn run test:${{ github.event.input.library }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Third party libraries testing workflow | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
library: | ||
type: choice | ||
options: | ||
- viem | ||
- web3 | ||
- ethers | ||
version: | ||
type: string | ||
default: 'latest' | ||
description: Version to test again or 'latest' | ||
workflow_run: | ||
|
||
jobs: | ||
third-party-test-workflow: | ||
runs-on: ['self-hosted', 'org', '8-cpu'] | ||
steps: | ||
- uses: celo-org/developer-tooling/.github/actions/third-party-tests/action.yaml | ||
with: | ||
library: ${{ github.event.inputs.library }} | ||
version: ${{ github.event.inputs.version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
TEST_ACCOUNT="0x123..." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
extends: '../../.eslintrc.js', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
lib/ | ||
tmp/ | ||
.tmp/ | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/.devchain/ | ||
/.devchain.tar.gz | ||
/coverage/ | ||
/node_modules/ | ||
/src/ | ||
/tmp/ | ||
/.tmp/ | ||
|
||
/tsconfig.* | ||
/jest.config.* | ||
*.tgz | ||
|
||
/src | ||
|
||
/lib/**/*.test.* | ||
/lib/test-utils |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# @celo/e2e | ||
|
||
TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"exclude": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "@celo/e2e", | ||
"version": "0.0.1", | ||
"description": "TODO", | ||
"types": "./lib/index.d.ts", | ||
"author": "cLabs", | ||
"license": "Apache-2.0", | ||
"homepage": "https://docs.celo.org/developer/tools", | ||
"repository": "https://github.com/celo-org/developer-tooling/tree/master/packages/e2e", | ||
"keywords": [], | ||
"type": "module", | ||
"exports": { | ||
".": "./lib/index.js" | ||
}, | ||
"scripts": { | ||
"test": "yarn run vitest", | ||
"test:viem": "yarn run vitest viem", | ||
"test:ethers": "yarn run vitest ethers", | ||
"test:web3": "yarn run vitest web3" | ||
}, | ||
"dependencies": { | ||
"@celo/abis": "^11.0.0", | ||
"@celo/typescript": "workspace:^", | ||
"@celo/web3-plugin-transaction-types": "^1.0.2", | ||
"@vitest/coverage-v8": "2.1.2", | ||
"dotenv": "^8.2.0", | ||
"ethers": "^6.13.4", | ||
"viem": "^2.21.27", | ||
"vitest": "^2.1.2", | ||
"web3": "^4.13.0" | ||
}, | ||
"engines": { | ||
"node": ">=18" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { Hex } from 'viem' | ||
|
||
export const TEST_PRIVATE_KEY = process.env.TEST_ACCOUNT as Hex | ||
export { celo, celoAlfajores } from 'viem/chains' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { Contract, ethers, Wallet } from 'ethers' | ||
|
||
import { describe, expect, it } from 'vitest' | ||
|
||
import { registryABI } from '@celo/abis' | ||
import { celoAlfajores, TEST_PRIVATE_KEY } from './common' | ||
|
||
const provider = new ethers.JsonRpcProvider(celoAlfajores.rpcUrls.default.http[0]) | ||
const signer = new Wallet(TEST_PRIVATE_KEY, provider) | ||
|
||
const cEURContract = new Contract( | ||
'0x000000000000000000000000000000000000ce10', | ||
registryABI, | ||
provider | ||
) | ||
let cEUR = cEURContract.getAddressForString('StableToken') | ||
|
||
describe('e2e ethers test suite', () => { | ||
it('is setup correctly', async () => { | ||
const blockNumber = await provider.getBlockNumber() | ||
expect(blockNumber).toBeTypeOf('number') | ||
expect(blockNumber).toBeGreaterThan(0) | ||
}) | ||
|
||
it('can get basic account info', async () => { | ||
const address = await signer.getAddress() | ||
expect(address).toMatchInlineSnapshot(`"0x5FB3913Eb60d125Afbe7A6572E4F0F624dd945Ed"`) | ||
|
||
const balance = await signer.provider?.getBalance(address, 'latest') | ||
expect(balance).toBeTypeOf('bigint') | ||
expect(balance).toBeGreaterThan(0n) | ||
}) | ||
|
||
it('can call a contract', async () => { | ||
expect(cEUR).resolves.toMatch(/^0x[A-Fa-f0-9]{40}$/) | ||
}) | ||
|
||
it('can submit a basic tx', async () => { | ||
const tx = await signer.sendTransaction({ | ||
value: 1n, | ||
to: await signer.getAddress(), | ||
}) | ||
await tx.wait() | ||
expect(tx.hash).toMatch(/^0x[A-Fa-f0-9]{64}$/) | ||
}, 15000) | ||
|
||
it.skip('can submit a feeCurrency tx', async () => { | ||
const tx = await signer.sendTransaction({ | ||
value: 1n, | ||
to: await signer.getAddress(), | ||
// feeCurrency: await cEUR, | ||
}) | ||
await tx.wait() | ||
expect(tx.hash).toMatch(/^0x[A-Fa-f0-9]{64}$/) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { registryABI } from '@celo/abis' | ||
|
||
import { createPublicClient, createWalletClient, http } from 'viem' | ||
import { privateKeyToAccount } from 'viem/accounts' | ||
import { createNonceManager, jsonRpc } from 'viem/nonce' | ||
|
||
import { describe, expect, it } from 'vitest' | ||
|
||
import { celoAlfajores, TEST_PRIVATE_KEY } from './common' | ||
|
||
const publicClient = createPublicClient({ | ||
chain: celoAlfajores, | ||
transport: http(), | ||
}) | ||
|
||
const walletClient = createWalletClient({ | ||
account: privateKeyToAccount(TEST_PRIVATE_KEY, { | ||
nonceManager: createNonceManager({ | ||
source: jsonRpc(), | ||
}), | ||
}), | ||
transport: http(), | ||
chain: celoAlfajores, | ||
}) | ||
|
||
let cEUR = publicClient.readContract({ | ||
abi: registryABI, | ||
functionName: 'getAddressForString', | ||
address: '0x000000000000000000000000000000000000ce10', | ||
args: ['StableTokenEUR'], | ||
}) | ||
|
||
describe('viem e2e test suite', () => { | ||
it('is setup correctly', async () => { | ||
const blockNumber = await publicClient.getBlockNumber() | ||
expect(blockNumber).toBeTypeOf('bigint') | ||
expect(blockNumber).toBeGreaterThan(0) | ||
}) | ||
|
||
it('can get basic account info', async () => { | ||
const [address] = await walletClient.getAddresses() | ||
expect(address).toMatchInlineSnapshot(`"0x5FB3913Eb60d125Afbe7A6572E4F0F624dd945Ed"`) | ||
|
||
const balance = await publicClient.getBalance({ address, blockTag: 'latest' }) | ||
expect(balance).toBeTypeOf('bigint') | ||
expect(balance).toBeGreaterThan(0) | ||
}) | ||
|
||
it('can call a contract', async () => { | ||
expect(cEUR).resolves.toMatch(/^0x[A-Fa-f0-9]{40}$/) | ||
}) | ||
|
||
it('can submit a basic tx', async () => { | ||
const tx = await walletClient.sendTransaction({ | ||
value: 1n, | ||
to: await walletClient.getAddresses()[0], | ||
}) | ||
expect(tx).toMatch(/^0x[A-Fa-f0-9]{64}$/) | ||
}) | ||
it('can submit a feeCurrency tx', async () => { | ||
const tx = await walletClient.sendTransaction({ | ||
value: 1n, | ||
to: await walletClient.getAddresses()[0], | ||
feeCurrency: await cEUR, | ||
}) | ||
expect(tx).toMatch(/^0x[A-Fa-f0-9]{64}$/) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { registryABI } from '@celo/abis' | ||
// import { CeloTransactionTypesPlugin } from '@celo/web3-plugin-transaction-types' | ||
|
||
import { describe, expect, it } from 'vitest' | ||
|
||
import Web3 from 'web3' | ||
|
||
import { TEST_PRIVATE_KEY, celoAlfajores } from './common' | ||
|
||
const web3 = new Web3(celoAlfajores.rpcUrls.default[0]) | ||
const account = web3.eth.accounts.wallet.add(TEST_PRIVATE_KEY) | ||
web3.setProvider(new Web3.providers.HttpProvider(celoAlfajores.rpcUrls.default.http[0])) | ||
|
||
const cEURContract = new web3.eth.Contract( | ||
registryABI as any, | ||
'0x000000000000000000000000000000000000ce10' | ||
) | ||
let cEUR = cEURContract.methods.getAddressForString('StableToken').call() | ||
|
||
describe('e2e web3 test suite', () => { | ||
it('is setup correctly', async () => { | ||
const blockNumber = await web3.eth.getBlockNumber() | ||
expect(blockNumber).toBeTypeOf('number') | ||
expect(blockNumber).toBeGreaterThan(0) | ||
}) | ||
|
||
it('can get basic account info', async () => { | ||
const { address } = account | ||
expect(address).toMatchInlineSnapshot(`"0x5FB3913Eb60d125Afbe7A6572E4F0F624dd945Ed"`) | ||
|
||
const balance = await web3.eth.getBalance(address, 'latest') | ||
expect(balance).toBeTypeOf('string') | ||
expect(balance).toMatch(/\d+/) | ||
expect(BigInt(balance)).toBeGreaterThan(0n) | ||
}) | ||
|
||
it('can call a contract', async () => { | ||
expect(cEUR).resolves.toMatch(/^0x[A-Fa-f0-9]{40}$/) | ||
}) | ||
|
||
it('can submit a basic tx', async () => { | ||
const params = { | ||
value: 1, | ||
from: account.address, | ||
to: account.address, | ||
} as const | ||
|
||
const tx = await web3.eth.sendTransaction({ | ||
...params, | ||
gas: await web3.eth.estimateGas(params), | ||
}) | ||
|
||
expect(tx.transactionHash).toMatch(/^0x[A-Fa-f0-9]{64}$/) | ||
}, 15000) | ||
|
||
it.skip('can submit a feeCurrency tx', async () => { | ||
// web3.registerPlugin(new CeloTransactionTypesPlugin()) | ||
// web3.celo.link(web3) | ||
// web3.eth.defaultAccount = account.address | ||
// const params = { | ||
// value: 1, | ||
// from: account.address, | ||
// to: account.address, | ||
// feeCurrency: await cEUR, | ||
// } as const | ||
// await web3.celo.populateTransaction(params) | ||
// const tx = await web3.eth.sendTransaction({ | ||
// ...params, | ||
// }) | ||
// expect(tx.transactionHash).toMatch(/^0x[A-Fa-f0-9]{64}$/) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"extends": "@celo/typescript/tsconfig.library.json", | ||
"compilerOptions": { | ||
"rootDir": "src", | ||
"outDir": "lib", | ||
"moduleResolution": "Node16", | ||
"module": "Node16", | ||
"declaration": true, | ||
"types": ["vitest/globals"] | ||
}, | ||
"include": ["src/**/*", "types/**/*"], | ||
"exclude": ["**/*.test.ts"] | ||
} |
Oops, something went wrong.