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

Add remove program function to entropy-client #1023

Merged
merged 7 commits into from
Aug 23, 2024
Merged

Conversation

ameba23
Copy link
Contributor

@ameba23 ameba23 commented Aug 22, 2024

This adds a function to remove a program to entropy-client, as well as a test for it.

It also adds a command to entropy-test-cli which calls this function.

@@ -228,14 +228,14 @@ pub async fn store_program(
auxiliary_data_interface: Vec<u8>,
oracle_data_pointer: Vec<u8>,
) -> Result<<EntropyConfig as Config>::Hash, ClientError> {
let update_program_tx = entropy::tx().programs().set_program(
let set_program_tx = entropy::tx().programs().set_program(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unrelated to this PR but just to tidy

.find_first::<entropy::programs::events::ProgramRemoved>()?
.ok_or(ClientError::CannotConfirmProgramRemoved)?;

if event.old_program_hash != program_hash {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dunno if this is really needed but why not

@ameba23 ameba23 requested review from HCastano and JesseAbram August 22, 2024 10:42
Comment on lines +271 to +273
let remove_program_tx = entropy::tx().programs().remove_program(program_hash);
let in_block =
submit_transaction_with_pair(api, rpc, deployer_pair, &remove_program_tx, None).await?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Something we might want to do is check if the error we get here is ProgramInUse and also return the reference counter (and maybe even accounts using it?).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I find these dispatch errors not so easy to do anything with, because you get a module error which contains the actual error from the pallet but doesnt directly publicly expose it, you have to get 'ModuleErrorDetails'.


#[tokio::test]
#[serial]
async fn test_store_and_remove_program() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure if it's worth testing since I'm pretty sure we check this elsewhere, but this should fail if the program's ref_count != 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok i have added an extra test for that.

* master:
  Clean up registration related tests in `pallet-registry` (#1021)
  Remove `prune_registration` extrinsic (#1022)
  Add benchmark for `new_session` hook (#1016)
@ameba23 ameba23 merged commit cc2d740 into master Aug 23, 2024
8 checks passed
@ameba23 ameba23 deleted the peg/remove-program-test branch August 23, 2024 12:58
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.

3 participants