-
Notifications
You must be signed in to change notification settings - Fork 8
accessing/modifying external once set & question about external in general #13
Comments
This global i think |
@fckt it would be great if you could implement |
@NikVolf do i understand this correctly?: |
that's correct |
i tried a few approaches in implementing the most promising way goes through one could also do some nasty unsafe transmute stuff but we shouldn't consider that. there doesn't seem to be an easy way. all approaches feel somewhat hacky! |
@fckt i figured out a way to implement it also requires the following change: 2fcb56d a downside is that any testing implementations of i hope our discussion in openethereum/pwasm-token-example#10 will lead to an overall better solution that will remove the need for at least now i can continue writing tests for https://github.com/paritytech/pwasm-token-example |
close due to inactivity |
i'm in the process of writing tests for https://github.com/paritytech/pwasm-token-example
(working on branch https://github.com/paritytech/pwasm-token-example/tree/tests) and thinking about how to improve the testing experience for rust pwasm contracts.
now i'm stuck writing a test that involves:
a
(pwasm_test::set_external
)a
again either to assert something on it or in order to modify it3.1 often one will want to have
sender
return different things for different contract calls in tests while reusing the rest of the external state3.
seems hard to do.pwasm_test::set_external
moves the external and now it's hard to access it.pointers towards implementing
pwasm_test::get_external
would be greatly appreciated!test_with_external!
to me seems useful only for trivial tests currently as most real world tests will involve testing interaction with external by accessing external again after the test body has run.maybe i'm missing something obvious!
a related question:
can someone enlighten me why we are using the whole
EXTERNAL
thread local global mutable state (https://github.com/paritytech/pwasm-test/blob/master/src/externs.rs#L12)?if the contract functions took an impl of
External
as an argument then we would not need global mutable state.from the contract developers/testers perspective that would make things much more simple, easier to reason about, harder to screw up.
The text was updated successfully, but these errors were encountered: