Skip to content

Commit

Permalink
removes nft logic from AtomicBountyV1.test.js
Browse files Browse the repository at this point in the history
  • Loading branch information
FlacoJones committed Feb 25, 2023
1 parent b6767a8 commit 54a4500
Showing 1 changed file with 0 additions and 114 deletions.
114 changes: 0 additions & 114 deletions test/Bounty/AtomicBounty.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ describe('AtomicBountyV1.sol', () => {
// MOCK ASSETS
let mockLink;
let mockDai;
let mockNft;

// UTILS
let abiCoder = new ethers.utils.AbiCoder;
Expand All @@ -43,7 +42,6 @@ describe('AtomicBountyV1.sol', () => {
AtomicBountyV1 = await ethers.getContractFactory('AtomicBountyV1');
const MockLink = await ethers.getContractFactory('MockLink');
const MockDai = await ethers.getContractFactory('MockDai');
const MockNft = await ethers.getContractFactory('MockNft');

[owner, claimManager, depositManager] = await ethers.getSigners();

Expand All @@ -54,16 +52,6 @@ describe('AtomicBountyV1.sol', () => {
mockDai = await MockDai.deploy();
await mockDai.deployed();

mockNft = await MockNft.deploy();
await mockNft.deployed();

await mockNft.safeMint(owner.address);
await mockNft.safeMint(owner.address);
await mockNft.safeMint(owner.address);
await mockNft.safeMint(owner.address);
await mockNft.safeMint(owner.address);
await mockNft.safeMint(owner.address);

// ATOMIC CONTRACT W/ FUNDING GOAL
atomicContract = await AtomicBountyV1.deploy();
await atomicContract.deployed();
Expand All @@ -72,13 +60,6 @@ describe('AtomicBountyV1.sol', () => {
initializationTimestamp = await setNextBlockTimestamp();
await atomicContract.initialize(Constants.bountyId, owner.address, Constants.organization, owner.address, claimManager.address, depositManager.address, atomicBountyInitOperation);

await mockNft.approve(atomicContract.address, 0);
await mockNft.approve(atomicContract.address, 1);
await mockNft.approve(atomicContract.address, 2);
await mockNft.approve(atomicContract.address, 3);
await mockNft.approve(atomicContract.address, 4);
await mockNft.approve(atomicContract.address, 5);

// Pre-approve LINK and DAI for transfers during testing
await mockLink.approve(atomicContract.address, 10000000);
await mockDai.approve(atomicContract.address, 10000000);
Expand Down Expand Up @@ -134,67 +115,6 @@ describe('AtomicBountyV1.sol', () => {
});
});

describe('receiveNFT', () => {

describe('REVERTS', () => {
it('should revert if too many NFT deposits', async () => {
// ASSUME
expect(await mockNft.ownerOf(0)).to.equal(owner.address);
expect(await mockNft.ownerOf(1)).to.equal(owner.address);
expect(await mockNft.ownerOf(2)).to.equal(owner.address);
expect(await mockNft.ownerOf(3)).to.equal(owner.address);
expect(await mockNft.ownerOf(4)).to.equal(owner.address);

// ACT
await atomicContract.connect(depositManager).receiveNft(owner.address, mockNft.address, 0, 1, []);
await atomicContract.connect(depositManager).receiveNft(owner.address, mockNft.address, 1, 1, []);
await atomicContract.connect(depositManager).receiveNft(owner.address, mockNft.address, 2, 1, []);
await atomicContract.connect(depositManager).receiveNft(owner.address, mockNft.address, 3, 1, []);
await atomicContract.connect(depositManager).receiveNft(owner.address, mockNft.address, 4, 1, []);

// ASSERT
await expect(atomicContract.connect(depositManager).receiveNft(owner.address, mockNft.address, 5, 1, [])).to.be.revertedWith('NFT_DEPOSIT_LIMIT_REACHED');
});

it('should revert if expiration is negative', async () => {
await expect(atomicContract.connect(depositManager).receiveNft(owner.address, mockNft.address, 0, 0, [])).to.be.revertedWith('EXPIRATION_NOT_GREATER_THAN_ZERO');
});
});

describe('DEPOSIT INITIALIZATION', () => {
it(`should initialize nft deposit data with correct metadata`, async () => {

// ACT
const expectedTimestamp = await setNextBlockTimestamp();
const depositId = generateDepositId(Constants.bountyId, 0);
await atomicContract.connect(depositManager).receiveNft(owner.address, mockNft.address, 1, Constants.thirtyDays, []);

// ASSERT
expect(await atomicContract.funder(depositId)).to.equal(owner.address);
expect(await atomicContract.tokenAddress(depositId)).to.equal(mockNft.address);
expect(await atomicContract.tokenId(depositId)).to.equal(1);
expect(await atomicContract.expiration(depositId)).to.equal(Constants.thirtyDays);
expect(await atomicContract.isNFT(depositId)).to.equal(true);

const depositTime = await atomicContract.depositTime(depositId);
expect(depositTime.toString()).to.equal(expectedTimestamp.toString());
});
});

describe('transfer', () => {
it('should transfer NFT from owner to bounty contract', async () => {
// ASSUME
expect(await mockNft.ownerOf(0)).to.equal(owner.address);

// ACT
await atomicContract.connect(depositManager).receiveNft(owner.address, mockNft.address, 0, 1, []);

// ASSERT
expect(await mockNft.ownerOf(0)).to.equal(atomicContract.address);
});
});
});

describe('claimBalance', () => {
it('should transfer protocol token from contract to payout address and set token balance to zero', async () => {
// ARRANGE
Expand Down Expand Up @@ -271,40 +191,6 @@ describe('AtomicBountyV1.sol', () => {
});
});

describe('claimNft', () => {
describe('require and revert', () => {
it('should revert if not called by Claim Manager contract', async () => {
// ARRANGE
const [, , , , , notClaimManager] = await ethers.getSigners();
const value = 10000;
let issueWithNonOwnerAccount = atomicContract.connect(notClaimManager);

// ASSERT
await expect(issueWithNonOwnerAccount.claimNft(notClaimManager.address, ethers.utils.formatBytes32String('mockDepositId'))).to.be.revertedWith('ClaimManagerOwnable: caller is not the current OpenQ Claim Manager');
});
});

describe('transfer', () => {
it('should transfer NFT deposit from bounty contract to claimer', async () => {
// ASSUME
expect(await mockNft.ownerOf(1)).to.equal(owner.address);

// ARRANGE
const depositId = generateDepositId(Constants.bountyId, 0);
await atomicContract.connect(depositManager).receiveNft(owner.address, mockNft.address, 1, 1, []);

// ASSUME
expect(await mockNft.ownerOf(1)).to.equal(atomicContract.address);

// ACT
await atomicContract.connect(claimManager).claimNft(owner.address, depositId);

// ASSERT
expect(await mockNft.ownerOf(1)).to.equal(owner.address);
});
});
});

describe('close', () => {
it('should revert if not called by ClaimManager contract', async () => {
// ARRANGE
Expand Down

0 comments on commit 54a4500

Please sign in to comment.