Skip to content

Commit

Permalink
refactor a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Vanderwaal committed Jan 27, 2024
1 parent 42855d5 commit 235a930
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 26 deletions.
12 changes: 5 additions & 7 deletions tests/mmm-creator-royalty.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ describe('mmm-creator-royalty', () => {
connection.getBalance(poolData.nftCreator.publicKey),
]);

const tokenAccountRent = await getTokenAccountRent(connection);
let tokenAccountRent = await getTokenAccountRent(connection);
if (tokenProgramId === TOKEN_2022_PROGRAM_ID) {
tokenAccountRent += IMMUTABLE_OWNER_EXTENSION_LAMPORTS;
}

const sellStatePDARent = await getSellStatePDARent(connection);

const expectedTxFees = SIGNATURE_FEE_LAMPORTS * 2; // cosigner + payer
Expand Down Expand Up @@ -314,11 +318,6 @@ describe('mmm-creator-royalty', () => {
connection.getBalance(poolData.nftCreator.publicKey),
]);

let extension_rent = 0;
if (tokenProgramId === TOKEN_2022_PROGRAM_ID) {
extension_rent = IMMUTABLE_OWNER_EXTENSION_LAMPORTS;
}

assert.equal(
buyerBalance,
initBuyerBalance -
Expand All @@ -327,7 +326,6 @@ describe('mmm-creator-royalty', () => {
expectedTakerFees -
expectedTxFees -
tokenAccountRent -
extension_rent - // Metaplex NFT ATAs have the immutable extension
expectedCreatorFees, // no token account rent bc seller ata was closed and pool ata opened
);
assert.equal(
Expand Down
20 changes: 6 additions & 14 deletions tests/mmm-fulfill-exp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,10 @@ describe('mmm-fulfill-exp', () => {
assertTx(txId, confirmedTx);
}

let extension_rent = 0;
let tokenAccountRent = await getTokenAccountRent(connection);
if (tokenProgramId === TOKEN_2022_PROGRAM_ID) {
extension_rent = IMMUTABLE_OWNER_EXTENSION_LAMPORTS;
tokenAccountRent += IMMUTABLE_OWNER_EXTENSION_LAMPORTS;
}

const tokenAccountRent =
(await getTokenAccountRent(connection)) + extension_rent;
const sellStatePDARent = await getSellStatePDARent(connection);

const expectedTxFees =
Expand Down Expand Up @@ -729,13 +726,10 @@ describe('mmm-fulfill-exp', () => {
assert.equal(await connection.getBalance(sellState), 0);
}

let extension_rent = 0;
let tokenAccountRent = await getTokenAccountRent(connection);
if (tokenProgramId === TOKEN_2022_PROGRAM_ID) {
extension_rent = IMMUTABLE_OWNER_EXTENSION_LAMPORTS;
tokenAccountRent += IMMUTABLE_OWNER_EXTENSION_LAMPORTS;
}

const tokenAccountRent =
(await getTokenAccountRent(connection)) + extension_rent;
const sellStatePDARent = await getSellStatePDARent(connection);
{
const expectedTakerFees = expectedTotalPrice * LAMPORTS_PER_SOL * 0.04;
Expand Down Expand Up @@ -1075,13 +1069,11 @@ describe('mmm-fulfill-exp', () => {
await sendAndAssertTx(connection, tx, blockhashData, false);
}

let extension_rent = 0;
let tokenAccountRent = await getTokenAccountRent(connection);
if (tokenProgramId === TOKEN_2022_PROGRAM_ID) {
extension_rent = IMMUTABLE_OWNER_EXTENSION_LAMPORTS;
tokenAccountRent += IMMUTABLE_OWNER_EXTENSION_LAMPORTS;
}

const tokenAccountRent =
(await getTokenAccountRent(connection)) + extension_rent;
const sellStatePDARent = await getSellStatePDARent(connection);

const expectedTxFees = SIGNATURE_FEE_LAMPORTS * 2; // cosigner + payer
Expand Down
7 changes: 2 additions & 5 deletions tests/mmm-fulfill-linear.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,10 @@ describe('mmm-fulfill-linear', () => {
assertTx(txId, confirmedTx);
}

let extension_rent = 0;
let tokenAccountRent = await getTokenAccountRent(connection);
if (tokenProgramId === TOKEN_2022_PROGRAM_ID) {
extension_rent = IMMUTABLE_OWNER_EXTENSION_LAMPORTS;
tokenAccountRent += IMMUTABLE_OWNER_EXTENSION_LAMPORTS;
}

const tokenAccountRent =
(await getTokenAccountRent(connection)) + extension_rent;
const sellStatePDARent = await getSellStatePDARent(connection);

const expectedTxFees =
Expand Down

0 comments on commit 235a930

Please sign in to comment.