@@ -1412,6 +1412,49 @@ test('manifest encoding', t => {
1412
1412
}
1413
1413
} )
1414
1414
1415
+ test ( 'create verifier - open existing core with manifest' , async function ( t ) {
1416
+ const keyPair = crypto . keyPair ( )
1417
+
1418
+ const manifest = Verifier . createManifest ( {
1419
+ quorum : 1 ,
1420
+ signers : [ {
1421
+ signature : 'ed25519' ,
1422
+ publicKey : keyPair . publicKey
1423
+ } ]
1424
+ } )
1425
+
1426
+ const key = Verifier . manifestHash ( manifest )
1427
+
1428
+ const storage = ram . reusable ( )
1429
+ const core = new Hypercore ( storage , key , { compat : false } )
1430
+ await core . ready ( )
1431
+
1432
+ t . is ( core . manifest , null )
1433
+ t . is ( core . core . header . manifest , null )
1434
+ t . alike ( core . key , key )
1435
+
1436
+ await core . close ( )
1437
+
1438
+ manifest . signers [ 0 ] . publicKey = b4a . alloc ( 32 , 0 )
1439
+
1440
+ const wrongCore = new Hypercore ( storage , null , { manifest, compat : false } )
1441
+ await t . exception ( wrongCore . ready ( ) , / S T O R A G E _ C O N F L I C T / )
1442
+
1443
+ manifest . signers [ 0 ] . publicKey = keyPair . publicKey
1444
+
1445
+ const manifestCore = new Hypercore ( storage , null , { manifest, compat : false } )
1446
+ await manifestCore . ready ( )
1447
+
1448
+ t . not ( manifestCore . manifest , null )
1449
+ t . not ( manifestCore . core . header . manifest , null )
1450
+ t . alike ( manifestCore . key , key )
1451
+
1452
+ await manifestCore . close ( )
1453
+
1454
+ const compatCore = new Hypercore ( storage , null , { manifest, compat : true } )
1455
+ await t . execution ( compatCore . ready ( ) ) // compat flag is unset internally
1456
+ } )
1457
+
1415
1458
function createMultiManifest ( signers , prologue = null ) {
1416
1459
return {
1417
1460
hash : 'blake2b' ,
0 commit comments