After writing tests for NNS maturity disbursement me and my colleague noticed that the manage_neuron function returns None instead of Ok even though the results of the test show that the maturity was successfully transferred/disbursed to the account that is supposed to receive it.
Is this the expected behavior/logic for this scenario because to me it seems strange that if the transfer succeeded we would receive None?
If that is the expected behavior we will change our code to not treat None as an error in that case.
Below is our current handling of the response:
match nns_governance_canister_c2c_client::manage_neuron(
nns_governance_canister_id,
manage_neuron,
)
.await
{
Ok(manage_neuron_response) => match manage_neuron_response.command {
Some(
nns_governance_canister::types::manage_neuron_response::Command::DisburseMaturity(
response,
),
) => {
info!("Successfully disbursed maturity for neuron {:?}", response);
Ok(())
}
Some(response) => {
let error_msg = format!("Unexpected response from manage_neuron: {:?}", response);
error!("{}", error_msg);
return Err(error_msg);
}
None => {
let error_msg = "manage_neuron response contained no command.".to_string();
error!("{}", &error_msg);
return Err(error_msg);
}
},
Err(e) => {
let error_msg = format!(
"Failed to disburse maturity for neuron {:?}: {:?}",
neuron_id, e
);
error!("{}", &error_msg);
return Err(error_msg);
}
}
Would love to hear from someone who encountered something similar or can help explain the logic behind this.