Skip to content

Commit 32dafd3

Browse files
committed
use this.attest.selector
1 parent f91a8cc commit 32dafd3

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/allocators/SimpleAllocator.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ contract SimpleAllocator is ISimpleAllocator {
8686
revert InsufficientBalance(from_, id_, balance, fullAmount);
8787
}
8888

89-
return 0x1a808f91;
89+
return this.attest.selector;
9090
}
9191

9292
/// @inheritdoc IERC1271

test/SimpleAllocator.t.sol

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,34 @@ contract SimpleAllocator_Attest is Deposited {
486486
compactContract.transfer(user, attacker, defaultAmount, address(usdc), address(simpleAllocator));
487487
}
488488

489+
function test_successfullyAttested_returnsSelector() public {
490+
bytes4 selector = bytes4(0x1a808f91);
491+
492+
uint32 transferAmount = 10;
493+
uint32 lockedAmount = 90;
494+
495+
address otherUser = makeAddr('otherUser');
496+
497+
// Lock tokens
498+
uint256 defaultExpiration_ = vm.getBlockTimestamp() + defaultResetPeriod;
499+
vm.prank(user);
500+
simpleAllocator.lock(
501+
Compact({
502+
arbiter: arbiter,
503+
sponsor: user,
504+
nonce: defaultNonce,
505+
id: usdcId,
506+
expires: defaultExpiration_,
507+
amount: lockedAmount
508+
})
509+
);
510+
compactContract.transfer(user, otherUser, transferAmount, address(usdc), address(simpleAllocator));
511+
512+
vm.prank(address(compactContract));
513+
bytes4 returnedSelector = simpleAllocator.attest(user, user, otherUser, usdcId, transferAmount);
514+
assertEq(returnedSelector, selector);
515+
}
516+
489517
function test_successfullyAttested(uint32 lockedAmount_, uint32 transferAmount_) public {
490518
transferAmount_ = uint32(bound(transferAmount_, 0, defaultAmount));
491519
lockedAmount_ = uint32(bound(lockedAmount_, 0, defaultAmount - transferAmount_));

0 commit comments

Comments
 (0)