-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTransfer.t.sol
52 lines (41 loc) · 1.76 KB
/
Transfer.t.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
import "./BaseRegistrarTest.t.sol";
contract TransferTest is BaseRegistrarTest {
address public caller = address(0xbeef);
address public owner = address(0xdead);
address public recipient = address(0xcafe);
uint256 public notaId;
function setUp() public override {
super.setUp();
_fundCallerApproveAddress(caller, DAI, 100 ether, address(REGISTRAR));
notaId = _registrarWriteHelper(caller, address(DAI), 1 ether, 0, owner, HOOK, "");
}
function testTransfer() public {
_registrarTransferAssumptions(owner, owner, recipient, notaId);
_registrarTransferHelper(owner, owner, recipient, notaId);
}
function testTransferApproved() public {
_registrarApproveHelper(owner, caller, notaId);
_registrarTransferHelper(caller, owner, recipient, notaId);
}
function testTransferOperator() public {
vm.expectEmit(true, true, true, true);
emit IERC721.ApprovalForAll(owner, caller, true);
vm.prank(owner);
REGISTRAR.setApprovalForAll(caller, true);
_registrarTransferHelper(caller, owner, recipient, notaId);
}
function testTransferFailUnauthorized(address unauthorized) public {
vm.assume(unauthorized != owner);
vm.assume(unauthorized != REGISTRAR.getApproved(notaId));
vm.assume(!REGISTRAR.isApprovedForAll(owner, unauthorized));
vm.expectRevert("NOT_APPROVED_OR_OWNER");
vm.prank(unauthorized);
REGISTRAR.transferFrom(owner, recipient, notaId);
}
function testFuzzTransfer(address to) public {
_registrarTransferAssumptions(owner, owner, to, notaId);
_registrarTransferHelper(owner, owner, to, notaId);
}
}