Skip to content

Commit eeb0198

Browse files
fix Update tests to match latest api changes
1 parent c051599 commit eeb0198

File tree

5 files changed

+626
-1185
lines changed

5 files changed

+626
-1185
lines changed

packages/renderers-vixen-parser/e2e/raydium-amm-v4-parser/codama.cjs

Lines changed: 4 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -109,67 +109,12 @@ function main() {
109109
throw new Error('Project name is required.');
110110
}
111111

112-
const idl = readJson(path.join(__dirname, 'idl.json'));
113-
let node = rootNodeFromAnchor(idl);
114-
node = setDefaultShankDiscriminators(node);
112+
let idl = readJson(path.join(__dirname, 'idl.json'));
113+
idl.metadata = { origin: 'shank', address: '675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8' };
115114

116-
node.program.publicKey = '675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8';
115+
const node = rootNodeFromAnchor(idl);
117116

118117
generateProject(project, node);
119118
}
120119

121-
main();
122-
123-
function setDefaultShankDiscriminators(node) {
124-
node.program.origin = 'shank';
125-
126-
node.program.instructions.map((instruction, i) => {
127-
instruction.discriminators = [
128-
{
129-
kind: 'fieldDiscriminatorNode',
130-
field: 'discriminator',
131-
offset: 0,
132-
},
133-
];
134-
135-
const discriminatorArgument = {
136-
kind: 'instructionArgumentNode',
137-
name: 'discriminator',
138-
defaultValueStrategy: 'omitted',
139-
docs: [],
140-
type: {
141-
kind: 'fixedSizeTypeNode',
142-
size: 1,
143-
type: { kind: 'bytesTypeNode' },
144-
},
145-
defaultValue: {
146-
kind: 'bytesValueNode',
147-
data: i.toString(16),
148-
encoding: 'base16',
149-
},
150-
};
151-
152-
// // Remove discriminator argument if it exists
153-
const index = instruction.arguments.findIndex(arg => arg.name === 'discriminator');
154-
if (index !== -1) {
155-
instruction.arguments.splice(index, 1);
156-
}
157-
158-
instruction.arguments.unshift(discriminatorArgument);
159-
});
160-
161-
// By default use account length as discriminator for accounts
162-
const accounts = node.program.accounts.map(account => {
163-
let updatedAccount = { ...account, discriminators: [] };
164-
165-
const index = account.data.fields.findIndex(field => field.name === 'discriminator');
166-
if (index !== -1) {
167-
updatedAccount.data.fields.splice(index, 1);
168-
}
169-
return updatedAccount;
170-
});
171-
172-
node = { ...node, program: { ...node.program, accounts } };
173-
174-
return node;
175-
}
120+
main();

packages/renderers-vixen-parser/e2e/raydium-amm-v4-parser/src/generated_sdk/accounts/target_orders.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub struct TargetOrders {
4242
}
4343

4444
impl TargetOrders {
45-
pub const LEN: usize = 2216;
45+
pub const LEN: usize = 2208;
4646

4747
#[inline(always)]
4848
pub fn from_bytes(data: &[u8]) -> Result<Self, std::io::Error> {

packages/renderers-vixen-parser/test/accountsParserPage.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,13 @@ test('it renders accounts parsers', () => {
4141
const renderMap = visit(
4242
node,
4343
getRenderMapVisitor({
44-
project: 'test',
45-
sdkName: 'crate',
44+
projectName: 'test',
4645
}),
4746
);
4847

4948
// Then we expect the following identifier and reference to the byte array
5049
// as a parameters to be rendered.
51-
codeContains(renderMap.get('src/generated/accounts_parser.rs'), [
50+
codeContains(renderMap.get('src/generated_parser/accounts_parser.rs'), [
5251
'pub enum TestProgramState',
5352
'Mint(Mint)',
5453
'Account(Account)',

packages/renderers-vixen-parser/test/instructionsParserPage.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,13 @@ test('it renders instructions parsers', () => {
143143
const renderMap = visit(
144144
node,
145145
getRenderMapVisitor({
146-
project: 'test',
147-
sdkName: 'crate',
146+
projectName: 'test',
148147
}),
149148
);
150149

151150
// // Then we expect the following pub struct.
152151
// codeContains(renderMap.get('instructions/mint_tokens.rs'), [`pub struct MintTokensInstructionData`, `pub fn new(`]);
153-
codeContains(renderMap.get('src/generated/instructions_parser.rs'), [
152+
codeContains(renderMap.get('src/generated_parser/instructions_parser.rs'), [
154153
'pub enum TestProgramIx',
155154
'CreateAccount(CreateAccountIxAccounts, CreateAccountIxData)',
156155
'Assign(AssignIxAccounts, AssignIxData)',

0 commit comments

Comments
 (0)