Skip to content

Commit

Permalink
deposit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ShivaanshK committed Jun 28, 2024
1 parent 46d8c89 commit 87c8c69
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
27 changes: 22 additions & 5 deletions test/foundry/SponsorshipPaymasterWithPremium.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ contract SponsorshipPaymasterWithPremiumTest is NexusTestBase {
setupTestEnvironment();
// Deploy Sponsorship Paymaster
bicoPaymaster = new BiconomySponsorshipPaymaster(ALICE_ADDRESS, ENTRYPOINT, BOB_ADDRESS, CHARLIE_ADDRESS);

// Deposit funds for paymaster id
vm.startPrank(CHARLIE_ADDRESS);
ENTRYPOINT.depositTo{ value: 10 ether }(address(bicoPaymaster));
vm.stopPrank();
}

function testDeploy() external {
Expand Down Expand Up @@ -102,4 +97,26 @@ contract SponsorshipPaymasterWithPremiumTest is NexusTestBase {
bicoPaymaster.setFeeCollector(DAN_ADDRESS);
vm.stopPrank();
}

function testDepositFor() external {
uint256 dappBalance = bicoPaymaster.getBalance(DAPP_PAYMASTER.addr);
uint256 depositAmount = 10 ether;
assertEq(dappBalance, 0 ether);
bicoPaymaster.depositFor{ value: depositAmount }(DAPP_PAYMASTER.addr);
dappBalance = bicoPaymaster.getBalance(DAPP_PAYMASTER.addr);
assertEq(dappBalance, depositAmount);
}

function testInvalidDepositFor() external {
vm.expectRevert(abi.encodeWithSignature("PaymasterIdCannotBeZero()"));
bicoPaymaster.depositFor{ value: 1 ether }(address(0));

vm.expectRevert(abi.encodeWithSignature("DepositCanNotBeZero()"));
bicoPaymaster.depositFor{ value: 0 ether }(DAPP_PAYMASTER.addr);
}

function testInvalidDeposit() external {
vm.expectRevert("Use depositFor() instead");
bicoPaymaster.deposit{ value: 1 ether }();
}
}
2 changes: 2 additions & 0 deletions test/foundry/base/NexusTestBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ abstract contract NexusTestBase is CheatCodes, EventsAndErrors {
Vm.Wallet internal DAN;
Vm.Wallet internal EMMA;
Vm.Wallet internal BUNDLER;
Vm.Wallet internal DAPP_PAYMASTER;
Vm.Wallet internal FACTORY_OWNER;

address internal BOB_ADDRESS;
Expand Down Expand Up @@ -107,6 +108,7 @@ abstract contract NexusTestBase is CheatCodes, EventsAndErrors {
DAN_ADDRESS = DAN.addr;
EMMA_ADDRESS = EMMA.addr;

DAPP_PAYMASTER = createAndFundWallet("DAPP_PAYMASTER", 1000 ether);
FACTORY_OWNER = createAndFundWallet("FACTORY_OWNER", 1000 ether);
}

Expand Down

0 comments on commit 87c8c69

Please sign in to comment.