Skip to content

Commit 5779ab1

Browse files
committed
Move all transfer integration tests to BuilderCodeTransfers
1 parent 43da4e0 commit 5779ab1

File tree

2 files changed

+50
-50
lines changed

2 files changed

+50
-50
lines changed

test/integration/BuilderCodeTransfers.t.sol

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,53 @@ contract BuilderCodesTransfersTest is BuilderCodesTest {
5252
assertEq(builderCodes.balanceOf(from), 0);
5353
assertEq(builderCodes.balanceOf(to), 1);
5454
}
55+
56+
/// @notice Test that transferred code preserves the payout address
57+
///
58+
/// @param codeSeed The seed for generating the code
59+
/// @param initialOwner The initial owner address
60+
/// @param payoutAddress The payout address
61+
/// @param secondOwner The second owner address
62+
/// @param newPayoutAddress The new payout address for testing updates
63+
function test_transferedCodePreservesPayoutAddress(
64+
uint256 codeSeed,
65+
address initialOwner,
66+
address payoutAddress,
67+
address secondOwner,
68+
address newPayoutAddress
69+
) public {
70+
initialOwner = _boundNonZeroAddress(initialOwner);
71+
payoutAddress = _boundNonZeroAddress(payoutAddress);
72+
secondOwner = _boundNonZeroAddress(secondOwner);
73+
newPayoutAddress = _boundNonZeroAddress(newPayoutAddress);
74+
75+
vm.assume(initialOwner != secondOwner);
76+
77+
string memory code = _generateValidCode(codeSeed);
78+
79+
// Register the code with initial owner and payout address
80+
vm.prank(registrar);
81+
builderCodes.register(code, initialOwner, payoutAddress);
82+
83+
// Verify initial state
84+
uint256 tokenId = builderCodes.toTokenId(code);
85+
assertEq(builderCodes.ownerOf(tokenId), initialOwner);
86+
assertEq(builderCodes.payoutAddress(code), payoutAddress);
87+
88+
// Transfer the code to second owner
89+
vm.prank(owner);
90+
builderCodes.grantRole(TRANSFER_ROLE, initialOwner);
91+
vm.prank(initialOwner);
92+
builderCodes.transferFrom(initialOwner, secondOwner, tokenId);
93+
94+
// Verify ownership changed but payout address preserved
95+
assertEq(builderCodes.ownerOf(tokenId), secondOwner);
96+
assertEq(builderCodes.payoutAddress(code), payoutAddress, "Payout address should be preserved after transfer");
97+
98+
// Verify new owner can update payout address
99+
vm.prank(secondOwner);
100+
builderCodes.updatePayoutAddress(code, newPayoutAddress);
101+
102+
assertEq(builderCodes.payoutAddress(code), newPayoutAddress);
103+
}
55104
}

test/integration/BuilderCodesOperations.t.sol renamed to test/integration/BuilderCodesAdminOperations.t.sol

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,56 +7,7 @@ import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
77
import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";
88

99
/// @notice Integration tests for BuilderCodes operations
10-
contract BuilderCodesOperationsTest is BuilderCodesTest {
11-
/// @notice Test that transferred code preserves the payout address
12-
///
13-
/// @param codeSeed The seed for generating the code
14-
/// @param initialOwner The initial owner address
15-
/// @param payoutAddress The payout address
16-
/// @param secondOwner The second owner address
17-
/// @param newPayoutAddress The new payout address for testing updates
18-
function test_transferedCodePreservesPayoutAddress(
19-
uint256 codeSeed,
20-
address initialOwner,
21-
address payoutAddress,
22-
address secondOwner,
23-
address newPayoutAddress
24-
) public {
25-
initialOwner = _boundNonZeroAddress(initialOwner);
26-
payoutAddress = _boundNonZeroAddress(payoutAddress);
27-
secondOwner = _boundNonZeroAddress(secondOwner);
28-
newPayoutAddress = _boundNonZeroAddress(newPayoutAddress);
29-
30-
vm.assume(initialOwner != secondOwner);
31-
32-
string memory code = _generateValidCode(codeSeed);
33-
34-
// Register the code with initial owner and payout address
35-
vm.prank(registrar);
36-
builderCodes.register(code, initialOwner, payoutAddress);
37-
38-
// Verify initial state
39-
uint256 tokenId = builderCodes.toTokenId(code);
40-
assertEq(builderCodes.ownerOf(tokenId), initialOwner);
41-
assertEq(builderCodes.payoutAddress(code), payoutAddress);
42-
43-
// Transfer the code to second owner
44-
vm.prank(owner);
45-
builderCodes.grantRole(TRANSFER_ROLE, initialOwner);
46-
vm.prank(initialOwner);
47-
builderCodes.transferFrom(initialOwner, secondOwner, tokenId);
48-
49-
// Verify ownership changed but payout address preserved
50-
assertEq(builderCodes.ownerOf(tokenId), secondOwner);
51-
assertEq(builderCodes.payoutAddress(code), payoutAddress, "Payout address should be preserved after transfer");
52-
53-
// Verify new owner can update payout address
54-
vm.prank(secondOwner);
55-
builderCodes.updatePayoutAddress(code, newPayoutAddress);
56-
57-
assertEq(builderCodes.payoutAddress(code), newPayoutAddress);
58-
}
59-
10+
contract BuilderCodesAdminOperationsTest is BuilderCodesTest {
6011
/// @notice Test that adding many registrars works
6112
///
6213
/// @param testOwner The owner address for testing

0 commit comments

Comments
 (0)