Skip to content

Commit

Permalink
test: fix failed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
scottphc committed Jan 24, 2025
1 parent a2b4648 commit 4f5157d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
10 changes: 6 additions & 4 deletions test/SpotlightTokenFactoryTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ contract SpotlightTokenFactoryTest is Test {
address(_bondingCurve)
);
_factory.createToken{value: tokenCreator.balance}(
tokenCreationData, initialBuyData, makeDerivative, ipMetadata, sigMetadata, sigRegister, address(0)
tokenCreationData, initialBuyData, makeDerivative, ipMetadata, sigMetadata, sigRegister
);
vm.stopPrank();

Expand All @@ -216,7 +216,9 @@ contract SpotlightTokenFactoryTest is Test {
uint256 SHOULD_REFUND_EXCESS_IP = 1 ether;
uint256 TOKEN_CREATOR_BALANCE = (DEFAULT_CREATION_FEE + INITIAL_BUY_AMOUNT + SHOULD_REFUND_EXCESS_IP);

uint256 expectedFactoryBalance = address(_factory).balance + DEFAULT_CREATION_FEE + INITIAL_BUY_AMOUNT * 1 / 100;
uint256 protocolTradingFee = INITIAL_BUY_AMOUNT / 100;
uint256 ipAccountFee = protocolTradingFee / 10;
uint256 expectedFactoryBalance = address(_factory).balance + DEFAULT_CREATION_FEE + (protocolTradingFee - ipAccountFee);
uint256 expectedTokenCreatorBalance = SHOULD_REFUND_EXCESS_IP;
uint256 expectedPredeployedTokenBalance = INITIAL_BUY_AMOUNT * 99 / 100;

Expand All @@ -235,7 +237,7 @@ contract SpotlightTokenFactoryTest is Test {
) = _getDummyStructs(tokenCreator, 1 ether);

_factory.createToken{value: TOKEN_CREATOR_BALANCE}(
tokenCreationData, initialBuyData, makeDerivative, ipMetadata, sigMetadata, sigRegister, address(0)
tokenCreationData, initialBuyData, makeDerivative, ipMetadata, sigMetadata, sigRegister
);
vm.stopPrank();

Expand Down Expand Up @@ -269,7 +271,7 @@ contract SpotlightTokenFactoryTest is Test {

vm.expectRevert("SpotlightTokenFactory: Insufficient total amount");
_factory.createToken{value: TOKEN_CREATOR_BALANCE}(
tokenCreationData, initialBuyData, makeDerivative, ipMetadata, sigMetadata, sigRegister, address(0)
tokenCreationData, initialBuyData, makeDerivative, ipMetadata, sigMetadata, sigRegister
);
vm.stopPrank();

Expand Down
14 changes: 7 additions & 7 deletions test/SpotlightTokenTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ contract SpotlightTokenTest is Test {
uint256 public constant MAX_TOTAL_SUPPLY = 1_000_000_000e18; // 1 billion
uint256 public constant GRADUATE_MARKET_AMOUNT = 3 ether;
uint256 public constant IP_ACCOUNT_FEE_BPS = 1_000; // 10%
address constant IP_ACCOUNT = 0x359EcA9F3C4cCdB7C10Dd4D9410EaD52Ef9B430A;

SpotlightTokenFactory private _factory;
SpotlightTokenIPCollection private _tokenIpCollection;
Expand Down Expand Up @@ -89,7 +88,7 @@ contract SpotlightTokenTest is Test {
});

(_tokenAddress,) = _factory.createToken{value: DEFAULT_CREATION_FEE}(
tokenCreationData, initialBuyData, makeDerivative, ipMetadata, sigMetadata, sigRegister, address(0)
tokenCreationData, initialBuyData, makeDerivative, ipMetadata, sigMetadata, sigRegister
);
_token = SpotlightToken(payable(_tokenAddress));

Expand All @@ -109,8 +108,7 @@ contract SpotlightTokenTest is Test {
makeDerivative,
ipMetadata,
sigMetadata,
sigRegister,
IP_ACCOUNT
sigRegister
);
_tokenCreatedWithIPAccount = SpotlightToken(payable(tokenCreatedWithIPAccount));
vm.stopPrank();
Expand Down Expand Up @@ -141,7 +139,7 @@ contract SpotlightTokenTest is Test {
_tokenCreator,
address(_bondingCurve),
address(_factory),
address(IP_ACCOUNT),
address(0x359EcA9F3C4cCdB7C10Dd4D9410EaD52Ef9B430A),
address(_rewardsVault),
address(PIPERX_V2_ROUTER),
address(PIPERX_V2_FACTORY)
Expand All @@ -164,9 +162,10 @@ contract SpotlightTokenTest is Test {
uint256 PROTOCOL_TRADING_FEE = _calculateFee(USER_BUY_AMOUNT, TOTAL_FEE_BPS);
uint256 TOKEN_CONTRACT_BALANCE_BEFORE = address(_token).balance;
uint256 FACTORY_BALANCE_BEFORE = address(_factory).balance;
uint256 protocolTradingFeeForFactory = PROTOCOL_TRADING_FEE - _calculateFee(PROTOCOL_TRADING_FEE, IP_ACCOUNT_FEE_BPS);
uint256 expectedTokenReceived = _token.getIPBuyQuoteWithFee(USER_BUY_AMOUNT);
uint256 expectedContractIPBalance = TOKEN_CONTRACT_BALANCE_BEFORE + USER_BUY_AMOUNT - PROTOCOL_TRADING_FEE;
uint256 expectedFactoryBalance = FACTORY_BALANCE_BEFORE + PROTOCOL_TRADING_FEE;
uint256 expectedFactoryBalance = FACTORY_BALANCE_BEFORE + protocolTradingFeeForFactory;

vm.deal(_buyer, USER_BUY_AMOUNT);
vm.startPrank(_buyer);
Expand Down Expand Up @@ -298,9 +297,10 @@ contract SpotlightTokenTest is Test {
uint256 FACTORY_BALANCE_BEFORE = address(_factory).balance;
uint256 ipIn = _token.getTokenBuyQuote(USER_BUY_TOKEN_AMOUNT);
uint256 protocolTradingFee = _calculateFee(ipIn, TOTAL_FEE_BPS);
uint256 protocolTradingFeeForFactory = protocolTradingFee - _calculateFee(protocolTradingFee, IP_ACCOUNT_FEE_BPS);
uint256 ipInWithFee = ipIn + protocolTradingFee;
uint256 expectedContractIPBalance = TOKEN_CONTRACT_BALANCE_BEFORE + ipIn;
uint256 expectedFactoryBalance = FACTORY_BALANCE_BEFORE + protocolTradingFee;
uint256 expectedFactoryBalance = FACTORY_BALANCE_BEFORE + protocolTradingFeeForFactory;

vm.deal(_buyer, ipInWithFee);
vm.startPrank(_buyer);
Expand Down
7 changes: 6 additions & 1 deletion test/mocks/MockStoryDerivativeWorkflows.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import "../../lib/forge-std/src/Test.sol";
contract MockStoryDerivativeWorkflows is IStoryDerivativeWorkflows, Test {
address public mockReturnAddress;
uint256 public callCount;
address public mockParentIPAccount;

StoryWorkflowStructs.MakeDerivative public mockMakeDerivative;
StoryWorkflowStructs.IPMetadata public mockIpMetadata;
Expand All @@ -26,8 +27,12 @@ contract MockStoryDerivativeWorkflows is IStoryDerivativeWorkflows, Test {
);

constructor() {
mockParentIPAccount = address(0x359EcA9F3C4cCdB7C10Dd4D9410EaD52Ef9B430A);
address[] memory parentIPAccounts = new address[](1);
parentIPAccounts[0] = mockParentIPAccount;

mockMakeDerivative = StoryWorkflowStructs.MakeDerivative({
parentIpIds: new address[](0),
parentIpIds: parentIPAccounts,
licenseTemplate: address(0),
licenseTermsIds: new uint256[](0),
royaltyContext: ""
Expand Down

0 comments on commit 4f5157d

Please sign in to comment.