Pocket-IC : get_stable_memory of sns_governance canister returns empty []

I’m using pocket-ic to do some integration testing.

As part of my testing I have installed an sns governance canister that holds some neurons.

I want to be able to set the neuron data inside the governance canister at different times in my tests.

When i run the below code, I get [].

let canister_state_raw = pic.get_stable_memory(sns_canister_id);
println!("{:?}", canister_state_raw); // returns []

let canister_state: Governance = decode_one(&canister_state_raw).unwrap(); // fails here because there is no bytes to decode.
println!("{:?}", canister_state.neurons.len());

I’ve verified that the sns governance canister is being installed correctly and I can even run query calls to get the neurons i initialized the canister with.

Any ideas that might set me on the right track to debug this?

Thanks,

Freddie

Looking at the sns governance code I can only see references to stable memory in pre_ and post_upgrade. Did you ever upgrade the governance canister? Otherwise I would assume it is expected that there is nothing written to stable memory

Hi Severin,

No, I never upgraded the canister but I guess I will have to in order for stable memory to be present. If that’s what I’m missing then thanks :slight_smile:

Do you think there is a simpler way to effectively increase the Neuron maturity instead of doing the upgrade and setting the neuron state manually with get/set_stable_memory

Cheers,

Freddie

I don’t think this works to modify neuron maturity. Data is kept in-memory and only during upgrades it is temporarily written to stable memory and then read instantly after. If you then go and manipulate stable memory it won’t have any effect.

What I would suggest instead is to manipulate time. If you use e.g. create a useless proposal, vote, and then set_time you can quickly jump a few days into the future and let maturity accumulate like that.

1 Like