Skip to content
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

Subkeys 2 #28

Merged
merged 9 commits into from
Aug 12, 2020
Merged

Subkeys 2 #28

merged 9 commits into from
Aug 12, 2020

Conversation

maurolacy
Copy link
Contributor

Improved test cases after previous PR comments.

Added the two remaining test cases.

@maurolacy maurolacy self-assigned this Aug 8, 2020
@maurolacy
Copy link
Contributor Author

Still need to test execute(). Guess I'll need an integration test for it... will be working on it asap.

ethanfrey
ethanfrey previously approved these changes Aug 11, 2020
Copy link
Member

@ethanfrey ethanfrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice tests. I propose some cleanup of variables, maybe I just do that then merge

&initial_expirations,
);

// Check allowances work for accounts with balances
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice tests


// Add a third (new) admin
let msg = HandleMsg::UpdateAdmins {
admins: [&config.admins[..], &[admin3.clone()]].concat(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of the spread and concat operators. But somehow, I would prefer to see this more explicit.

let new_admins = vec![owner.clone(), admin2.clone(), admin3.clone()]
let msg = HandleMsg::UpdateAdmins { admins: new_admins.clone() };
// ...
assert_eq!(config, ConfigResponse { admins: new_admins, mutable: true });

This is the exact same functionality you have written but easier to read. And key in test cases is legibility (performance is not an issue)

@ethanfrey
Copy link
Member

Going through this code again, not the PR, I notice there is no test for execute, that the allowances work as they are supposed to.

@ethanfrey ethanfrey dismissed their stale review August 11, 2020 19:04

I realized key execute tests were missing. Cannot approve yet

@maurolacy
Copy link
Contributor Author

Yes. I'll write the execute() tests tomorrow.

Copy link
Member

@ethanfrey ethanfrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there

e => panic!("unexpected error: {}", e),
}

// Owner / admins can do anything (at the contract level)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good test case.

Can you add another where the spender (with allowance) tries to send a message besides BankMsg::Send. Anything else to show it fails.

Just one more test and this is 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do.

Copy link
Member

@ethanfrey ethanfrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks for the fixes

@ethanfrey ethanfrey merged commit 9bc70ef into master Aug 12, 2020
@ethanfrey ethanfrey deleted the subkeys-2 branch August 12, 2020 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants