Skip to content

Commit a603d4a

Browse files
fix forge tests
1 parent ae656d9 commit a603d4a

File tree

2 files changed

+36
-23
lines changed

2 files changed

+36
-23
lines changed

src/test/ByocRegistry.t.sol renamed to src/test/ContractPublisher.t.sol

+31-18
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
pragma solidity ^0.8.0;
33

44
// Target contracts
5-
import { ByocRegistry } from "contracts/ByocRegistry.sol";
6-
import "contracts/interfaces/IByocRegistry.sol";
5+
import { ContractPublisher } from "contracts/ContractPublisher.sol";
6+
import "contracts/interfaces/IContractPublisher.sol";
77
import "contracts/TWRegistry.sol";
88

99
// Test helpers
@@ -18,7 +18,7 @@ contract MockCustomContract {
1818
}
1919
}
2020

21-
contract IByocRegistryData {
21+
contract IContractPublisherData {
2222
/// @dev Emitted when the registry is paused.
2323
event Paused(bool isPaused);
2424

@@ -29,7 +29,7 @@ contract IByocRegistryData {
2929
event ContractPublished(
3030
address indexed operator,
3131
address indexed publisher,
32-
IByocRegistry.CustomContractInstance publishedContract
32+
IContractPublisher.CustomContractInstance publishedContract
3333
);
3434

3535
/// @dev Emitted when a contract is unpublished.
@@ -42,8 +42,8 @@ contract IByocRegistryData {
4242
event RemovedContractToPublicList(address indexed publisher, string indexed contractId);
4343
}
4444

45-
contract ByocRegistryTest is BaseTest, IByocRegistryData {
46-
ByocRegistry internal byoc;
45+
contract ContractPublisherTest is BaseTest, IContractPublisherData {
46+
ContractPublisher internal byoc;
4747
TWRegistry internal twRegistry;
4848

4949
address internal publisher;
@@ -55,7 +55,7 @@ contract ByocRegistryTest is BaseTest, IByocRegistryData {
5555
function setUp() public override {
5656
super.setUp();
5757

58-
byoc = ByocRegistry(byocRegistry);
58+
byoc = ContractPublisher(contractPublisher);
5959
twRegistry = TWRegistry(registry);
6060

6161
publisher = getActor(0);
@@ -74,7 +74,10 @@ contract ByocRegistryTest is BaseTest, IByocRegistryData {
7474
contractId
7575
);
7676

77-
IByocRegistry.CustomContractInstance memory customContract = byoc.getPublishedContract(publisher, contractId);
77+
IContractPublisher.CustomContractInstance memory customContract = byoc.getPublishedContract(
78+
publisher,
79+
contractId
80+
);
7881

7982
assertEq(customContract.contractId, contractId);
8083
assertEq(customContract.publishMetadataUri, publishMetadataUri);
@@ -97,7 +100,10 @@ contract ByocRegistryTest is BaseTest, IByocRegistryData {
97100
contractId
98101
);
99102

100-
IByocRegistry.CustomContractInstance memory customContract = byoc.getPublishedContract(publisher, contractId);
103+
IContractPublisher.CustomContractInstance memory customContract = byoc.getPublishedContract(
104+
publisher,
105+
contractId
106+
);
101107

102108
assertEq(customContract.contractId, contractId);
103109
assertEq(customContract.publishMetadataUri, publishMetadataUri);
@@ -144,13 +150,14 @@ contract ByocRegistryTest is BaseTest, IByocRegistryData {
144150
vm.prank(publisher);
145151
byoc.approveOperator(operator, true);
146152

147-
IByocRegistry.CustomContractInstance memory expectedCustomContract = IByocRegistry.CustomContractInstance({
148-
contractId: contractId,
149-
publishTimestamp: 100,
150-
publishMetadataUri: publishMetadataUri,
151-
bytecodeHash: keccak256(type(MockCustomContract).creationCode),
152-
implementation: address(0)
153-
});
153+
IContractPublisher.CustomContractInstance memory expectedCustomContract = IContractPublisher
154+
.CustomContractInstance({
155+
contractId: contractId,
156+
publishTimestamp: 100,
157+
publishMetadataUri: publishMetadataUri,
158+
bytecodeHash: keccak256(type(MockCustomContract).creationCode),
159+
implementation: address(0)
160+
});
154161

155162
vm.expectEmit(true, true, true, true);
156163
emit ContractPublished(operator, publisher, expectedCustomContract);
@@ -181,7 +188,10 @@ contract ByocRegistryTest is BaseTest, IByocRegistryData {
181188
vm.prank(publisher);
182189
byoc.unpublishContract(publisher, contractId);
183190

184-
IByocRegistry.CustomContractInstance memory customContract = byoc.getPublishedContract(publisher, contractId);
191+
IContractPublisher.CustomContractInstance memory customContract = byoc.getPublishedContract(
192+
publisher,
193+
contractId
194+
);
185195

186196
assertEq(customContract.contractId, "");
187197
assertEq(customContract.publishMetadataUri, "");
@@ -207,7 +217,10 @@ contract ByocRegistryTest is BaseTest, IByocRegistryData {
207217
vm.prank(operator);
208218
byoc.unpublishContract(publisher, contractId);
209219

210-
IByocRegistry.CustomContractInstance memory customContract = byoc.getPublishedContract(publisher, contractId);
220+
IContractPublisher.CustomContractInstance memory customContract = byoc.getPublishedContract(
221+
publisher,
222+
contractId
223+
);
211224

212225
assertEq(customContract.contractId, "");
213226
assertEq(customContract.publishMetadataUri, "");

src/test/utils/BaseTest.sol

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import "contracts/token/TokenERC721.sol";
2424
import "contracts/token/TokenERC1155.sol";
2525
import "contracts/marketplace/Marketplace.sol";
2626
import "contracts/vote/VoteERC20.sol";
27-
import { ByocRegistry } from "contracts/ByocRegistry.sol";
28-
import { ByocFactory } from "contracts/ByocFactory.sol";
27+
import { ContractPublisher } from "contracts/ContractPublisher.sol";
28+
import { ContractDeployer } from "contracts/ContractDeployer.sol";
2929
import "contracts/mock/Mock.sol";
3030

3131
abstract contract BaseTest is DSTest, Test {
@@ -43,7 +43,7 @@ abstract contract BaseTest is DSTest, Test {
4343
address public registry;
4444
address public factory;
4545
address public fee;
46-
address public byocRegistry;
46+
address public contractPublisher;
4747

4848
address public factoryAdmin = address(0x10000);
4949
address public deployer = address(0x20000);
@@ -66,9 +66,9 @@ abstract contract BaseTest is DSTest, Test {
6666
forwarder = address(new Forwarder());
6767
registry = address(new TWRegistry(forwarder));
6868
factory = address(new TWFactory(forwarder, registry));
69-
byocRegistry = address(new ByocRegistry(forwarder));
69+
contractPublisher = address(new ContractPublisher(forwarder));
7070
TWRegistry(registry).grantRole(TWRegistry(registry).OPERATOR_ROLE(), factory);
71-
TWRegistry(registry).grantRole(TWRegistry(registry).OPERATOR_ROLE(), byocRegistry);
71+
TWRegistry(registry).grantRole(TWRegistry(registry).OPERATOR_ROLE(), contractPublisher);
7272
fee = address(new TWFee(forwarder, factory));
7373
TWFactory(factory).addImplementation(address(new TokenERC20(fee)));
7474
TWFactory(factory).addImplementation(address(new TokenERC721(fee)));

0 commit comments

Comments
 (0)