Skip to content

Commit

Permalink
Reintroduce geth insta-mine in e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ezdac committed Sep 23, 2024
1 parent bec0a6f commit a07f072
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 6 additions & 2 deletions e2e_test/js-tests/send_tx.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async function replaceTx(tx) {
});
const receipt = await publicClient.waitForTransactionReceipt({
hash: hash,
confirmations: 2,
confirmations: 1,
});
return receipt;
}
Expand All @@ -89,6 +89,7 @@ async function main() {
});

var hash;

try {
hash = await walletClient.sendRawTransaction({
serializedTransaction: await walletClient.signTransaction(request),
Expand All @@ -105,8 +106,11 @@ async function main() {
}

var success = true;
// wait 1 second to give the node time to potentially process the tx
// in instamine mode. If the tx is invalidated, the block will not progress
await sleep(1000);
// give the node some time to process the transaction
await waitBlocks(5);
// await waitBlocks(1);
var receipt = await getTransactionReceipt(hash);
if (!receipt) {
receipt = await replaceTx(request);
Expand Down
5 changes: 3 additions & 2 deletions e2e_test/run_all_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ TEST_GLOB=$1
cd "$SCRIPT_DIR/.." || exit 1
make geth
trap 'kill %%' EXIT # kill bg job at exit
build/bin/geth --dev --dev.period 1 --http --http.api eth,web3,net &>"$SCRIPT_DIR/geth.log" &
build/bin/geth --dev --http --http.api eth,web3,net &>"$SCRIPT_DIR/geth.log" &

# Wait for geth to be ready
for _ in {1..10}; do
Expand All @@ -27,7 +27,8 @@ cd "$SCRIPT_DIR" || exit 1
# There's a problem with geth return errors on the first transaction sent.
# See https://github.com/ethereum/web3.py/issues/3212
# To work around this, send a transaction before running tests
cast send --json --private-key $ACC_PRIVKEY $TOKEN_ADDR 'transfer(address to, uint256 value) returns (bool)' 0x000000000000000000000000000000000000dEaD 100
cast send --async --json --private-key "$ACC_PRIVKEY" "$TOKEN_ADDR" 'transfer(address to, uint256 value) returns (bool)' 0x000000000000000000000000000000000000dEaD 100
sleep 5

failures=0
tests=0
Expand Down

0 comments on commit a07f072

Please sign in to comment.