-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow block mode customization on e2e tests (#904)
* refactor e2e tests into separate folder depending on block-mode * improve * improve * enable conditional on mining mode on hardhat * improve condition * initial e2e multiple txs test * fix * fix naming
- Loading branch information
1 parent
d97f6a8
commit acaaba7
Showing
9 changed files
with
122 additions
and
40 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
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
4 changes: 2 additions & 2 deletions
4
e2e/test/e2e-tx-parallel-contract.test.ts → ...automine/e2e-tx-parallel-contract.test.ts
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
4 changes: 2 additions & 2 deletions
4
e2e/test/e2e-tx-parallel-transfer.test.ts → ...automine/e2e-tx-parallel-transfer.test.ts
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
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,51 @@ | ||
import { expect } from "chai"; | ||
|
||
import { TEST_ACCOUNTS, randomAccounts } from "../helpers/account"; | ||
import { send, sendGetBalance, sendRawTransactions, sendReset } from "../helpers/rpc"; | ||
|
||
describe("Multiple Transactions Per Block", () => { | ||
it("Resets blockchain", async () => { | ||
await sendReset(); | ||
}); | ||
it("Send multiple transactions and mine block", async () => { | ||
const counterParty = randomAccounts(1)[0]; | ||
expect(await sendGetBalance(counterParty.address)).eq(0); | ||
|
||
let expectedCounterPartyBalance = 0; | ||
const signedTxs = []; | ||
for (let i = 0; i < TEST_ACCOUNTS.length; i++) { | ||
const amount = i + 1; | ||
const account = TEST_ACCOUNTS[i]; | ||
signedTxs.push(await account.signWeiTransfer(counterParty.address, amount)); | ||
expectedCounterPartyBalance += amount; | ||
} | ||
|
||
for (const account of randomAccounts(100)) { | ||
signedTxs.push(await account.signWeiTransfer(counterParty.address, 0)); | ||
} | ||
|
||
const txHashes = await sendRawTransactions(signedTxs); | ||
|
||
const latestBlockBeforeMining = await send('eth_getBlockByNumber', ['latest', true]); | ||
|
||
// mine the block | ||
await send("evm_mine", []); | ||
|
||
// get the latest block after mining | ||
const latestBlockAfterMining = await send('eth_getBlockByNumber', ['latest', true]); | ||
|
||
// check if block was mined | ||
expect(latestBlockAfterMining).to.exist; | ||
|
||
// check if mined block is different from the latest block before mining | ||
expect(latestBlockAfterMining.hash).to.not.equal(latestBlockBeforeMining.hash); | ||
|
||
// check if all transactions are in the block | ||
for (let txHash of txHashes) { | ||
expect(latestBlockAfterMining.transactions.map((tx: any) => tx.hash)).to.include(txHash); | ||
} | ||
|
||
// check counterParty balance | ||
expect(await sendGetBalance(counterParty.address)).eq(expectedCounterPartyBalance); | ||
}); | ||
}); |
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