-
Notifications
You must be signed in to change notification settings - Fork 15
Smock call record is wiped out after every transaction #38
Comments
Looking into this! |
I see that you're using |
Hmmm I ran this locally but didn't get any errors. Could you double check the reproduction steps? Maybe I'm just looking at the wrong file |
Hey sorry I had not pushed the failing line 🤦 it should work (or rather not work) now |
Hah, no problem. Trying again now. |
Ahhh okay. This is an issue I've been aware of but haven't written up a ticket for yet. You can actually get your test to pass if you swap the ordering of statements in your test as follows: // original
const newTokenOwner = await ERC721.ownerOf(depositTokenId)
expect(newTokenOwner).to.equal(OVM_ERC721Gateway.address)
const depositCallToMessenger =
Mock__OVM_L1CrossDomainMessenger.smocked.sendMessage.calls[0]
// Message should be sent to the L2ERC20Gateway on L2
expect(depositCallToMessenger._target).to.equal(
Mock__OVM_DepositedERC721.address
) // "fixed"
const depositCallToMessenger =
Mock__OVM_L1CrossDomainMessenger.smocked.sendMessage.calls[0]
// Message should be sent to the L2ERC20Gateway on L2
expect(depositCallToMessenger._target).to.equal(
Mock__OVM_DepositedERC721.address
)
const newTokenOwner = await ERC721.ownerOf(depositTokenId)
expect(newTokenOwner).to.equal(OVM_ERC721Gateway.address) The underlying reason for this is because I implemented the
|
Dreamy that worked! And the long-term fix sounds great too. Thanks so much. Sorry I thought I had tried changing the order around a bit but clearly not enough. |
No problem! I'm going to leave this issue open as a reference + add to the 1.0 roadmap. Thank you again for the report!! |
I came here to report a similar issue, ie. if no calls have been made to a function, then the Example, I wanted to test that under a certain condition, no call is made to a contract. Using smock I would do something like:
That results in the same error in the above description ( LMK if you'd like a separate issue to support an empty |
@maurelian could you make another issue for this? Supporting empty calls is much easier than the full update to the call assertion format so I'd like to push out a temp fix for that ASAP. Having a separate issue will make that specific bug easier to track. |
Describe the bug
When implementing onERC721Received functionality on an ERC721 Gateway, the
smocked
pattern used in the other tests fails with:The functionality is working in integration tests (i.e. the token is being passed across the bridge when this function is called), verified on this branch: https://github.com/austintgriffith/scaffold-eth/tree/oo-wip
To Reproduce
https://github.com/azf20/contracts/tree/erc721-bridge-smocking-onERC721Received
Fails with
TypeError: Cannot read property 'map' of undefined
Expected behavior
The smocked call information is returned to verify that the implementation is correct
System Specs:
Additional context
This could be user error (on my part), but the function is working as intended and the pattern works in the other tests.
The text was updated successfully, but these errors were encountered: