From 744976b683179d644f4f9af830e69bd36b2f9e09 Mon Sep 17 00:00:00 2001 From: Jiyoon Koo Date: Wed, 24 Jan 2024 11:14:23 -0500 Subject: [PATCH] using devtools method for generating test vectors --- packages/protocol/src/dev-tools.ts | 25 ----- .../protocol/tests/generate-test-vectors.ts | 102 +----------------- 2 files changed, 3 insertions(+), 124 deletions(-) diff --git a/packages/protocol/src/dev-tools.ts b/packages/protocol/src/dev-tools.ts index 8d29daa2..fea5125e 100644 --- a/packages/protocol/src/dev-tools.ts +++ b/packages/protocol/src/dev-tools.ts @@ -29,31 +29,6 @@ export type RfqOptions = { receiver?: PortableDid } - -/** - * Options passed to {@link DevTools.createCredential} - * @beta - */ -export type CreateCredentialOptions = Omit & { - /** the credential type (e.g. UniversityDegreeCredential) */ - type: string - /** data to include in the credential */ - data: Record -} - -/** - * Options passed to {@link DevTools.createJwt} - * @beta - */ -export type CreateJwtOptions = { - /** the thing to sign */ - payload: any, - /** the JWT's subject (e.g. Alice's DID) */ - subject: string - /** the JWT's issuer */ - issuer: PortableDid -} - /** * Utility functions for testing purposes * @beta diff --git a/packages/protocol/tests/generate-test-vectors.ts b/packages/protocol/tests/generate-test-vectors.ts index acc25528..beb0de34 100644 --- a/packages/protocol/tests/generate-test-vectors.ts +++ b/packages/protocol/tests/generate-test-vectors.ts @@ -1,6 +1,6 @@ import { DidKeyMethod } from '@web5/dids' import { VerifiableCredential } from '@web5/credentials' -import { Close, Message, Offering, Order, OrderStatus, Quote, Rfq } from '../src/main.js' +import { Close, DevTools, Message, Order, OrderStatus, Quote, Rfq } from '../src/main.js' import fs from 'fs' /** @@ -15,83 +15,7 @@ type TestVector = { const generateParseOfferingVector = async () => { const did = await DidKeyMethod.create() - const offering = Offering.create({ - metadata : { from: did.did }, - data : { - description : 'Selling BTC for USD', - payinCurrency : { - currencyCode : 'USD', - maxAmount : '1000000.00' - }, - payoutCurrency: { - currencyCode : 'BTC', - maxAmount : '99952611.00000' - }, - payoutUnitsPerPayinUnit : '0.00003826', - payinMethods : [{ - kind : 'DEBIT_CARD', - requiredPaymentDetails : { - $schema : 'http://json-schema.org/draft-07/schema', - type : 'object', - properties : { - cardNumber: { - type : 'string', - description : 'The 16-digit debit card number', - minLength : 16, - maxLength : 16 - }, - expiryDate: { - type : 'string', - description : 'The expiry date of the card in MM/YY format', - pattern : '^(0[1-9]|1[0-2])\\/([0-9]{2})$' - }, - cardHolderName: { - type : 'string', - description : 'Name of the cardholder as it appears on the card' - }, - cvv: { - type : 'string', - description : 'The 3-digit CVV code', - minLength : 3, - maxLength : 3 - } - }, - required : ['cardNumber', 'expiryDate', 'cardHolderName', 'cvv'], - additionalProperties : false - } - }], - payoutMethods: [{ - kind : 'BTC_ADDRESS', - requiredPaymentDetails : { - $schema : 'http://json-schema.org/draft-07/schema', - type : 'object', - properties : { - btcAddress: { - type : 'string', - description : 'your Bitcoin wallet address' - } - }, - required : ['btcAddress'], - additionalProperties : false - } - }], - requiredClaims: { - id : '7ce4004c-3c38-4853-968b-e411bafcd945', - input_descriptors : [{ - id : 'bbdb9b7c-5754-4f46-b63b-590bada959e0', - constraints : { - fields: [{ - path : ['$.type'], - filter : { - type : 'string', - const : 'YoloCredential' - } - }] - } - }] - } - } - }) + const offering = DevTools.createOffering() await offering.sign(did) @@ -111,27 +35,7 @@ const generateParseQuoteVector = async () => { from : did.did, to : 'did:ex:pfi' }, - data: { - expiresAt : new Date().toISOString(), - payin : { - currencyCode : 'BTC', - amount : '0.01', - fee : '0.0001', - paymentInstruction : { - link : 'tbdex.io/example', - instruction : 'Fake instruction' - } - }, - payout: { - currencyCode : 'USD', - amount : '1000.00', - paymentInstruction : { - link : 'tbdex.io/example', - instruction : 'Fake instruction' - } - }, - - } + data: DevTools.createQuoteData() }) await quote.sign(did)