Skip to content

Commit ae4f410

Browse files
committed
Test that update_dao works
1 parent eaef2d5 commit ae4f410

1 file changed

Lines changed: 64 additions & 56 deletions

File tree

tests/autocratV0.ts

Lines changed: 64 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -294,62 +294,70 @@ describe("autocrat_v0", async function () {
294294
instruction;
295295

296296
beforeEach(async function () {
297-
// const accounts = [
298-
// {
299-
// pubkey: dao,
300-
// isSigner: false,
301-
// isWritable: true,
302-
// },
303-
// {
304-
// pubkey: daoTreasury,
305-
// isSigner: true,
306-
// isWritable: false,
307-
// },
308-
// ];
309-
// newPassThresholdBps = Math.floor(Math.random() * 1000);
310-
// const data = autocrat.coder.instruction.encode("set_pass_threshold_bps", {
311-
// passThresholdBps: newPassThresholdBps,
312-
// });
313-
// const instruction = {
314-
// programId: autocrat.programId,
315-
// accounts,
316-
// data,
317-
// };
318-
319-
await mintToOverride(context, treasuryMetaAccount, 1_000_000_000n);
320-
await mintToOverride(context, treasuryUsdcAccount, 1_000_000n);
321-
322-
let receiver = Keypair.generate();
323-
let to0 = await createAccount(
324-
banksClient,
325-
payer,
326-
META,
327-
receiver.publicKey
328-
);
329-
let to1 = await createAccount(
330-
banksClient,
331-
payer,
332-
USDC,
333-
receiver.publicKey
334-
);
335-
336-
const ix = await migrator.methods
337-
.multiTransfer2()
338-
.accounts({
339-
authority: daoTreasury,
340-
from0: treasuryMetaAccount,
341-
to0,
342-
from1: treasuryUsdcAccount,
343-
to1,
344-
})
345-
.instruction();
346-
297+
// just uncomment this and replace with another instruction that you wish to test
298+
const accounts = [
299+
{
300+
pubkey: dao,
301+
isSigner: false,
302+
isWritable: true,
303+
},
304+
{
305+
pubkey: daoTreasury,
306+
isSigner: true,
307+
isWritable: false,
308+
},
309+
];
310+
newPassThresholdBps = Math.floor(Math.random() * 1000);
311+
const data = autocrat.coder.instruction.encode("update_dao", {
312+
daoParams: {
313+
passThresholdBps: newPassThresholdBps,
314+
baseBurnLamports: null,
315+
burnDecayPerSlotLamports: null,
316+
slotsPerProposal: null,
317+
marketTakerFee: null,
318+
twapExpectedValue: null,
319+
}
320+
});
347321
instruction = {
348-
programId: ix.programId,
349-
accounts: ix.keys,
350-
data: ix.data,
322+
programId: autocrat.programId,
323+
accounts,
324+
data,
351325
};
352326

327+
// await mintToOverride(context, treasuryMetaAccount, 1_000_000_000n);
328+
// await mintToOverride(context, treasuryUsdcAccount, 1_000_000n);
329+
330+
// let receiver = Keypair.generate();
331+
// let to0 = await createAccount(
332+
// banksClient,
333+
// payer,
334+
// META,
335+
// receiver.publicKey
336+
// );
337+
// let to1 = await createAccount(
338+
// banksClient,
339+
// payer,
340+
// USDC,
341+
// receiver.publicKey
342+
// );
343+
344+
// const ix = await migrator.methods
345+
// .multiTransfer2()
346+
// .accounts({
347+
// authority: daoTreasury,
348+
// from0: treasuryMetaAccount,
349+
// to0,
350+
// from1: treasuryUsdcAccount,
351+
// to1,
352+
// })
353+
// .instruction();
354+
355+
// instruction = {
356+
// programId: ix.programId,
357+
// accounts: ix.keys,
358+
// data: ix.data,
359+
// };
360+
353361
proposal = await initializeProposal(
354362
autocrat,
355363
instruction,
@@ -794,7 +802,7 @@ describe("autocrat_v0", async function () {
794802
// })
795803
instruction.accounts
796804
.concat({
797-
pubkey: migrator.programId,
805+
pubkey: instruction.programId,
798806
isWritable: false,
799807
isSigner: false,
800808
})
@@ -823,8 +831,8 @@ describe("autocrat_v0", async function () {
823831
assert((await getAccount(banksClient, treasuryMetaAccount)).amount == 0n);
824832
assert((await getAccount(banksClient, treasuryUsdcAccount)).amount == 0n);
825833

826-
// const storedDao = await autocrat.account.dao.fetch(dao);
827-
// assert.equal(storedDao.passThresholdBps, newPassThresholdBps);
834+
const storedDao = await autocrat.account.dao.fetch(dao);
835+
assert.equal(storedDao.passThresholdBps, newPassThresholdBps);
828836

829837
await redeemConditionalTokens(
830838
vaultProgram,

0 commit comments

Comments
 (0)