Closed megamattron closed 2 years ago
Hi Matt 👋
Usually those are only abstractions of actual transaction confirmations (simple javascript loops and intervals wrapped in promises and/or callbacks).
You need to confirm
the mocked transaction in order to trigger those: see here
It actually also required a small patch to make it work with web3js (which I've added in v11.2.0).
I've also added a test dedicated to web3js contract interactions that can serve as an example in this case: https://github.com/DePayFi/web3-mock/blob/main/tests/units/web3wallet/web3js-contracts.spec.js
Let me know if there is anything else.
Thank you for the help! When I call confirm on my mocked transaction it seems to open an alert in the web UI shown in Cypress, is this what the 11.2 patch was supposed to fix? Perhaps I'm not correctly on the latest version?
There is one thing I've noticed with web3js that transactions are not sent immediately. Hence in the example test I added a 1 second timeout before confirming it: see https://github.com/DePayFi/web3-mock/blob/main/tests/units/web3wallet/web3js-contracts.spec.js#L57
web3-mock does not trigger any alert dialogs, so maybe you're catching errors somewhere in your code and trigger an alert there?
Any errors in the cypress console?
Otherwise you can also add a console.log('SENDING worked')
as first thing in your on('sending')
and a console.log('RECEIPT worked')
as first thing in your once('receipt')
callback in your code to see if you even get there.
I think this has been solved – right?
Let me know if otherwise, or if you have any further feedback/questions @megamattron
Yes, thank you. We didn't end up using this particular feature but the other fixes were super helpful, thanks again!
I have mocked a transaction to a contract which seems to be working well, but I'm not sure how to trigger events like "sending" or "receipt". For example, in our app code something like:
Thank you!