Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 3d04aa0

Browse files
committed
chore: add negative test for ATA creation with off-curve owner
1 parent 7320cf4 commit 3d04aa0

File tree

4 files changed

+66
-1
lines changed

4 files changed

+66
-1
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// flow-typed signature: 81268811ffa24a5fec63585e3a703215
2+
// flow-typed version: <<STUB>>/chai-as-promised_v7.1.1/flow_v0.145.0
3+
4+
/**
5+
* This is an autogenerated libdef stub for:
6+
*
7+
* 'chai-as-promised'
8+
*
9+
* Fill this stub out by replacing all the `any` types.
10+
*
11+
* Once filled out, we encourage you to share your work with the
12+
* community by sending a pull request to:
13+
* https://github.com/flowtype/flow-typed
14+
*/
15+
16+
declare module 'chai-as-promised' {
17+
declare module.exports: any;
18+
}
19+
20+
/**
21+
* We include stubs for each file inside this npm package in case you need to
22+
* require those files directly. Feel free to delete any files that aren't
23+
* needed.
24+
*/
25+
declare module 'chai-as-promised/lib/chai-as-promised' {
26+
declare module.exports: any;
27+
}
28+
29+
// Filename aliases
30+
declare module 'chai-as-promised/lib/chai-as-promised.js' {
31+
declare module.exports: $Exports<'chai-as-promised/lib/chai-as-promised'>;
32+
}

token/js/package-lock.json

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

token/js/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
"@typescript-eslint/parser": "^4.14.2",
8383
"babel-eslint": "^10.1.0",
8484
"chai": "^4.3.0",
85+
"chai-as-promised": "^7.1.1",
8586
"eslint": "^7.4.0",
8687
"eslint-plugin-flowtype": "^5.3.1",
8788
"eslint-plugin-import": "^2.22.0",

token/js/test/token.test.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
// @flow
2-
import {expect} from 'chai';
2+
import chai from 'chai';
3+
import chaiAsPromised from 'chai-as-promised';
34
import {Account, PublicKey} from '@solana/web3.js';
45

56
import {ASSOCIATED_TOKEN_PROGRAM_ID, Token, TOKEN_PROGRAM_ID} from '../client/token';
67

8+
chai.use(chaiAsPromised);
9+
const expect = chai.expect;
10+
711
describe('Token', () => {
812
it('createTransfer', () => {
913
const ix = Token.createTransferCheckedInstruction(
@@ -42,6 +46,12 @@ describe('Token', () => {
4246
expect(associatedPublicKey.toString()).to.eql(
4347
new PublicKey('DShWnroshVbeUp28oopA3Pu7oFPDBtC1DBmPECXXAQ9n').toString(),
4448
);
49+
await expect(Token.getAssociatedTokenAddress(
50+
ASSOCIATED_TOKEN_PROGRAM_ID,
51+
TOKEN_PROGRAM_ID,
52+
new PublicKey('7o36UsWR1JQLpZ9PE2gn9L4SQ69CNNiWAXd4Jt7rqz9Z'),
53+
associatedPublicKey,
54+
)).to.be.rejectedWith(`Owner cannot sign: ${associatedPublicKey.toString()}`);
4555
});
4656

4757
it('createAssociatedTokenAccount', () => {

0 commit comments

Comments
 (0)