jet-lab / jet-simulation

An in-memory simulated Solana runtime to use for testing program instructions.
GNU Affero General Public License v3.0
0 stars 0 forks source link

support localnet in custom program error assertion #6

Closed dnut closed 2 years ago

dnut commented 2 years ago

This upgrades the macro that was used to assert that an instruction returned a program error during a test in simulation.

add support for localnet

RpcClient propagates program errors through a ClientError instead of ProgramError so this tries to destruct the generic error as each of those before failing, instead of requiring ProgramError.

move to function, macro is not needed

Maybe this was easier to get working as a macro but it also works as a function. Typically if the same job can be done with a function, I prefer to use a function, because it's more straightforward to deal with problems in concrete code than meta-code. It works with any std::error::Error that downcasts to a ProgramError or ClientError through anyhow.

consolidate duplicate implementations

There were two macros doing basically the same thing that now share the same function implementation under the hood. Backwards compatibility is retained, and the macros are only deprecated for now. I'm switching all the tests to use the function in jet-v2 orca branch. I propose deleting the macros soon once changes propagate to master in all dependents.