This question already has an answer here:

I am currently trying to push my unit testing far in order to achieve a complete coverage over my code. I am using Open Zepplin's Ownable.sol contract and I cannot find in the documentation something about mocking the user sending the request (understand msg.sender) using remix_test.sol.

Do any of you ever heard about or have done such a thing ?

marked as duplicate by Ismael, Achala Dissanayake, Richard Horrocks, Briomkez, eth Nov 3 '18 at 12:24

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • I think Ownable got deleted in the latest release because it was unsecure, but I could be wrong. – GrandFleet Nov 2 '18 at 23:16

You can use real address as msg.sender, you don't need any mocking here. Please refer to Open Zeppelin unit-test code for further information


For test on remix you can refer to sample test from remix ide


Hope this might help!

  • Hi and thanks for your answer ! It appears to me that these tests are not written with remix_tests.sol, but Mocha. I was wondering if there is a way to write them down using Remix only. – Vincent C. Nov 2 '18 at 4:21
  • I think we can use some default account of remix when you selecting run on Javascript VM – Ha ĐANG Nov 2 '18 at 4:28
  • Yeah, but it seems you cannot switch during the test... So when I launch using let's call it A user, the contract is supposed to be owned by A. When I start the test again changing to B user, the contract is supposed to be owned by B. – Vincent C. Nov 2 '18 at 4:40
  • you can use specific account like this from remix sample test code github.com/ethereum/remix/blob/master/remix-tests/tests/… – Ha ĐANG Nov 2 '18 at 8:03
  • Hmm, sorry but I don't think this is the answer to what I asked... Indeed, this allow me to get existing test accounts, but this doesn't allow my unit test to launch a function as if I was TestsAccounts.getAccount(1). – Vincent C. Nov 4 '18 at 7:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.