Skip to content

Commit

Permalink
solana-labs#2406: initializeTransferFeeConfig test
Browse files Browse the repository at this point in the history
  • Loading branch information
Hrushi20 committed Apr 26, 2024
1 parent 6ad8073 commit b1b7e66
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 18 deletions.
16 changes: 0 additions & 16 deletions packages/rpc-graphql/src/__tests__/__setup__.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1686,22 +1686,6 @@ export const mockTransactionToken2022AllExtensions = {
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
stackHeight: null,
},
// Transfer Fee Instruction InitializeTransferFeeConfig
{
parsed: {
info: {
maximumFee: 5000,
mint: 'FsHcsGiY43QmZc6yTgwYC1DA5U3ZgycXxn3bd2oBjrEZ',
transferFeeBasisPoints: 50,
transferFeeConfigAuthority: '2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB',
withdrawWithheldAuthority: '2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB',
},
type: 'initializeTransferFeeConfig',
},
program: 'spl-token',
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
stackHeight: null,
},
// TODO (more) ...
],
recentBlockhash: '6vRS7MoToVccMqfQecdVC6UbmARaT5mha91zhreqnce9',
Expand Down
55 changes: 55 additions & 0 deletions packages/rpc-graphql/src/__tests__/transaction-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,61 @@ describe('transaction', () => {
},
});
});

it('initialize-transferFee-config', async () => {
expect.assertions(1);
const source = /* GraphQL */ `
query testQuery($signature: Signature!) {
transaction(signature: $signature) {
message {
instructions {
programId
... on SplTokenInitializeTransferFeeConfig {
mint {
address
}
transferFeeBasisPoints
maximumFee
transferFeeConfigAuthority {
address
}
withdrawWithheldAuthority {
address
}
}
}
}
}
}
`;

const result = await rpcGraphQL.query(source, { signature });
expect(result).toMatchObject({
data: {
transaction: {
message: {
instructions: expect.arrayContaining([
{
maximumFee: expect.any(Number),
mint: {
address: expect.any(String),
},
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
transferFeeBasisPoints: expect.any(Number),
transferFeeConfigAuthority: {
address: expect.any(String)
},
withdrawWithheldAuthority: {
address: expect.any(String)
},

},
]),
},
},
},
});
});
});
});
});
4 changes: 2 additions & 2 deletions packages/rpc-graphql/src/resolvers/instruction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ export const instructionResolvers = {
},
SplTokenInitializeTransferFeeConfig: {
mint: resolveAccount('mint'),
transferFeeConfigAuthority: resolveAccount('account'),
withdrawWithheldAuthority: resolveAccount('account'),
transferFeeConfigAuthority: resolveAccount('transferFeeConfigAuthority'),
withdrawWithheldAuthority: resolveAccount('withdrawWithheldAuthority'),
},
SplTokenMintToCheckedInstruction: {
account: resolveAccount('account'),
Expand Down

0 comments on commit b1b7e66

Please sign in to comment.