-
Notifications
You must be signed in to change notification settings - Fork 19
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: make e2e tests for passkey more rigorous in their success checks #2246
Conversation
await assert.doesNotReject(passkeyProxy.fundAndSendUnsigned(fundingSource)); | ||
await ExtrinsicHelper.waitForFinalization((await getBlockNumber()) + 2); | ||
// adding some delay before fetching the nonce to ensure it is updated | ||
await new Promise((resolve) => setTimeout(resolve, 1000)); |
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 need to await finalization now that sendUnsigned
has been fixed to not resolve until the extrinsic is included in a finalized block.
@@ -264,6 +264,10 @@ export class Extrinsic<N = unknown, T extends ISubmittableResult = ISubmittableR | |||
public async fundAndSendUnsigned(source: KeyringPair) { | |||
await this.fundOperation(source); | |||
log('Fund and Send', `Fund Source: ${getUnifiedAddress(source)}`); | |||
return this.sendUnsigned(); |
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.
Deleted code block; now that sendUnsigned
is doing what this block used to do.
const accountPKey = getUnifiedPublicKey(fundedSr25519Keys); | ||
const nonce = await getNonce(fundedSr25519Keys); | ||
const transferAmount = 55_000_000n; |
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.
Do we have constants for these like DOLLARS and CENTS?
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.
Not sure, but the amount isn't important anyway; we just want to be sure to check that whatever amount is transferred, the balance changes by that amount.
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.
But that does remind me, it would be good to also check that the correct sender's balance decreases by the appropriate amount.
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.
👍 great!
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.
Lgtm
…c errors on failures
…#2246) # Goal The goal of this PR is to make the e2e tests for the passkey pallet a bit more discerning, and more clear to read. Previously, the tests were determining a successful token transfer by the absence of an exception and an increased nonce. While this is technically correct, according to the logic by which the extrinsic call would complete with no exceptions, it is a bit opaque. This PR enhances the test conditions to check that: * The appropriate events are generated in the block, and the event contents are correct * The correct reciever's balance is incremented by the transfer amount * The correct sender's balance is decremented by the transfer amount + fee * Failure tests are enhance to check the specific error that caused the failure Test conditions for the success cases are also enhanced so that successful tests are more verbose, as each check is encapsulated in a separate test block. Also, the function `Extrinsic.sendUnsigned()` was fixed to properly parse and return the event stream from the blockchain, in the same manner that `Extrinsic.signAndSend()` does. # Checklist - [ ] Updated Pallet Readme? - [ ] Updated js/api-augment for Custom RPC APIs? - [ ] Design doc(s) updated? - [ ] Unit Tests added? - [ ] e2e Tests added? - [ ] Benchmarks added? - [ ] Spec version incremented?
Goal
The goal of this PR is to make the e2e tests for the passkey pallet a bit more discerning, and more clear to read.
Previously, the tests were determining a successful token transfer by the absence of an exception and an increased nonce. While this is technically correct, according to the logic by which the extrinsic call would complete with no exceptions, it is a bit opaque.
This PR enhances the test conditions to check that:
Test conditions for the success cases are also enhanced so that successful tests are more verbose, as each check is encapsulated in a separate test block.
Also, the function
Extrinsic.sendUnsigned()
was fixed to properly parse and return the event stream from the blockchain, in the same manner thatExtrinsic.signAndSend()
does.Checklist