Skip to content

Commit 3a0023c

Browse files
fix: Intermittent test failure in cicd from newing in unit test (#233)
* fix(drop 2): avalanche deploy address issue - update avalanche factory and registry address - update chain implementation Ids * draft rotation of salt * forge fmt.... * deploy create2 from different user * add more verbose debugging in cicd * add more verbose debugging in cicd * remove forge fmt * remove forge fmt * remove forge fmt * found you * add back forge fmt * actually run forge fmt now --------- Co-authored-by: Ogooluwa Akinola <[email protected]>
1 parent b87a816 commit 3a0023c

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ jobs:
4141

4242
- name: Run Forge tests
4343
run: |
44-
forge test -vvv
44+
forge test -vvvv
4545
id: test

test/factory/MagicDropCloneFactoryTest.t.sol

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ contract MockERC1155Initializable is MockERC1155 {
2020
}
2121

2222
contract InvalidImplementation is MockERC721 {
23-
function initialize(string memory) public {} // Missing name and symbol parameters
23+
function initialize(string memory) public {
24+
revert("deliberate failure");
25+
} // Missing name and symbol parameters
2426
}
2527

2628
contract MagicDropCloneFactoryTest is Test {
@@ -34,10 +36,13 @@ contract MagicDropCloneFactoryTest is Test {
3436

3537
uint32 internal erc721ImplId;
3638
uint32 internal erc1155ImplId;
39+
InvalidImplementation invalidImplementation;
3740

3841
function setUp() public {
3942
vm.startPrank(owner);
4043

44+
invalidImplementation = new InvalidImplementation();
45+
4146
// Deploy and initialize registry
4247
address registryImpl = LibClone.clone(address(new MagicDropTokenImplRegistry()));
4348
registry = MagicDropTokenImplRegistry(payable(registryImpl));
@@ -156,16 +161,16 @@ contract MagicDropCloneFactoryTest is Test {
156161
vm.startPrank(user);
157162

158163
factory.createContractDeterministic{value: 0.01 ether}(
159-
"TestNFT1", "TNFT1", TokenStandard.ERC721, payable(user), erc721ImplId, bytes32(0)
164+
"TestNFT1", "TNFT1", TokenStandard.ERC721, payable(user), erc721ImplId, bytes32(uint256(100))
160165
);
161166
vm.expectRevert();
162167
factory.createContractDeterministic{value: 0.01 ether}(
163-
"TestNFT2", "TNFT2", TokenStandard.ERC721, payable(user), erc721ImplId, bytes32(0)
168+
"TestNFT2", "TNFT2", TokenStandard.ERC721, payable(user), erc721ImplId, bytes32(uint256(100))
164169
);
165170
}
166171

167172
function testContractAlreadyDeployed() public {
168-
bytes32 salt = bytes32(uint256(1));
173+
bytes32 salt = bytes32(uint256(101));
169174
uint32 implId = 1;
170175
TokenStandard standard = TokenStandard.ERC721;
171176
address initialOwner = address(0x1);
@@ -188,21 +193,22 @@ contract MagicDropCloneFactoryTest is Test {
188193
TokenStandard standard = TokenStandard.ERC721;
189194

190195
vm.startPrank(owner);
191-
InvalidImplementation impl = new InvalidImplementation();
192-
uint32 implId = registry.registerImplementation(standard, address(impl), false, 0.01 ether, 0.00001 ether);
196+
197+
uint32 implId =
198+
registry.registerImplementation(standard, address(invalidImplementation), false, 0.01 ether, 0.00001 ether);
193199
vm.stopPrank();
194200

195201
vm.expectRevert(MagicDropCloneFactory.InitializationFailed.selector);
196202
factory.createContractDeterministic{value: 0.01 ether}(
197-
"TestNFT", "TNFT", standard, payable(user), implId, bytes32(0)
203+
"TestNFT", "TNFT", standard, payable(user), implId, bytes32(uint256(102))
198204
);
199205
}
200206

201207
function testInsufficientDeploymentFee() public {
202208
vm.startPrank(user);
203209
vm.expectRevert(MagicDropCloneFactory.InsufficientDeploymentFee.selector);
204210
factory.createContractDeterministic{value: 0.005 ether}(
205-
"TestNFT", "TNFT", TokenStandard.ERC721, payable(user), erc721ImplId, bytes32(0)
211+
"TestNFT", "TNFT", TokenStandard.ERC721, payable(user), erc721ImplId, bytes32(uint256(103))
206212
);
207213
}
208214

0 commit comments

Comments
 (0)