Replies: 1 comment 5 replies
-
Can you |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey Richard. @ricmoo
So I am at the point of hitting my brain on the wall and hoping you could give me some hints about this.
I am using
zksync
network and have the following in my tests.Note that I am as well using `"@nomicfoundation/hardhat-chai-matchers": "1.0.6``` which uses ethers v5 and also, in my own code, I am using ethers v5. All the zksync package that I am using also uses ethers v5.
Note that the
revertedWith
function from chai has the following line in the code:So you might think that everything is fine, but the following line doesn't work and to explain this, I will list down scenearios.
When the network is zksync
SCENARIO 1: Using zksync packages such that they use v6.
The transaction is made and the returned result(which is an error) contains
data
field which is an abi encoded error message. Since it containsdata
, all is good and chai matcher doesn't throw an error(see the above)SCENARIO 2: Using zksync packages such that they use v5.
Well, in such case, the returned thing from ethers doesn't contain
data
, but onlyreason: execution reverted: failMessage
and some other things, but notdata
field. Hence, chai matcher fails and can't do its job.When the network is hardhat or normal EVM
Well, here it doesn't matter which version of ethers is used. It just works for both as
data
is returned. I wonder whydata
field is not returned for zksync network by ethers v5.I wonder if you are aware of this and how can I fix this problem ? Note that I can't use ethers v6 because my project is big and can't really upgrade. If I use zksync packages such that they use ethers v6, then i got dependency problems. So the only way I can do is to use ethers v5 in my project and also use zksync packages such that they use ethers v5.
In such circumstance, I end up in Scenario 2 above. at one point, I thought what if I write my custom revertedWith, but since ether's error returned won't contain
data
field, I am not sure how to extract the error. getting it fromreason
doesn't sound right in my opinion.What would you advise ? :(
Beta Was this translation helpful? Give feedback.
All reactions