@@ -461,7 +461,10 @@ describe('tests merkelization', () => {
461
461
expect ( birthDate . getTime ( ) ) . toEqual ( valueD . epochMilliseconds ) ;
462
462
463
463
const valueMTEntry = await MtValue . mkValueMtEntry ( DEFAULT_HASHER , valueD ) ;
464
- const ok = await verifyProof ( await mz . mt ! . root ( ) , proof , pathMTEntry , valueMTEntry ) ;
464
+ if ( ! mz . mt ) {
465
+ throw new Error ( "can't hash mt entry " ) ;
466
+ }
467
+ const ok = await verifyProof ( await mz . mt . root ( ) , proof , pathMTEntry , valueMTEntry ) ;
465
468
expect ( ok ) . toBeTruthy ( ) ;
466
469
467
470
expect ( ( await mz . root ( ) ) . hex ( ) ) . toEqual (
@@ -1025,9 +1028,8 @@ describe('merklize document with ipfs context', () => {
1025
1028
// node --experimental-vm-modules node_modules/jest/bin/jest.js -t 'set kubo client' tests/merklization.test.ts
1026
1029
1027
1030
const ipfsNodeURL = process . env . IPFS_URL ?? null ;
1028
- if ( ipfsNodeURL === null ) {
1029
- console . warn ( 'IPFS_URL is not set, skipping IPFS Node test' ) ;
1030
- return ;
1031
+ if ( ! ipfsNodeURL ) {
1032
+ throw new Error ( 'IPFS_URL is not set, skipping IPFS Node test' ) ;
1031
1033
}
1032
1034
1033
1035
beforeAll ( async ( ) => {
@@ -1036,7 +1038,7 @@ describe('merklize document with ipfs context', () => {
1036
1038
1037
1039
it ( 'ipfsNodeURL is set' , async ( ) => {
1038
1040
const mz : Merklizer = await Merklizer . merklizeJSONLD ( ipfsDocument , {
1039
- ipfsNodeURL : ipfsNodeURL
1041
+ ipfsNodeURL
1040
1042
} ) ;
1041
1043
expect ( ( await mz . root ( ) ) . bigInt ( ) . toString ( ) ) . toEqual (
1042
1044
'19309047812100087948241250053335720576191969395309912987389452441269932261840'
@@ -1045,7 +1047,7 @@ describe('merklize document with ipfs context', () => {
1045
1047
1046
1048
it ( 'ipfsGatewayURL is set' , async ( ) => {
1047
1049
const mz : Merklizer = await Merklizer . merklizeJSONLD ( ipfsDocument , {
1048
- ipfsGatewayURL : 'http://ipfs.io'
1050
+ ipfsNodeURL
1049
1051
} ) ;
1050
1052
expect ( ( await mz . root ( ) ) . bigInt ( ) . toString ( ) ) . toEqual (
1051
1053
'19309047812100087948241250053335720576191969395309912987389452441269932261840'
@@ -1075,10 +1077,20 @@ async function pushSchemasToIPFS(ipfsNodeURL: string): Promise<void> {
1075
1077
'dir1/dir2/bbs-v2.jsonld'
1076
1078
) ;
1077
1079
1078
- const addURL = normalizeIPFSNodeURL ( ipfsNodeURL , 'add' ) ;
1079
- const res = await fetch ( addURL , {
1080
+ let url : string | URL = normalizeIPFSNodeURL ( ipfsNodeURL , 'add' ) ;
1081
+ url = new URL ( url ) ;
1082
+ let headers = { } ;
1083
+ if ( url . username && url . password ) {
1084
+ headers = {
1085
+ authorization : `Basic ${ btoa ( url . username + ':' + url . password ) } `
1086
+ } ;
1087
+ url . username = '' ;
1088
+ url . password = '' ;
1089
+ }
1090
+ const res = await fetch ( url , {
1080
1091
method : 'POST' ,
1081
- body : formData
1092
+ body : formData ,
1093
+ headers
1082
1094
} ) ;
1083
1095
1084
1096
const resBody = await res . text ( ) ;
0 commit comments