From 3288635054565bdd87767801e5d25062ef04fd0f Mon Sep 17 00:00:00 2001 From: welliton gervickas Date: Mon, 4 Dec 2023 21:08:18 -0300 Subject: [PATCH] feat: fix specs --- contracts/adapters/CCIPAdapter.sol | 4 +--- contracts/mocks/MockBridge.sol | 4 ++-- test/adapters/ccip/CCIPAdapter.spec.ts | 17 +++++++++++------ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/contracts/adapters/CCIPAdapter.sol b/contracts/adapters/CCIPAdapter.sol index 08d84c1..fb7a929 100644 --- a/contracts/adapters/CCIPAdapter.sol +++ b/contracts/adapters/CCIPAdapter.sol @@ -75,12 +75,10 @@ contract CCIPAdapter is BaseAdapter, CCIPReceiver { function _receiveMessage(IBridge.ERC721Receive memory payload_) internal virtual override { try IBridge(bridge()).receiveERC721(payload_) { - /// @dev if success, just bypass + emit IBaseAdapter.ERC721Received(payload_.fromChain, payload_.sender, payload_.data); } catch { _setPendingMessage(payload_); } - - emit IBaseAdapter.ERC721Received(payload_.fromChain, payload_.sender, payload_.data); } function _setPendingMessage(IBridge.ERC721Receive memory payload_) private { diff --git a/contracts/mocks/MockBridge.sol b/contracts/mocks/MockBridge.sol index 5b5faf0..ea62437 100644 --- a/contracts/mocks/MockBridge.sol +++ b/contracts/mocks/MockBridge.sol @@ -10,8 +10,8 @@ contract MockBridge { bool public s_isLocked; - function lock() external { - s_isLocked = true; + function lock(bool status_) external { + s_isLocked = status_; } event ERC721Received(ERC721Receive indexed message_); diff --git a/test/adapters/ccip/CCIPAdapter.spec.ts b/test/adapters/ccip/CCIPAdapter.spec.ts index b9a4e58..007f04b 100644 --- a/test/adapters/ccip/CCIPAdapter.spec.ts +++ b/test/adapters/ccip/CCIPAdapter.spec.ts @@ -213,10 +213,12 @@ describe('CCIPAdapter', function () { destTokenAmounts: [] } - await mockBridge.lock() + await mockBridge.lock(true) await ccipAdapter.ccipReceive(payload) + await mockBridge.lock(false) + await expect(ccipAdapter.manuallyExecuteMessages(1)) .to.emit(ccipAdapter, 'ERC721Received') .withArgs( @@ -262,9 +264,10 @@ describe('CCIPAdapter', function () { destTokenAmounts: [] } - await mockBridge.lock() - + await mockBridge.lock(true) await ccipAdapter.ccipReceive(payload) + await mockBridge.lock(false) + await ccipAdapter.manuallyExecuteMessages(1) const executedMessage = await ccipAdapter.getExecutedMessage(0) @@ -316,10 +319,12 @@ describe('CCIPAdapter', function () { destTokenAmounts: [] } - await mockBridge.lock() + await mockBridge.lock(true) await ccipAdapter.ccipReceive(payload) + await mockBridge.lock(false) + const pendingMessage = await ccipAdapter.getPendingMessage(0) expect({ @@ -369,9 +374,9 @@ describe('CCIPAdapter', function () { destTokenAmounts: [] } - await mockBridge.lock() - + await mockBridge.lock(true) await ccipAdapter.ccipReceive(payload) + await mockBridge.lock(false) await expect(ccipAdapter.manuallyExecuteMessages(10)) .to.emit(ccipAdapter, 'ERC721Received')