forked from ethereum-optimism/op-geth
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds an e2e smoketest that sends value transfer, contract interaction and contract creation transactions for all of the valid transaction types. It also verifies that deprecated transactions (celo legacy & cip42) are not supported. Co-authored-by: Karl Bartel <[email protected]>
- Loading branch information
Showing
9 changed files
with
297 additions
and
107 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,42 @@ | ||
name: e2e-test-deployed-network | ||
|
||
on: | ||
schedule: | ||
- cron: "0 14 * * *" | ||
pull_request: | ||
branches: | ||
- master | ||
- celo* | ||
paths: | ||
- 'e2e_test/**' | ||
|
||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
e2e-tests: | ||
runs-on: ["8-cpu","self-hosted","org"] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.21' | ||
|
||
- name: Build | ||
run: make all | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
with: | ||
version: nightly-143abd6a768eeb52a5785240b763d72a56987b4a | ||
|
||
- name: Run e2e tests alfajores | ||
shell: bash | ||
run: NETWORK=alfajores e2e_test/run_all_tests.sh |
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
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,76 @@ | ||
import { assert } from "chai"; | ||
import "mocha"; | ||
import { | ||
parseAbi, | ||
} from "viem"; | ||
import fs from "fs"; | ||
import { publicClient, walletClient } from "./viem_setup.mjs" | ||
|
||
// Load compiled contract | ||
const testContractJSON = JSON.parse(fs.readFileSync(process.env.COMPILED_TEST_CONTRACT, 'utf8')); | ||
|
||
// check checks that the receipt has status success and that the transaction | ||
// type matches the expected type, since viem sometimes mangles the type when | ||
// building txs. | ||
async function check(txHash, type) { | ||
const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash }); | ||
assert.equal(receipt.status, "success", "receipt status 'failure'"); | ||
const transaction = await publicClient.getTransaction({ hash: txHash }); | ||
assert.equal(transaction.type, type, "transaction type does not match"); | ||
} | ||
|
||
// sendTypedTransaction sends a transaction with the given type and an optional | ||
// feeCurrency. | ||
async function sendTypedTransaction(type, feeCurrency) { | ||
return await walletClient.sendTransaction({ | ||
to: "0x00000000000000000000000000000000DeaDBeef", | ||
value: 1, | ||
type: type, | ||
feeCurrency: feeCurrency, | ||
}); | ||
} | ||
|
||
// sendTypedSmartContractTransaction initiates a token transfer with the given type | ||
// and an optional feeCurrency. | ||
async function sendTypedSmartContractTransaction(type, feeCurrency) { | ||
const abi = parseAbi(['function transfer(address to, uint256 value) external returns (bool)']); | ||
return await walletClient.writeContract({ | ||
abi: abi, | ||
address: process.env.TOKEN_ADDR, | ||
functionName: 'transfer', | ||
args: ['0x00000000000000000000000000000000DeaDBeef', 1n], | ||
type: type, | ||
feeCurrency: feeCurrency, | ||
}); | ||
} | ||
|
||
// sendTypedCreateTransaction sends a create transaction with the given type | ||
// and an optional feeCurrency. | ||
async function sendTypedCreateTransaction(type, feeCurrency) { | ||
return await walletClient.deployContract({ | ||
type: type, | ||
feeCurrency: feeCurrency, | ||
bytecode: testContractJSON.bytecode.object, | ||
abi: testContractJSON.abi, | ||
// The constructor args for the test contract at ../debug-fee-currency/DebugFeeCurrency.sol | ||
args: [1n, true, true, true], | ||
}); | ||
} | ||
|
||
["legacy", "eip2930", "eip1559", "cip64"].forEach(function (type) { | ||
describe("viem smoke test, tx type " + type, () => { | ||
const feeCurrency = type == "cip64" ? process.env.FEE_CURRENCY : undefined; | ||
it("send tx", async () => { | ||
const send = await sendTypedTransaction(type, feeCurrency); | ||
await check(send, type); | ||
}); | ||
it("send create tx", async () => { | ||
const create = await sendTypedCreateTransaction(type, feeCurrency); | ||
await check(create, type); | ||
}); | ||
it("send contract interaction tx", async () => { | ||
const contract = await sendTypedSmartContractTransaction(type, feeCurrency); | ||
await check(contract, type); | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.