Skip to content

Commit

Permalink
🔥 remove console logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Aboudjem committed Nov 8, 2023
1 parent 2e355ea commit 7f45aa1
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 212 deletions.
2 changes: 1 addition & 1 deletion contracts/test/helpers/MockChainlinkAggregator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ contract MockChainlinkOracleAggregator is Ownable, IOracleAggregator {
(bool success, bytes memory ret) = tokensInfo[token]
.callAddress
.staticcall(tokensInfo[token].callData);
console.log("price feed reverted here? success = %s ", success);
require(success, "ChainlinkOracleAggregator:: query failed");
if (tokensInfo[token].dataSigned) {
tokenPriceUnadjusted = uint256(abi.decode(ret, (int256)));
Expand Down
1 change: 0 additions & 1 deletion test/bundler-integration/environment/deployEntrypoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ if (require.main === module) {
await BundlerTestEnvironment.getDefaultInstance();
const [deployer] = await ethers.getSigners();
const entrypoint = await new EntryPoint__factory(deployer).deploy();
console.log("Entrypoint deployed at", entrypoint.address);
await promises.writeFile(envPath, `ENTRYPOINT=${entrypoint.address}`);
})();
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,14 @@ describe("EntryPoint with VerifyingPaymaster Singleton", function () {
);

walletAddress = expected;
console.log(" wallet address ", walletAddress);

paymasterAddress = verifyingSingletonPaymaster.address;
console.log("Paymaster address is ", paymasterAddress);

await verifyingSingletonPaymaster
.connect(deployer)
.addStake(86400, { value: parseEther("2") });
console.log("paymaster staked");

await entryPoint.depositTo(paymasterAddress, { value: parseEther("1") });

// const resultSet = await entryPoint.getDepositInfo(paymasterAddress);
// console.log("deposited state ", resultSet);
});

async function getUserOpWithPaymasterInfo(paymasterId: string) {
Expand Down Expand Up @@ -170,7 +164,6 @@ describe("EntryPoint with VerifyingPaymaster Singleton", function () {
describe("#validatePaymasterUserOp", () => {
it("Should Fail when there is no deposit for paymaster id", async () => {
const paymasterId = await depositorSigner.getAddress();
console.log("paymaster Id ", paymasterId);
const userOp = await getUserOpWithPaymasterInfo(paymasterId);

const signatureWithModuleAddress = ethers.utils.defaultAbiCoder.encode(
Expand All @@ -180,7 +173,6 @@ describe("EntryPoint with VerifyingPaymaster Singleton", function () {

userOp.signature = signatureWithModuleAddress;

console.log("entrypoint ", entryPoint.address);
await expect(
entryPoint.callStatic.simulateValidation(userOp)
// ).to.be.revertedWith("FailedOp");
Expand Down
78 changes: 2 additions & 76 deletions test/token-paymaster/biconomy-token-paymaster-specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,8 @@ const MOCK_VALID_AFTER = "0x0000000000001234";
const MOCK_SIG = "0x1234";
const MOCK_ERC20_ADDR = "0x" + "01".repeat(20);
const DEFAULT_FEE_MARKUP = 1100000;
// Assume TOKEN decimals is 18, then 1 ETH = 1000 TOKENS
// const MOCK_FX = ethers.constants.WeiPerEther.mul(1000);

const MOCK_FX: BigNumberish = "977100"; // matic to usdc approx
console.log("MOCK FX ", MOCK_FX); // 1000000000000000000000

export async function deployEntryPoint(
provider = ethers.provider
Expand Down Expand Up @@ -146,7 +143,7 @@ describe("Biconomy Token Paymaster", function () {
const MockToken = await ethers.getContractFactory("MockToken");
token = await MockToken.deploy();
await token.deployed();
console.log("Test token deployed at: ", token.address);


const usdcMaticPriceFeedMock = await new MockPriceFeed__factory(
deployer
Expand All @@ -171,8 +168,6 @@ describe("Biconomy Token Paymaster", function () {
const priceResult = await oracleAggregator.getTokenValueOfOneNativeToken(
token.address
);
console.log("priceResult");
console.log(priceResult);

sampleTokenPaymaster = await new BiconomyTokenPaymaster__factory(
deployer
Expand Down Expand Up @@ -214,24 +209,18 @@ describe("Biconomy Token Paymaster", function () {
smartAccountDeploymentIndex
);

console.log("mint tokens to owner address..");
await token.mint(walletOwnerAddress, ethers.utils.parseEther("1000000"));

walletAddress = expected;
console.log(" wallet address ", walletAddress);

paymasterAddress = sampleTokenPaymaster.address;
console.log("Paymaster address is ", paymasterAddress);


await sampleTokenPaymaster
.connect(deployer)
.addStake(1, { value: parseEther("2") });
console.log("paymaster staked");

await entryPoint.depositTo(paymasterAddress, { value: parseEther("2") });

// const resultSet = await entryPoint.getDepositInfo(paymasterAddress);
// console.log("deposited state ", resultSet);
});

describe("Token Payamster read methods and state checks", () => {
Expand Down Expand Up @@ -269,13 +258,6 @@ describe("Biconomy Token Paymaster", function () {

const feeReceiver = await sampleTokenPaymaster.feeReceiver();

console.log(
"current values from contracts",
owner,
verifyingSigner,
feeReceiver
);

expect(owner).to.be.equal(await walletOwner.getAddress());
expect(verifyingSigner).to.be.equal(await offchainSigner.getAddress());
expect(feeReceiver).to.be.equal(paymasterAddress);
Expand Down Expand Up @@ -375,57 +357,22 @@ describe("Biconomy Token Paymaster", function () {
.add(userOp.preVerificationGas)
.mul(userOp.maxFeePerGas);

console.log("required prefund ", requiredPrefund.toString());

const initBalance = await token.balanceOf(paymasterAddress);
console.log("fee receiver token balance before ", initBalance.toString());

const preTokenBalanceForAccount = await token.balanceOf(walletAddress);
console.log(
"smart account erc20 balance before",
preTokenBalanceForAccount.toString()
);

const tx = await entryPoint.handleOps(
[userOp],
await offchainSigner.getAddress()
);
const receipt = await tx.wait();
console.log(
"fees paid in native ",
receipt.effectiveGasPrice.mul(receipt.gasUsed).toString()
);

console.log("gas used ");
console.log(receipt.gasUsed.toNumber());

const postBalance = await token.balanceOf(paymasterAddress);
console.log("fee receiver token balance after ", postBalance.toString());

const postTokenBalanceForAccount = await token.balanceOf(walletAddress);
console.log(
"smart account erc20 balance after",
postTokenBalanceForAccount.toString()
);

console.log(
"required prefund in token terms ",
requiredPrefund
.mul(MOCK_FX)
.div(ethers.constants.WeiPerEther)
.toString()
);

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

/* expect(postBalance.sub(initBalance)).to.be.greaterThan(
ethers.constants.Zero
);
expect(postBalance.sub(initBalance)).to.be.lessThanOrEqual(
requiredPrefund.mul(MOCK_FX).div(ethers.constants.WeiPerEther)
); */

await expect(
entryPoint.handleOps([userOp], await offchainSigner.getAddress())
).to.be.reverted;
Expand Down Expand Up @@ -845,14 +792,6 @@ describe("Biconomy Token Paymaster", function () {

let owner = await sampleTokenPaymaster.owner();

console.log(
"current values from contracts",
verifyingSigner,
feeReceiver,
unaccountedCost,
owner
);

await sampleTokenPaymaster
.connect(ethersSigner[0])
.setFeeReceiver(newFeeReceiver);
Expand Down Expand Up @@ -892,26 +831,16 @@ describe("Biconomy Token Paymaster", function () {
const etherBalanceBefore = await ethers.provider.getBalance(
withdrawAddress
);
console.log("balance before ", etherBalanceBefore.toString());

const tokenBalanceBefore = await token.balanceOf(withdrawAddress);
console.log("token balance before ", tokenBalanceBefore.toString());

const currentGasDeposited = await sampleTokenPaymaster.deposit();
console.log(
"current gas in Entry Point ",
currentGasDeposited.toString()
);

await sampleTokenPaymaster
.connect(ethersSigner[6])
.withdrawTo(withdrawAddress, ethers.utils.parseEther("0.2"));

const gasasDepositedAfter = await sampleTokenPaymaster.deposit();
console.log(
"current gas in Entry Point ",
gasasDepositedAfter.toString()
);

await expect(
sampleTokenPaymaster
Expand All @@ -922,14 +851,12 @@ describe("Biconomy Token Paymaster", function () {
const etherBalanceAfter = await ethers.provider.getBalance(
withdrawAddress
);
console.log("balance after ", etherBalanceBefore.toString());

expect(
etherBalanceBefore.add(ethers.utils.parseEther("0.2"))
).to.be.equal(etherBalanceAfter);

const collectedTokens = await token.balanceOf(paymasterAddress);
console.log("collected tokens ", collectedTokens);

await expect(
sampleTokenPaymaster
Expand All @@ -942,7 +869,6 @@ describe("Biconomy Token Paymaster", function () {
.withdrawERC20(token.address, withdrawAddress, collectedTokens);

const tokenBalanceAfter = await token.balanceOf(withdrawAddress);
console.log("token balance after ", tokenBalanceAfter.toString());

expect(tokenBalanceBefore.add(collectedTokens)).to.be.equal(
tokenBalanceAfter
Expand Down
27 changes: 0 additions & 27 deletions test/token-paymaster/btpm-coverage-specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,8 @@ export const AddressZero = ethers.constants.AddressZero;

const MOCK_VALID_UNTIL = "0x00000000deadbeef";
const MOCK_VALID_AFTER = "0x0000000000001234";
// Assume TOKEN decimals is 18, then 1 ETH = 1000 TOKENS
// const MOCK_FX = ethers.constants.WeiPerEther.mul(1000);

const MOCK_FX: BigNumberish = "977100"; // matic to usdc approx
console.log("MOCK FX ", MOCK_FX); // 1000000000000000000000

export async function deployEntryPoint(
provider = ethers.provider
Expand Down Expand Up @@ -149,7 +146,6 @@ describe("Biconomy Token Paymaster", function () {
const MockToken = await ethers.getContractFactory("MockToken");
token = await MockToken.deploy();
await token.deployed();
console.log("Test token deployed at: ", token.address);

const usdcMaticPriceFeedMock = await new MockPriceFeed__factory(
deployer
Expand All @@ -174,8 +170,6 @@ describe("Biconomy Token Paymaster", function () {
const priceResult = await oracleAggregator.getTokenValueOfOneNativeToken(
token.address
);
console.log("priceResult");
console.log(priceResult);

sampleTokenPaymaster = await new BiconomyTokenPaymaster__factory(
deployer
Expand Down Expand Up @@ -217,39 +211,31 @@ describe("Biconomy Token Paymaster", function () {
smartAccountDeploymentIndex
);

console.log("mint tokens to owner address..");
await token.mint(walletOwnerAddress, ethers.utils.parseEther("1000000"));

walletAddress = expected;
console.log(" wallet address ", walletAddress);

paymasterAddress = sampleTokenPaymaster.address;
console.log("Paymaster address is ", paymasterAddress);

await sampleTokenPaymaster
.connect(deployer)
.addStake(1, { value: parseEther("2") });
console.log("paymaster staked");

await entryPoint.depositTo(paymasterAddress, { value: parseEther("2") });

const resultSet = await entryPoint.getDepositInfo(paymasterAddress);
console.log("deposited state ", resultSet);
});

describe("Token Payamster Staking + Gas deposits / withdraw", () => {
it("Owner should be able to add and withdraw stake", async () => {
await sampleTokenPaymaster
.connect(deployer)
.addStake(1, { value: parseEther("2") });

console.log("paymaster staked");
});
});

describe("Pull: ether / tokens recovery", () => {
it("only owner should be able to pull tokens, withdraw gas", async () => {
// paymaster can receive eth
await deployer.sendTransaction({
to: paymasterAddress,
value: parseEther("1"),
Expand All @@ -262,16 +248,10 @@ describe("Biconomy Token Paymaster", function () {
const etherBalanceBefore = await ethers.provider.getBalance(
withdrawAddress
);
console.log("balance before ", etherBalanceBefore.toString());

const tokenBalanceBefore = await token.balanceOf(withdrawAddress);
console.log("token balance before ", tokenBalanceBefore.toString());

const currentGasDeposited = await sampleTokenPaymaster.deposit();
console.log(
"current gas in Entry Point ",
currentGasDeposited.toString()
);

await sampleTokenPaymaster.transferOwnership(
await ethersSigner[6].getAddress()
Expand All @@ -282,10 +262,6 @@ describe("Biconomy Token Paymaster", function () {
.withdrawTo(withdrawAddress, ethers.utils.parseEther("0.2"));

const gasasDepositedAfter = await sampleTokenPaymaster.deposit();
console.log(
"current gas in Entry Point ",
gasasDepositedAfter.toString()
);

await expect(
sampleTokenPaymaster
Expand All @@ -296,14 +272,12 @@ describe("Biconomy Token Paymaster", function () {
const etherBalanceAfter = await ethers.provider.getBalance(
withdrawAddress
);
console.log("balance after ", etherBalanceBefore.toString());

expect(
etherBalanceBefore.add(ethers.utils.parseEther("0.2"))
).to.be.equal(etherBalanceAfter);

const collectedTokens = await token.balanceOf(paymasterAddress);
console.log("collected tokens ", collectedTokens);

await expect(
sampleTokenPaymaster
Expand All @@ -329,7 +303,6 @@ describe("Biconomy Token Paymaster", function () {
.withdrawERC20(token.address, withdrawAddress, collectedTokens);

const tokenBalanceAfter = await token.balanceOf(withdrawAddress);
console.log("token balance after ", tokenBalanceAfter.toString());

expect(tokenBalanceBefore.add(collectedTokens)).to.be.equal(
tokenBalanceAfter
Expand Down
Loading

0 comments on commit 7f45aa1

Please sign in to comment.