Conversation
…nd nonces in test-txpool
…ilters from test to test
…o avoid non-determinism of the nonce
| // For some reason fees are not well estimated otherwise | ||
| await createAndFinalizeBlock(context.polkadotApi); | ||
| describeDevMoonbeam("Nonce - Initial", (context) => { | ||
| // before("Setup: Create block with transfer", async () => { |
| nodeStarted = true; | ||
| const { p2pPort, rpcPort, wsPort } = await findAvailablePorts(); | ||
|
|
||
| // console.log("Using ports", { p2pPort, rpcPort, wsPort }); |
JoshOrndorff
left a comment
There was a problem hiding this comment.
✔️ Awesome!
Our tests are so nice and clean now!
I was a little late on the review, but left some comments for possible minor improvements.
| cd ../tests | ||
| npm install | ||
| npm run test; | ||
| npm run test -- -j $(($(nproc) / 2)); |
There was a problem hiding this comment.
A comment would be nice here. Is this detecting the number of cpus available and allocating half of them to the tests?
| await Promise.all(Object.keys(contractSources).map(compile)); | ||
| for (let name of Object.keys(contractSources)) { | ||
| console.log(`Compiling ${name}`); | ||
| await compile(name); | ||
| } |
There was a problem hiding this comment.
Doesn't this switch from parallel compilation to serial compilation? Is that intentional?
| // Originally ,this test required the timestamp be in the last finve minutes. | ||
| // This requirement doesn't make sense when we forge timestamps in manual seal. |
There was a problem hiding this comment.
We no longer forge timestamps so we could bring back that lower bound that was previously in Frontier if we want to.
There was a problem hiding this comment.
Also, there is a typo in that comment. finve -> five
| it("should store the code on chain", async function () { | ||
| const { contract, rawTx } = await createContract(context.web3, "TestContract"); | ||
| const { txResults } = await context.createBlock({ transactions: [rawTx] }); | ||
|
|
||
| expect(await context.web3.eth.getCode(contract.options.address)).to.deep.equal( | ||
| "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063c6888fa114610030575b" + | ||
| "600080fd5b61004a6004803603810190610045919061008b565b610060565b60405161005791906100c3565b" + | ||
| "60405180910390f35b600060078261006f91906100de565b9050919050565b60008135905061008581610171" + | ||
| "565b92915050565b60006020828403121561009d57600080fd5b60006100ab84828501610076565b91505092" + | ||
| "915050565b6100bd81610138565b82525050565b60006020820190506100d860008301846100b4565b929150" + | ||
| "50565b60006100e982610138565b91506100f483610138565b9250817fffffffffffffffffffffffffffffff" + | ||
| "ffffffffffffffffffffffffffffffffff048311821515161561012d5761012c610142565b5b828202905092" + | ||
| "915050565b6000819050919050565b7f4e487b71000000000000000000000000000000000000000000000000" + | ||
| "00000000600052601160045260246000fd5b61017a81610138565b811461018557600080fd5b5056fea26469" + | ||
| "70667358221220a82dff050f5e40b874671c1f40e579b5a8c361f5313d1a9d32437222ab6a384c64736f6c63" + | ||
| "430008030033" | ||
| ); | ||
| }); |
There was a problem hiding this comment.
Should this code literal be imported from somewhere?
| [ | ||
| { | ||
| loop: 1, | ||
| gas: 42889, | ||
| }, | ||
| { | ||
| loop: 500, | ||
| gas: 1064354, | ||
| }, | ||
| { | ||
| loop: 600, | ||
| gas: 1269054, | ||
| }, |
There was a problem hiding this comment.
Maybe comment how we calculated these test vectors?
| // console.log("Using ports", { p2pPort, rpcPort, wsPort }); | ||
| const cmd = BINARY_PATH; | ||
| const args = [ | ||
| `--execution=Native`, // Faster execution using native |
There was a problem hiding this comment.
Faster is great. But our docs tell our node operators to run --execution=wasm so in that sense we're testing a different thing that we expect the users to use.
| import { BlockHeader } from "web3-eth"; | ||
| import { Log } from "web3-core"; | ||
|
|
||
| export async function customWeb3Request(web3: Web3, method: string, params: any[]) { |
| this.timeout(SPAWNING_TIME); | ||
| const init = await startMoonbeamDevNode(); | ||
| // Context is given prior to this assignement, so doing | ||
| // context = init.context will fail because it replace the variable; |
| }); | ||
|
|
||
| after(async function () { | ||
| // console.log(`\x1b[31m Killing RPC\x1b[0m`); |
| debug("Sending transaction", { | ||
| ...data, | ||
| data: !data.data | ||
| ? "" | ||
| : data.data.length < 80 | ||
| ? data.data | ||
| : data.data.substr(0, 7) + "..." + data.data.substr(data.data.length - 5), | ||
| }); |
There was a problem hiding this comment.
This is a string shortener, right? I wonder if it should be a helper function or have a comment.
* Crude attempt at finding open ports (#346) * added example test for frontier (#343) * added example test for frontier * added npm run non-ci-test * move staking test spec to node/chainspec (#335) * init * hide staking test spec behind test-staking feature flag * clean * comment staking test genesis config for readability * move test spec to separate file * Crude attempt at finding open ports * npx -w * Add missing file * Adds random port and parallel test execution * Fixed ethers test * Adds delay to node start in test Co-authored-by: Antoine Estienne <estienne.antoine@gmail.com> Co-authored-by: Amar Singh <asinghchrony@protonmail.com> Co-authored-by: Crystalin <alan@purestake.com> * Crystalin testweek watch (#347) * Crude attempt at finding open ports * npx -w * Add missing file * Adds random port and parallel test execution * Fixed ethers test * Adds delay to node start in test * Adds support for test watch * Cleaned package.json * Prevent test to run at start of watch * Restore optimization for cargo build Co-authored-by: Stephen Shelton <steve@brewcraft.org> * Unskip tests (#357) * Unskip `fetch genesis block by hash` * Remove timeouts * Unskip block gas limit tests * Remove `opt-level = 0` from Cargo.toml * Unskip * Test contract factory (#351) * added deployContractByName and contractSources * added getcompiled function * increase timeout for testfilterapi * change contract name and add sourcecode * Fix fixture requirement * update package and json Co-authored-by: Crystalin <alan@purestake.com> * Gorka remove intra test dependencies (#355) * Crude attempt at finding open ports * npx -w * Add missing file * Adds random port and parallel test execution * Fixed ethers test * Adds delay to node start in test * Adds support for test watch * Cleaned package.json * Prevent test to run at start of watch * Restore optimization for cargo build * Allow for non-finalization and ParentHash specification in createAndFinalizeBlock * Make test-block tests non-dependent by using non-finalized chains * Separate tests to make them non-dependent and parametrize tx hashes and nonces in test-txpool * it instead of step in test-version * setup providers before tests in test-ethers.ts * Create a block before tests to avoid one depend on the other in test-nonce * it for step in test-receipt * import constants for test-staking * Attemp at parametrizing test-filter-api tests * attemp at parametrizing test-revert-receipt * remove mocha-steps from tests * make test-subscription tests non-dependent * comply with prettier * Add support for retrieving the hash of the generated block * Make test-trace-filter tests non-dependent * balance-tests non-dependent * Non-dependent tests for test-polkadot-api * Add test-fork-chain tests * remove unnecesary timeouts * Use context provider for test-ether.ts * Remove currentId from test-filter-api since we are uninstalling all filters from test to test * Join balance test setups and check balance at each block * Rename variables to camelCase in tests * small introduced bug in test-pool-pending when camelCasing variables * Use a different account for test-revert-receipt deployment contract to avoid non-determinism of the nonce * shorten line because of editconfig * Separate test-subscription and test-subscription-past-events.ts * remove single letter variable in test-filter-api * Small cosmetic changes * revert changes in package.json * Remove beforeEach and substitute it for common function * change var for let or const Co-authored-by: Stephen Shelton <steve@brewcraft.org> Co-authored-by: Crystalin <alan@purestake.com> * Crystalin remove solc (#362) * Crude attempt at finding open ports * npx -w * Add missing file * Adds random port and parallel test execution * Fixed ethers test * Adds delay to node start in test * Adds support for test watch * Cleaned package.json * Prevent test to run at start of watch * Restore optimization for cargo build * Allow for non-finalization and ParentHash specification in createAndFinalizeBlock * Make test-block tests non-dependent by using non-finalized chains * Separate tests to make them non-dependent and parametrize tx hashes and nonces in test-txpool * it instead of step in test-version * setup providers before tests in test-ethers.ts * Create a block before tests to avoid one depend on the other in test-nonce * it for step in test-receipt * import constants for test-staking * Attemp at parametrizing test-filter-api tests * attemp at parametrizing test-revert-receipt * remove mocha-steps from tests * make test-subscription tests non-dependent * comply with prettier * Add support for retrieving the hash of the generated block * Make test-trace-filter tests non-dependent * balance-tests non-dependent * Non-dependent tests for test-polkadot-api * Add test-fork-chain tests * remove unnecesary timeouts * Use context provider for test-ether.ts * Remove currentId from test-filter-api since we are uninstalling all filters from test to test * Join balance test setups and check balance at each block * Rename variables to camelCase in tests * small introduced bug in test-pool-pending when camelCasing variables * Use a different account for test-revert-receipt deployment contract to avoid non-determinism of the nonce * shorten line because of editconfig * Separate test-subscription and test-subscription-past-events.ts * remove single letter variable in test-filter-api * Small cosmetic changes * revert changes in package.json * Remove beforeEach and substitute it for common function * change var for let or const * Removes solc from tests * Fixes path for contract tests * Adds formatting for compiled contracts Co-authored-by: Stephen Shelton <steve@brewcraft.org> Co-authored-by: Gorka Irazoqui <gorka.irazoki@gmail.com> * Typescript test refactoring (#364) * Crude attempt at finding open ports * npx -w * Add missing file * Adds random port and parallel test execution * Fixed ethers test * Adds delay to node start in test * Adds support for test watch * Cleaned package.json * Prevent test to run at start of watch * Restore optimization for cargo build * Allow for non-finalization and ParentHash specification in createAndFinalizeBlock * Make test-block tests non-dependent by using non-finalized chains * Separate tests to make them non-dependent and parametrize tx hashes and nonces in test-txpool * it instead of step in test-version * setup providers before tests in test-ethers.ts * Create a block before tests to avoid one depend on the other in test-nonce * it for step in test-receipt * import constants for test-staking * Attemp at parametrizing test-filter-api tests * attemp at parametrizing test-revert-receipt * remove mocha-steps from tests * make test-subscription tests non-dependent * comply with prettier * Add support for retrieving the hash of the generated block * Make test-trace-filter tests non-dependent * balance-tests non-dependent * Non-dependent tests for test-polkadot-api * Add test-fork-chain tests * remove unnecesary timeouts * Use context provider for test-ether.ts * Remove currentId from test-filter-api since we are uninstalling all filters from test to test * Join balance test setups and check balance at each block * Rename variables to camelCase in tests * small introduced bug in test-pool-pending when camelCasing variables * Use a different account for test-revert-receipt deployment contract to avoid non-determinism of the nonce * shorten line because of editconfig * Separate test-subscription and test-subscription-past-events.ts * remove single letter variable in test-filter-api * Small cosmetic changes * revert changes in package.json * Remove beforeEach and substitute it for common function * change var for let or const * Removes solc from tests * Fixes path for contract tests * Adds formatting for compiled contracts * Refactor tests * Fix formatting * Limit concurrency to half cpus for ts tests * Fixes github action typo Co-authored-by: Stephen Shelton <steve@brewcraft.org> Co-authored-by: Gorka Irazoqui <gorka.irazoki@gmail.com> * Antoine update testweek readme typos (#369) * added instructions to readme * update package lock * Add missing contracts to definition (#368) * Add Callee, Caller, Incrementer * Update test-trace * Remove unused * Move blockscout tracer to util/tracer * Test for txpool multiple transactions (#367) * Improve pending pool test * Rephrase comment * Better naming for txpool tests * Split txpool multiple test for more independance * Fixes few test expectations * Adds test for future transaction * Rename eth pool correctly * Fixes node listeners Co-authored-by: tgmichel <telmo@purestake.com> * Fixes typo in variable name * Added test for block gas in smart contract (#370) * VSCode debugger (support for TS tests) (#348) Add a VSCode debugger config with CodeLLDB. TS tests can be debugged by first starting the node in the debugger, then launching DEBUG_MODE=true npm run test-single in the test folder (modify package.json to change the test file). * Adds test for filter trace pagination (#373) * Fixes trace filter test Co-authored-by: Stephen Shelton <steve@brewcraft.org> Co-authored-by: Antoine Estienne <estienne.antoine@gmail.com> Co-authored-by: Amar Singh <asinghchrony@protonmail.com> Co-authored-by: tgmichel <telmo@purestake.com> Co-authored-by: girazoki <gorka.irazoki@gmail.com> Co-authored-by: nanocryk <6422796+nanocryk@users.noreply.github.com>
Refactoring of the typescript sections:
describeDevMoonbeam(running sequentially in same file)utilfoldercallee,caller,...)