contractA
function test() internal {
stateVariable = 20;
uint num = 20;
assembly {
mstore(0x00, num)
return(0x00, 0x20)
}
}
How do I test the return
? I am using hardhat
, but i don't think it changes anything.
Step 1: I should create another contract contractB
which is a mock and which is the child of the contractA
. This way, I can make this contractB
's function public and it will include the internal function - test
.
After this, I'd appreciate if I could hear your opinions what could be the best way to make sure to test this.
contractB's
public function ? when calling a transaction from javascript, it doesn't return the value.. – Nika Kurashvili Feb 26 at 9:27test
generate an event with the returned value. The tricky part is thatreturn
ends the whole call that invokestest
so you need some kind of indirection like using .call or .delegatecall to invoke test. – Ismael Feb 26 at 16:07