-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #437 from LIT-Protocol/feat/cache-amd-certs-in-nod…
…e-env feat: allow cert caching if local storage is defined
- Loading branch information
Showing
2 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
e2e-nodejs/group-connection/test-connection-cert-caching.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import path from 'path'; | ||
import { success, fail, testThis, log } from '../../tools/scripts/utils.mjs'; | ||
import { LitNodeClient } from '@lit-protocol/lit-node-client'; | ||
import { LocalStorage } from 'node-localstorage'; | ||
export async function main() { | ||
const networks = ['habanero', 'manzano']; | ||
const storageProvider = new LocalStorage('./storage.test.db'); | ||
for (const network of networks) { | ||
// ==================== Test Logic ==================== | ||
const client = new LitNodeClient({ | ||
litNetwork: network, | ||
debug: globalThis.LitCI.debug, | ||
storageProvider: { | ||
provider: storageProvider, | ||
}, | ||
}); | ||
log(`connecting to ${network.toUpperCase()}...`); | ||
await client.connect(); | ||
|
||
// ==================== Post-Validation ==================== | ||
if (!client.ready) { | ||
return fail('client not ready'); | ||
} | ||
if (client.config.litNetwork !== network) { | ||
return fail(`client not connected to ${network}`); | ||
} | ||
|
||
if (storageProvider.length < 1) { | ||
fail(`cache is not hydrated with certificates`); | ||
} | ||
|
||
if (storageProvider.length < client.config.bootstrapUrls) { | ||
fail( | ||
`cache is not hydrated with enough certificates found: ${storageProvider.length} need ${client.config.bootstrapUrls.length}` | ||
); | ||
} | ||
for (let i = 0; i < storageProvider.length; i++) { | ||
const key = storageProvider.key(i); | ||
if (!key.includes('https://kdsintf.amd.com/')) { | ||
fail( | ||
'found cache item which does not match indexing schema should contain: https://kdsintf.amd.com/vcek/v1/Milan/' | ||
); | ||
} | ||
} | ||
} | ||
|
||
// ==================== Success ==================== | ||
return success( | ||
`Connected to ${networks.join(', ')} and found certs in cache` | ||
); | ||
} | ||
|
||
await testThis({ name: path.basename(import.meta.url), fn: main }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters