-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
@@ -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( |
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.
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 { |
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.
Dunno if this is really needed but why not
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?; |
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.
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?).
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 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() { |
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 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
.
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.
ok i have added an extra test for that.
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.