-
Notifications
You must be signed in to change notification settings - Fork 73
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
Add schedule_as into TaskScheduled event #365
Conversation
25baf2f
to
d130d45
Compare
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’m not confident to check this in without unit tests. When you get time, please write down the design of unit test cases to make sure event filing for this xcmp task is right with a variety of inputs.
The design of unit test case:
|
d130d45
to
edc25f7
Compare
@@ -267,6 +267,49 @@ fn schedule_xcmp_works() { | |||
}) | |||
} | |||
|
|||
#[test] |
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 need to include more tests around this function. For example,
- schedule through an empty wallet address(empty string).
- schedule through an invalid Turing wallet address.
- schedule through a wallet address that is the same as the owner wallet.
- schedule with an invalid multi-location
- schedule with a non-existent multi-location
- Could verify that the task can execute with a correct proxy?
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.
1. schedule through an empty wallet address(empty string).
The AccountId32::new(bytes) method requires a byte array parameter with 32 elements. An empty wallet address cannot be used to construct an AccountId32 variable.
let user_account = AccountId32::new([]);
| ---------------- ^^ expected an array with a fixed size of 32 elements, found one with 0 elements
| |
| arguments to this function are incorrect
|
= note: expected array `[u8; 32]`
found array `[_; 0]`
2. schedule through an invalid Turing wallet address.
The code within the automation time pallet does not perform validation checks on the account addresses.
Account address validation is a feature provided by the Substrate framework, which verifies the checksum of user addresses during actual runtime. I haven't verified this aspect yet.
However, in functional testing, incorrect account addresses will not result in an error.
schedule_as
is a AccountId
type parameter.
If you create an scheduleXcmpTaskThroughProxy extrinsic with polkadot.js API on Turing chain with other ss58 prefix address, polkadot.js API will convert it to a Turing address.
YFbVAJHJbn5sH523f3o6iLeropaD5CREtocrkPaGVzpJ5iz
will be converted to 68TwNoCpyz1X3ygMi9WtUAaCb8Q6jWAMvAHfAByRZqMFEtJG
If the conversion fails, an error will be thrown:
Struct: failed on schedule_as: AccountId:: Decoding YFbVAJHJbn5sH523f3o6iLeropaD5CREtocrkPaGVzpJ222: Invalid decoded address checksum.
4. schedule with an invalid multi-location
5. schedule with a non-existent multi-location
The automation time pallet does not check on whether destination
parameter is a valid MultiLocation, as that responsibility lies within the XCM module.
Alternatively, end-to-end (E2E) tests can be done to verify it.
The automation-time pallet does not check xcm_asset_location
parameter.
Because the calculation logic of XCM instruction fee is in the xcmp-handler pallet.
In the mock implementation, we do not provide real functionality.
6. Could verify that the task can execute with a correct proxy?
The MockEnsureProxy
is only used for automation-time testing purposes. However, it is not a fully functional proxy module in a real sense.
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.
- a wrong
xcm_asset_location
for destination doesn’t cause error on our XcmMessageSent, but causing one on relay chain instead. Therefore, we can’t test the validity in our chain’s code.
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.
Looks good to me!
Fixed the problem that when calling
scheduleXcmpTaskThroughProxy
, thewho
parameter of TaskScheduled was inconsistent withAccountId32
inautomationTime.accountTasks
in storage.who
is always the caller for extrinsic.