-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: ci integration tests chopsticks #839
base: develop
Are you sure you want to change the base?
Conversation
…ode into ag_chopsticks_design
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yes sorry I forgot the await there: 6e71bf1
integration-tests/chopsticks/src/tests/xcm/initiateWithdrawAsset/index.test.ts
Outdated
Show resolved
Hide resolved
} | ||
/// Schedules a transaction with root privileges at the given block number. If no block is provided, the transaction will be scheduled for the next block. | ||
export async function scheduleTx({ api }: { api: ApiPromise }, call: string, at = undefined, origin = 'Root') { | ||
const number = at ? at : (await api.rpc.chain.getHeader()).number.toNumber() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, if at
is set to block 0. Because ?
checks for truthiness and 0 is falsy. ??
checks for null
& undefined
only.
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.yml
to include block numbers and WASM overrides for different networks. Added a setup for Cargo cache to improve build efficiency. [1] [2] [3].env-example
file to include new mandatory and optional environment variables for the tests.Documentation:
README.md
for 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.ts
to 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]