Skip to content

Commit

Permalink
add card payment processor deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
mayconamaroCW committed Mar 14, 2024
1 parent 23a9e3f commit e705577
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion e2e-contracts/integration/test/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { ethers, upgrades } from "hardhat";
import { expect } from "chai";
import { ContractFactory } from "ethers";
import { SignerWithAddress } from "@nomicfoundation/hardhat-ethers/signers";
import { BRLCToken, CashbackDistributor, PixCashier } from "../typechain-types";
import { BRLCToken, CardPaymentProcessor, CashbackDistributor, PixCashier } from "../typechain-types";

/* Contracts instances */
let brlCoin: BRLCToken;
let pixCashier: PixCashier;
let cashbackDistributor: CashbackDistributor;
let cardPaymentProcessor: CardPaymentProcessor;

/* Signers and Wallets */
let deployer: SignerWithAddress;
Expand Down Expand Up @@ -48,6 +49,26 @@ async function configureCashbackDistributor() {
cashbackDistributor.enable();
}

async function deployCardPaymentProcessor() {
let cardPaymentProcessorFactory: ContractFactory = await ethers.getContractFactory("CardPaymentProcessor");
let deployedProxy = await upgrades.deployProxy(cardPaymentProcessorFactory.connect(deployer), [await brlCoin.getAddress()]);
await deployedProxy.waitForDeployment();
cardPaymentProcessor = deployedProxy.connect(deployer) as CardPaymentProcessor;
}

async function configureCardPaymentProcessor() {
const rateFactor = 10;
cardPaymentProcessor.grantRole(await cardPaymentProcessor.EXECUTOR_ROLE(), await deployer.getAddress());
cardPaymentProcessor.setCashbackDistributor(await cashbackDistributor.getAddress());
cardPaymentProcessor.setRevocationLimit(255);
cardPaymentProcessor.setCashbackRate(1.5 * rateFactor);
cardPaymentProcessor.setCashOutAccount(await deployer.getAddress());
brlCoin.approve(await cardPaymentProcessor.getAddress(), 0xfffffffffffff);
cashbackDistributor.grantRole(await cashbackDistributor.DISTRIBUTOR_ROLE(), await cardPaymentProcessor.getAddress());
cardPaymentProcessor.setCashbackDistributor(await cashbackDistributor.getAddress());
cardPaymentProcessor.enableCashback();
}

describe("Integration Test", function () {
before(async function () {
[deployer] = await ethers.getSigners();
Expand Down Expand Up @@ -77,6 +98,14 @@ describe("Integration Test", function () {
await configureCashbackDistributor();
});

it("Deploy CardPaymentProcessor", async function () {
await deployCardPaymentProcessor();
});

it("Configure CardPaymentProcessor", async function () {
await configureCardPaymentProcessor();
});

describe("Scenario 1", function () {

let alice = ethers.Wallet.createRandom().connect(ethers.provider);
Expand Down

0 comments on commit e705577

Please sign in to comment.