fix: ci integration tests chopsticks#839
Conversation
…ode into ag_chopsticks_design
rflechtner
left a comment
There was a problem hiding this comment.
Obviously this is too big a PR for me to fully review, but I scanned it for strange uses of the polkadot api and of async JS, of which I flagged a few. But generally looks good.
integration-tests/chopsticks/src/tests/switchPallet/pause/sendRelayToken/index.test.ts
Outdated
Show resolved
Hide resolved
integration-tests/chopsticks/src/tests/switchPallet/pause/switchEkilts/index.test.ts
Outdated
Show resolved
Hide resolved
integration-tests/chopsticks/src/tests/switchPallet/pause/switchKilts/index.test.ts
Outdated
Show resolved
Hide resolved
| deltaStoredSovereignSupply = BigInt(0) | ||
| ) { | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| const switchPairInfo: any = await nativeContext.api.query.assetSwitchPool1.switchPair() |
There was a problem hiding this comment.
we don't have access to the actual codec types for this pallet unless you import them from @kiltprotocol/augment-api, but many common types are available from @polkadot/types/interfaces. The Option Codec is one another basic codec type, and is available from @polkadot/types. Typescript has generics syntax just like rust, and types (like an Option Codec type) can be generic.
| deltaStoredSovereignSupply = BigInt(0) | ||
| ) { | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| const switchPairInfo: any = await nativeContext.api.query.assetSwitchPool1.switchPair() |
There was a problem hiding this comment.
I've made a more useful example of specifying the query return type earlier in this second review
integration-tests/chopsticks/src/tests/switchPallet/pause/switchKilts/index.test.ts
Outdated
Show resolved
Hide resolved
| afterEach(async () => { | ||
| await tearDownNetwork([receiverContext, senderContext, relayContext]) | ||
| }) | ||
| afterEach(async () => await tearDownNetwork([receiverContext, senderContext, relayContext])) |
There was a problem hiding this comment.
the syntax you used before was completely fine; this one is ok too though, but unusual. To summarize, these are ok:
// Returns a resolved promise containing the result of tearDownNetwork
afterEach(async () => await tearDownNetwork([receiverContext, senderContext, relayContext]))
// Returns a promise of tearDownNetwork's result directly, but is functionally identical to the above (indistinguishable for the caller)
afterEach(async () => tearDownNetwork([receiverContext, senderContext, relayContext]))
// Also returns a promise, because tearDownNetwork is async (but would be sync if tearDownNetwork were sync) - also functionally identical
afterEach(() => tearDownNetwork([receiverContext, senderContext, relayContext]))
// Same as above but with brackets
afterEach(() => {return tearDownNetwork([receiverContext, senderContext, relayContext]))}
// Also the same as earlier but with brackets
afterEach(async () => {return await tearDownNetwork([receiverContext, senderContext, relayContext]))}
// Not strictly the same - this returns a `Promise<void>` (but if tearDownNetwork did too, this would be functionally identical again)
afterEach(async () => {await tearDownNetwork([receiverContext, senderContext, relayContext]))}Don't do this though:
// Uncaught promise - the result is not handled nor awaited. The outer function always resolves.
afterEach(async () => {tearDownNetwork([receiverContext, senderContext, relayContext]))}
// Uncaught promise - the result is not handled nor awaited. The outer function is sync and returns void immediately.
afterEach(() => {tearDownNetwork([receiverContext, senderContext, relayContext]))}
// Illegal use of await in sync function
afterEach(() => {await tearDownNetwork([receiverContext, senderContext, relayContext]))}There was a problem hiding this comment.
oh yes sorry I forgot the await there: 6e71bf1
fixes #3252
This pull request introduces several enhancements and updates to the integration tests for the Chopsticks project. The changes include updates to environment variables, workflow configurations, dependencies, and the addition of new helper functions and documentation. Below are the most important changes grouped by theme:
Workflow and Environment Configuration:
.github/workflows/check-code.ymlto include block numbers and WASM overrides for different networks. Added a setup for Cargo cache to improve build efficiency. [1] [2] [3].env-examplefile to include new mandatory and optional environment variables for the tests.Documentation:
README.mdfor the Chopsticks integration tests, detailing setup instructions, environment variables, running tests, code style, adding new test cases, debugging, and recommended VS Code extensions.CLI and Command Enhancements:
src/cli.tsto manage Chopsticks instances with commands for spinning up networks, scheduling transactions, and showing state transitions.src/command/index.ts,src/command/network.ts,src/command/scheduleTx.ts, andsrc/command/stateTransition.ts. [1] [2] [3] [4]