Skip to content

Commit

Permalink
Merge pull request #1422 from drift-labs/fix/swift-lv-tests
Browse files Browse the repository at this point in the history
fix swift localValidator test
  • Loading branch information
LukasDeco authored Jan 10, 2025
2 parents 449f926 + db3a6d0 commit df42eed
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 5 additions & 1 deletion sdk/src/swift/swiftOrderSubscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ export class SwiftOrderSubscriber {
swiftOrderParamsMessage: SwiftOrderParamsMessage,
makerOrderParams: OptionalOrderParams
): Promise<TransactionInstruction[]> {
const swiftOrderParamsBuf = Buffer.from(
orderMessageRaw['order_message'],
'hex'
);
const takerAuthority = new PublicKey(orderMessageRaw['taker_authority']);
const takerUserPubkey = await getUserAccountPublicKey(
this.driftClient.program.programId,
Expand All @@ -164,7 +168,7 @@ export class SwiftOrderSubscriber {
).getUserAccount();
const ixs = await this.driftClient.getPlaceAndMakeSwiftPerpOrderIxs(
{
orderParams: orderMessageRaw['order_message'],
orderParams: swiftOrderParamsBuf,
signature: Buffer.from(orderMessageRaw['order_signature'], 'base64'),
},
decodeUTF8(orderMessageRaw['uuid']),
Expand Down
14 changes: 11 additions & 3 deletions tests/placeAndMakeSwiftPerp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,11 @@ describe('place and make swift order', () => {
immediateOrCancel: true,
});

const signedOrderParams = takerDriftClient.signSwiftOrderParamsMessage(
takerOrderParamsMessage
const takerOrderParamsMessageEncoded =
takerDriftClient.encodeSwiftOrderParamsMessage(takerOrderParamsMessage);
const takerOrderParamsSig = takerDriftClient.signMessage(
Buffer.from(takerOrderParamsMessageEncoded.toString('hex')),
makerDriftClient.wallet.payer
);

const ixs = [
Expand All @@ -376,7 +379,12 @@ describe('place and make swift order', () => {
];
ixs.push(
...(await makerDriftClient.getPlaceAndMakeSwiftPerpOrderIxs(
signedOrderParams,
{
orderParams: Buffer.from(
takerOrderParamsMessageEncoded.toString('hex')
),
signature: takerOrderParamsSig,
},
uuid,
{
taker: await takerDriftClient.getUserAccountPublicKey(),
Expand Down

0 comments on commit df42eed

Please sign in to comment.