Skip to content

Commit

Permalink
reverting second post op tests
Browse files Browse the repository at this point in the history
  • Loading branch information
livingrockrises committed Dec 8, 2023
1 parent e5a9491 commit 82e0e5b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 23 deletions.
17 changes: 6 additions & 11 deletions contracts/token/BiconomyTokenPaymaster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -582,20 +582,15 @@ contract BiconomyTokenPaymaster is
);
// emit UserOperationSponsored(account, address(feeToken), charge, actualGasCost);
} else {
// In case transferFrom failed in first handlePostOp call, attempt to charge the tokens again
bytes memory _data = abi.encodeWithSelector(
feeToken.transferFrom.selector,
/*SafeTransferLib.safeTransferFrom(
address(feeToken),
account,
feeReceiver,
charge
);
(bool success, ) = address(feeToken).call(_data);
if (!success) {
// In case above transferFrom failed, pay with deposit / notify at least
// Sender could be banned indefinitely or for certain period
emit TokenPaymentDue(address(feeToken), account, charge);
// Do nothing else here to not revert the whole bundle and harm reputation
}
);*/
// or just revert
require(0 == 1, "PostOpRevertedBLAHBLAHBLAHBLAHBLAHBLAHBLAHBLAHBLAH");
// revert PostOpRevertedBLAHBLAHBLAHBLAHBLAHBLAHBLAHBLAHBLAH();
}
// console.log("gas used for postop: %s", gas - gasleft());
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/TokenPaymasterErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ contract TokenPaymasterErrors {

error CannotBeUnrealisticValue();

error DEXRouterCannotBeZero();
error PostOpRevertedBLAHBLAHBLAHBLAHBLAHBLAHBLAHBLAHBLAH();
}
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ describe("Biconomy Token Paymaster (with Bundler)", function () {
userSCW,
token,
paymasterAddress,
ethers.constants.MaxUint256
ethers.constants.Zero
),
preVerificationGas: 55000,
},
Expand Down Expand Up @@ -277,14 +277,23 @@ describe("Biconomy Token Paymaster (with Bundler)", function () {

userOp.signature = signatureWithModuleAddress;

await environment.sendUserOperation(userOp, entryPoint.address);
const bundlerResponse = await environment.sendUserOperation(
userOp,
entryPoint.address
);
console.log(bundlerResponse);

const receipt = await environment.getUserOperationReceipt(
bundlerResponse.result
);
console.log(receipt);

const ev = await getUserOpEvent(entryPoint);
expect(ev.args.success).to.be.true;
// const ev = await getUserOpEvent(entryPoint);
// expect(ev.args.success).to.be.true;

await expect(
/* await expect(
entryPoint.handleOps([userOp], await offchainSigner.getAddress())
).to.be.reverted;
).to.be.reverted; */
});
});
});
20 changes: 15 additions & 5 deletions test/token-paymaster/biconomy-token-paymaster-specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ describe("Biconomy Token Paymaster", function () {
userSCW,
token,
paymasterAddress,
ethers.constants.MaxUint256
ethers.constants.Zero
),
},
walletOwner,
Expand Down Expand Up @@ -328,7 +328,17 @@ describe("Biconomy Token Paymaster", function () {
.mul(userOp.maxFeePerGas);

const preTokenBalanceForAccount = await token.balanceOf(walletAddress);
const tx = await entryPoint.handleOps(
await expect(
entryPoint.handleOps([userOp], await offchainSigner.getAddress())
// ).to.be.revertedWithCustomError(sampleTokenPaymaster, "PostOpReverted");
)
.to.be.revertedWithCustomError(entryPoint, "FailedOp")
.withArgs(
0,
"AA50 postOp reverted: PostOpRevertedBLAHBLAHBLAHBLAHBLAHBLAHBLAHBLAHBLAH"
);

/* const tx = await entryPoint.handleOps(
[userOp],
await offchainSigner.getAddress()
);
Expand All @@ -354,11 +364,11 @@ describe("Biconomy Token Paymaster", function () {
await expect(
entryPoint.handleOps([userOp], await offchainSigner.getAddress())
).to.be.reverted;
).to.be.reverted; */
});
});

describe("Negative scenarios: invalid and wrong signatures", () => {
/* describe("Negative scenarios: invalid and wrong signatures", () => {
it("should revert on invalid signature length", async () => {
const userSCW: any = BiconomyAccountImplementation__factory.connect(
walletAddress,
Expand Down Expand Up @@ -835,5 +845,5 @@ describe("Biconomy Token Paymaster", function () {
// Add test cases for pulling ether out of paymaster contract
// Add test cases for batch withdraw tokens
});
});
}); */
});

0 comments on commit 82e0e5b

Please sign in to comment.