Skip to content

Commit

Permalink
Unify file
Browse files Browse the repository at this point in the history
  • Loading branch information
jdcaballerov committed Aug 11, 2022
1 parent 8841214 commit 58347aa
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 52 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
import { Connection, Keypair, PublicKey, Transaction, LAMPORTS_PER_SOL } from '@solana/web3.js';
import {
AccountInfo,
Connection,
Keypair,
PublicKey,
Transaction,
LAMPORTS_PER_SOL,
} from '@solana/web3.js';
import { AuctionHouse, AuctionHouseArgs } from 'src/generated';
import test from 'tape';
import spok from 'spok';

import {
CreateAuctionHouseInstructionAccounts,
Expand All @@ -11,7 +21,6 @@ import {
WithdrawInstructionArgs,
createWithdrawInstruction,
} from 'src/generated';
import test from 'tape';
import { Amman } from '@metaplex-foundation/amman-client';
import { LOCALHOST } from '@metaplex-foundation/amman';

Expand Down Expand Up @@ -65,6 +74,52 @@ const getAuctionHouseBuyerEscrow = async (
);
};

function quickKeypair(): [PublicKey, Uint8Array] {
const kp = Keypair.generate();
return [kp.publicKey, kp.secretKey];
}

test('account auction-house: round trip serialization', async (t) => {
const [creator] = quickKeypair();
const [auctionHouseTreasury] = quickKeypair();
const [treasuryWithdrawalDestination] = quickKeypair();
const [feeWithdrawalDestination] = quickKeypair();
const [treasuryMint] = quickKeypair();

const args: AuctionHouseArgs = {
auctionHouseFeeAccount: creator,
auctionHouseTreasury,
treasuryWithdrawalDestination,
feeWithdrawalDestination,
treasuryMint,
authority: creator,
creator,
bump: 0,
treasuryBump: 1,
feePayerBump: 2,
sellerFeeBasisPoints: 3,
requiresSignOff: false,
canChangeSalePrice: true,
escrowPaymentBump: 255,
hasAuctioneer: false,
auctioneerAddress: PublicKey.default,
scopes: Array(7).fill(false), // constant size field in the contract
};

const expected = AuctionHouse.fromArgs(args);
const [data] = expected.serialize();

const info: AccountInfo<Buffer> = {
executable: false,
data,
owner: creator,
lamports: 1000,
};

const actual = AuctionHouse.fromAccountInfo(info)[0];
spok(t, actual, expected);
});

test('test auction-house instructions', async (t) => {
const authority = Keypair.generate();
const connection = new Connection(connectionURL, 'confirmed');
Expand Down
50 changes: 0 additions & 50 deletions auction-house/js/test/account.auction-house.test.ts

This file was deleted.

0 comments on commit 58347aa

Please sign in to comment.