Skip to content

Commit 6f60709

Browse files
committed
solana: adjust tests for updateAuctionParameters
1 parent fa23845 commit 6f60709

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
@@ -1032,25 +1032,19 @@ describe("Matching Engine", function () {
10321032

10331033
localVariables.set("duplicateProposalId", nextProposalId);
10341034

1035-
for (let i = 0; i < 2; i++) {
1036-
const ix = await engine.proposeAuctionParametersIx(
1037-
{
1038-
ownerOrAssistant: ownerAssistant.publicKey,
1039-
},
1040-
newAuctionParameters,
1041-
);
1035+
const ix = await engine.proposeAuctionParametersIx(
1036+
{
1037+
ownerOrAssistant: ownerAssistant.publicKey,
1038+
},
1039+
newAuctionParameters,
1040+
);
10421041

1043-
await expectIxOk(connection, [ix], [ownerAssistant]);
1044-
}
1042+
await expectIxOk(connection, [ix], [ownerAssistant]);
10451043
});
10461044

10471045
it("Cannot Update Auction Config (Owner Only)", async function () {
1048-
const { nextProposalId } = await engine.fetchCustodian();
1049-
1050-
// Substract one to get the proposal ID for the auction parameters proposal.
1051-
const proposal = await engine.proposalAddress(
1052-
nextProposalId.sub(bigintToU64BN(1n)),
1053-
);
1046+
const proposalId = localVariables.get("duplicateProposalId") as BN;
1047+
const proposal = await engine.proposalAddress(proposalId);
10541048

10551049
const ix = await engine.updateAuctionParametersIx({
10561050
owner: ownerAssistant.publicKey,
@@ -1061,12 +1055,8 @@ describe("Matching Engine", function () {
10611055
});
10621056

10631057
it("Cannot Update Auction Config (Proposal Delay Not Expired)", async function () {
1064-
const { nextProposalId } = await engine.fetchCustodian();
1065-
1066-
// Substract one to get the proposal ID for the auction parameters proposal.
1067-
const proposal = await engine.proposalAddress(
1068-
nextProposalId.sub(bigintToU64BN(1n)),
1069-
);
1058+
const proposalId = localVariables.get("duplicateProposalId") as BN;
1059+
const proposal = await engine.proposalAddress(proposalId);
10701060

10711061
const ix = await engine.updateAuctionParametersIx({
10721062
owner: owner.publicKey,
@@ -1076,13 +1066,29 @@ describe("Matching Engine", function () {
10761066
await expectIxErr(connection, [ix], [owner], "Error Code: ProposalDelayNotExpired");
10771067
});
10781068

1069+
// TODO: Is this necessary?
1070+
it.skip("Cannot Update Auction Config (Auction Config Mismatch)", async function () {
1071+
const { auctionConfigId } = await engine.fetchCustodian();
1072+
const auctionConfigAddress = engine.auctionConfigAddress(auctionConfigId);
1073+
const proposalId = localVariables.get("duplicateProposalId") as BN;
1074+
1075+
const proposal = await engine.proposalAddress(proposalId);
1076+
1077+
const ix = await engine.updateAuctionParametersIx({
1078+
owner: owner.publicKey,
1079+
proposal,
1080+
auctionConfig: auctionConfigAddress,
1081+
});
1082+
1083+
await expectIxErr(connection, [ix], [owner], "Error Code: AuctionConfigMismatch");
1084+
});
1085+
10791086
it("Update Auction Config as Owner", async function () {
1080-
const { nextProposalId, auctionConfigId } = await engine.fetchCustodian();
1087+
const { auctionConfigId } = await engine.fetchCustodian();
10811088

10821089
// Substract one to get the proposal ID for the auction parameters proposal.
1083-
const proposal = await engine.proposalAddress(
1084-
nextProposalId.sub(bigintToU64BN(1n)),
1085-
);
1090+
const proposalId = localVariables.get("duplicateProposalId") as BN;
1091+
const proposal = await engine.proposalAddress(proposalId);
10861092
const proposalDataBefore = await engine.fetchProposal({ address: proposal });
10871093

10881094
await waitUntilSlot(
@@ -1104,20 +1110,16 @@ describe("Matching Engine", function () {
11041110

11051111
// Verify that the proposal was updated with the enacted at slot.
11061112
const proposalDataAfter = await engine
1107-
.proposalAddress(nextProposalId.sub(bigintToU64BN(1n)))
1113+
.proposalAddress(proposalId)
11081114
.then((addr) => engine.fetchProposal({ address: addr }));
11091115
expect(proposalDataAfter.slotEnactedAt).to.eql(
11101116
numberToU64BN(await connection.getSlot()),
11111117
);
11121118
});
11131119

11141120
it("Cannot Update Auction Config (Proposal Already Enacted)", async function () {
1115-
const { nextProposalId } = await engine.fetchCustodian();
1116-
1117-
// Substract one to get the proposal ID for the auction parameters proposal.
1118-
const proposal = await engine.proposalAddress(
1119-
nextProposalId.sub(bigintToU64BN(1n)),
1120-
);
1121+
const proposalId = localVariables.get("duplicateProposalId") as BN;
1122+
const proposal = await engine.proposalAddress(proposalId);
11211123

11221124
const ix = await engine.updateAuctionParametersIx({
11231125
owner: owner.publicKey,
@@ -1127,53 +1129,21 @@ describe("Matching Engine", function () {
11271129
await expectIxErr(connection, [ix], [owner], "Error Code: ProposalAlreadyEnacted");
11281130
});
11291131

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

1165-
// Substract one to get the proposal ID for the auction parameters proposal.
1166-
const proposal = await engine.proposalAddress(
1167-
nextProposalId.sub(bigintToU64BN(1n)),
1168-
);
1137+
// // Substract one to get the proposal ID for the auction parameters proposal.
1138+
// const proposal = await engine.proposalAddress(proposalId);
11691139

1170-
const ix = await engine.updateAuctionParametersIx({
1171-
owner: owner.publicKey,
1172-
proposal,
1173-
});
1140+
// const ix = await engine.updateAuctionParametersIx({
1141+
// owner: owner.publicKey,
1142+
// proposal,
1143+
// });
11741144

1175-
await expectIxOk(connection, [ix], [owner]);
1176-
});
1145+
// await expectIxOk(connection, [ix], [owner]);
1146+
// });
11771147
});
11781148
});
11791149

0 commit comments

Comments
 (0)