Skip to content

Commit 312dc49

Browse files
author
Arnab Mitra
committed
test for issue #14.
1 parent 5e09e47 commit 312dc49

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

tests/vault-stake.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,32 @@ describe("vault-stake", () => {
10651065
}
10661066
});
10671067

1068+
it("rejects unbond with token account not owned by signer with InvalidTokenOwner", async () => {
1069+
// regression guard: previously emitted InvalidMintAuthority (wrong error code)
1070+
const [ticketPda] = anchor.web3.PublicKey.findProgramAddressSync(
1071+
[Buffer.from("ticket"), user.publicKey.toBuffer()],
1072+
program.programId
1073+
);
1074+
try {
1075+
// Pass user2's mint token account while signing as user — ownership mismatch
1076+
await program.methods.unbond(new BN(1000))
1077+
.accountsStrict({
1078+
stakeConfig: stakeConfigPda,
1079+
mint: mintedToken,
1080+
signer: user.publicKey,
1081+
userMintTokenAccount: user2MintTokenAccount,
1082+
ticket: ticketPda,
1083+
systemProgram: anchor.web3.SystemProgram.programId,
1084+
})
1085+
.signers([user])
1086+
.rpc();
1087+
assert.fail("Should have thrown error");
1088+
} catch (err) {
1089+
expect(err).to.exist;
1090+
expect(err.toString()).to.include("InvalidTokenOwner");
1091+
}
1092+
});
1093+
10681094
it("unpauses", async () => {
10691095
await program.methods
10701096
.pause(false)

0 commit comments

Comments
 (0)