Error when querying contract storage that was modified
I get the error pictured at the bottom when I use Test.get_storage ADDR
on a contract (ADDR
) whose memory has been modified through a transaction via one of its entrypoints. The same problem does not occur if I run Test.get_storage_of_address (Tezos.address (Test.to_contract ADDR ))
.
The example for which this works is for testing the ctez
repo, here: https://github.com/differentialderek/ctez/blob/simple-cfmm/tests/test.mligo
(See line 106
)
A minimal example is here:
// Minimal e.g.
type storage = (int, address) big_map
type parameter =
Change of address
| Do_nothing
type return = operation list * storage
// One entrypoint
let change (store, new_store : storage * address) : storage = Big_map.literal [ (0, new_store); ]
// Main function
let main (action, store : parameter * storage) : return =
([] : operation list), // No operations
(match action with
Change new_store -> (change (store, new_store))
| Do_nothing -> store)
// Test
let test =
// initialize contract
let init_storage = (Big_map.literal [ (0, ("tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU" : address)) ] : storage) in
let (typed_addr, pgm, size) =
Test.originate main init_storage 0tez in
// get entrypoint
let entrypoint =
((Test.to_entrypoint "change" typed_addr) : address contract) in
let new_addr = ("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" : address) in
// update storage
let update_storage = Test.transfer_to_contract_exn entrypoint new_addr 0tez in
Test.get_storage typed_addr
Resulting error (the same no matter the code):