Skip to content

Commit 326f7a4

Browse files
Copilot0xrinegade
andcommitted
Fix final Assembly-BPF SDK test issues and complete implementation
Co-authored-by: 0xrinegade <[email protected]>
1 parent f1264cf commit 326f7a4

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

__tests__/sdk/assembly-bpf.test.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,17 @@ describe('BPF Assembler', () => {
341341
dst: BPFRegister.R1,
342342
src: BPFRegister.R2,
343343
comment: 'Add registers'
344+
},
345+
{
346+
opcode: BPFInstruction.LOAD_IMM,
347+
dst: BPFRegister.R0,
348+
immediate: 0,
349+
comment: 'Return success'
350+
},
351+
{
352+
opcode: BPFInstruction.EXIT,
353+
dst: BPFRegister.R0,
354+
comment: 'Exit program'
344355
}
345356
];
346357

@@ -351,8 +362,14 @@ describe('BPF Assembler', () => {
351362
);
352363

353364
const result = await sdk.compile(instructions, metadata);
365+
366+
if (!result.success) {
367+
console.log('Compilation errors:', result.errors);
368+
}
369+
370+
expect(result.success).toBe(true);
354371
expect(result.assembly).toBeDefined();
355-
expect(result.assembly).toContain('ldi');
372+
expect(result.assembly).toContain('lddw');
356373
expect(result.assembly).toContain('add');
357374
expect(result.assembly).toContain('Load test value');
358375
});

src/sdk/assembly-bpf/examples.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ export async function createSimplePaymentProcessor() {
4444
return {
4545
sdk,
4646
compilationResult,
47-
metadata
47+
metadata,
48+
instructions
4849
};
4950
}
5051

@@ -258,14 +259,14 @@ export async function deploymentWorkflow() {
258259
console.log('🚀 Starting complete deployment workflow...');
259260

260261
// Create a simple payment processor
261-
const { sdk, compilationResult, metadata } = await createSimplePaymentProcessor();
262+
const { sdk, compilationResult, metadata, instructions } = await createSimplePaymentProcessor();
262263

263264
if (!compilationResult.bytecode) {
264265
throw new Error('No bytecode generated');
265266
}
266267

267268
// Validate the program
268-
const validation = await sdk.validateProgram(compilationResult.bytecode);
269+
const validation = sdk.validateProgram(instructions);
269270

270271
if (!validation.valid) {
271272
console.log('❌ Program validation failed:');

0 commit comments

Comments
 (0)