Skip to content

Commit

Permalink
feat: fix specs
Browse files Browse the repository at this point in the history
  • Loading branch information
wellitongervickas committed Dec 5, 2023
1 parent f7d792c commit 3288635
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
4 changes: 1 addition & 3 deletions contracts/adapters/CCIPAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions contracts/mocks/MockBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
Expand Down
17 changes: 11 additions & 6 deletions test/adapters/ccip/CCIPAdapter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 3288635

Please sign in to comment.