Skip to content

Commit 05f6c7c

Browse files
committed
solana: adjust tests for updateAuctionParameters
1 parent 7e07418 commit 05f6c7c

File tree

1 file changed

+46
-76
lines changed

1 file changed

+46
-76
lines changed

solana/ts/tests/01__matchingEngine.ts

+46-76
Original file line numberDiff line numberDiff line change
@@ -1024,25 +1024,19 @@ describe("Matching Engine", function () {
10241024

10251025
localVariables.set("duplicateProposalId", nextProposalId);
10261026

1027-
for (let i = 0; i < 2; i++) {
1028-
const ix = await engine.proposeAuctionParametersIx(
1029-
{
1030-
ownerOrAssistant: ownerAssistant.publicKey,
1031-
},
1032-
newAuctionParameters,
1033-
);
1027+
const ix = await engine.proposeAuctionParametersIx(
1028+
{
1029+
ownerOrAssistant: ownerAssistant.publicKey,
1030+
},
1031+
newAuctionParameters,
1032+
);
10341033

1035-
await expectIxOk(connection, [ix], [ownerAssistant]);
1036-
}
1034+
await expectIxOk(connection, [ix], [ownerAssistant]);
10371035
});
10381036

10391037
it("Cannot Update Auction Config (Owner Only)", async function () {
1040-
const { nextProposalId } = await engine.fetchCustodian();
1041-
1042-
// Substract one to get the proposal ID for the auction parameters proposal.
1043-
const proposal = await engine.proposalAddress(
1044-
nextProposalId.sub(bigintToU64BN(1n)),
1045-
);
1038+
const proposalId = localVariables.get("duplicateProposalId") as BN;
1039+
const proposal = await engine.proposalAddress(proposalId);
10461040

10471041
const ix = await engine.updateAuctionParametersIx({
10481042
owner: ownerAssistant.publicKey,
@@ -1053,12 +1047,8 @@ describe("Matching Engine", function () {
10531047
});
10541048

10551049
it("Cannot Update Auction Config (Proposal Delay Not Expired)", async function () {
1056-
const { nextProposalId } = await engine.fetchCustodian();
1057-
1058-
// Substract one to get the proposal ID for the auction parameters proposal.
1059-
const proposal = await engine.proposalAddress(
1060-
nextProposalId.sub(bigintToU64BN(1n)),
1061-
);
1050+
const proposalId = localVariables.get("duplicateProposalId") as BN;
1051+
const proposal = await engine.proposalAddress(proposalId);
10621052

10631053
const ix = await engine.updateAuctionParametersIx({
10641054
owner: owner.publicKey,
@@ -1068,13 +1058,29 @@ describe("Matching Engine", function () {
10681058
await expectIxErr(connection, [ix], [owner], "Error Code: ProposalDelayNotExpired");
10691059
});
10701060

1061+
// TODO: Is this necessary?
1062+
it.skip("Cannot Update Auction Config (Auction Config Mismatch)", async function () {
1063+
const { auctionConfigId } = await engine.fetchCustodian();
1064+
const auctionConfigAddress = engine.auctionConfigAddress(auctionConfigId);
1065+
const proposalId = localVariables.get("duplicateProposalId") as BN;
1066+
1067+
const proposal = await engine.proposalAddress(proposalId);
1068+
1069+
const ix = await engine.updateAuctionParametersIx({
1070+
owner: owner.publicKey,
1071+
proposal,
1072+
auctionConfig: auctionConfigAddress,
1073+
});
1074+
1075+
await expectIxErr(connection, [ix], [owner], "Error Code: AuctionConfigMismatch");
1076+
});
1077+
10711078
it("Update Auction Config as Owner", async function () {
1072-
const { nextProposalId, auctionConfigId } = await engine.fetchCustodian();
1079+
const { auctionConfigId } = await engine.fetchCustodian();
10731080

10741081
// Substract one to get the proposal ID for the auction parameters proposal.
1075-
const proposal = await engine.proposalAddress(
1076-
nextProposalId.sub(bigintToU64BN(1n)),
1077-
);
1082+
const proposalId = localVariables.get("duplicateProposalId") as BN;
1083+
const proposal = await engine.proposalAddress(proposalId);
10781084
const proposalDataBefore = await engine.fetchProposal({ address: proposal });
10791085

10801086
await waitUntilSlot(
@@ -1096,20 +1102,16 @@ describe("Matching Engine", function () {
10961102

10971103
// Verify that the proposal was updated with the enacted at slot.
10981104
const proposalDataAfter = await engine
1099-
.proposalAddress(nextProposalId.sub(bigintToU64BN(1n)))
1105+
.proposalAddress(proposalId)
11001106
.then((addr) => engine.fetchProposal({ address: addr }));
11011107
expect(proposalDataAfter.slotEnactedAt).to.eql(
11021108
numberToU64BN(await connection.getSlot()),
11031109
);
11041110
});
11051111

11061112
it("Cannot Update Auction Config (Proposal Already Enacted)", async function () {
1107-
const { nextProposalId } = await engine.fetchCustodian();
1108-
1109-
// Substract one to get the proposal ID for the auction parameters proposal.
1110-
const proposal = await engine.proposalAddress(
1111-
nextProposalId.sub(bigintToU64BN(1n)),
1112-
);
1113+
const proposalId = localVariables.get("duplicateProposalId") as BN;
1114+
const proposal = await engine.proposalAddress(proposalId);
11131115

11141116
const ix = await engine.updateAuctionParametersIx({
11151117
owner: owner.publicKey,
@@ -1119,53 +1121,21 @@ describe("Matching Engine", function () {
11191121
await expectIxErr(connection, [ix], [owner], "Error Code: ProposalAlreadyEnacted");
11201122
});
11211123

1122-
it("Cannot Update Auction Config (Auction Config Mismatch)", async function () {
1123-
const { nextProposalId } = await engine.fetchCustodian();
1124-
1125-
const proposalIx = await engine.proposeAuctionParametersIx(
1126-
{
1127-
ownerOrAssistant: ownerAssistant.publicKey,
1128-
},
1129-
auctionParams,
1130-
);
1131-
await expectIxOk(connection, [proposalIx], [ownerAssistant]);
1132-
1133-
const proposalData = await engine
1134-
.proposalAddress(nextProposalId)
1135-
.then((addr) => engine.fetchProposal({ address: addr }));
1136-
1137-
await waitUntilSlot(
1138-
connection,
1139-
proposalData.slotEnactDelay.toNumber() + SLOTS_PER_EPOCH + 1,
1140-
);
1141-
1142-
// Fetch the duplicate proposal ID saved earlier.
1143-
const duplicateProposalId = localVariables.get("duplicateProposalId") as BN;
1144-
const proposal = await engine.proposalAddress(duplicateProposalId);
1145-
1146-
const ix = await engine.updateAuctionParametersIx({
1147-
owner: owner.publicKey,
1148-
proposal,
1149-
});
1150-
1151-
await expectIxErr(connection, [ix], [owner], "Error Code: AuctionConfigMismatch");
1152-
});
1153-
1154-
after("Enact Last Proposal to Reset Auction Parameters", async function () {
1155-
const { nextProposalId } = await engine.fetchCustodian();
1124+
// TODO: Is this necessary if we enact in the test above?
1125+
// after("Enact Last Proposal to Reset Auction Parameters", async function () {
1126+
// const { nextProposalId } = await engine.fetchCustodian();
1127+
// const proposalId = localVariables.get("duplicateProposalId") as BN;
11561128

1157-
// Substract one to get the proposal ID for the auction parameters proposal.
1158-
const proposal = await engine.proposalAddress(
1159-
nextProposalId.sub(bigintToU64BN(1n)),
1160-
);
1129+
// // Substract one to get the proposal ID for the auction parameters proposal.
1130+
// const proposal = await engine.proposalAddress(proposalId);
11611131

1162-
const ix = await engine.updateAuctionParametersIx({
1163-
owner: owner.publicKey,
1164-
proposal,
1165-
});
1132+
// const ix = await engine.updateAuctionParametersIx({
1133+
// owner: owner.publicKey,
1134+
// proposal,
1135+
// });
11661136

1167-
await expectIxOk(connection, [ix], [owner]);
1168-
});
1137+
// await expectIxOk(connection, [ix], [owner]);
1138+
// });
11691139
});
11701140
});
11711141

0 commit comments

Comments
 (0)