|
1 | 1 | <!doctype html> |
2 | 2 | <html> |
| 3 | + <head> |
| 4 | + <meta charset="utf-8" /> |
| 5 | + <title>Concordium SDK - Web UMD Test</title> |
| 6 | + <script src="../../node_modules/@concordium/web-sdk/lib/min/concordium.web.min.js"></script> |
| 7 | + <style> |
| 8 | + body { |
| 9 | + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; |
| 10 | + max-width: 800px; |
| 11 | + margin: 40px auto; |
| 12 | + padding: 0 20px; |
| 13 | + line-height: 1.6; |
| 14 | + } |
| 15 | + h1 { |
| 16 | + border-bottom: 2px solid #eee; |
| 17 | + padding-bottom: 10px; |
| 18 | + } |
| 19 | + .test { |
| 20 | + padding: 10px; |
| 21 | + margin: 8px 0; |
| 22 | + border-radius: 4px; |
| 23 | + border-left: 4px solid; |
| 24 | + } |
| 25 | + .test.pass { |
| 26 | + background: #f0fff0; |
| 27 | + border-color: #2e7d32; |
| 28 | + } |
| 29 | + .test.fail { |
| 30 | + background: #fff0f0; |
| 31 | + border-color: #c62828; |
| 32 | + } |
| 33 | + .test-name { |
| 34 | + font-weight: 600; |
| 35 | + } |
| 36 | + .test-result { |
| 37 | + font-family: monospace; |
| 38 | + font-size: 12px; |
| 39 | + color: #666; |
| 40 | + margin-top: 4px; |
| 41 | + word-break: break-all; |
| 42 | + } |
| 43 | + .status { |
| 44 | + font-weight: bold; |
| 45 | + } |
| 46 | + .status.pass { |
| 47 | + color: #2e7d32; |
| 48 | + } |
| 49 | + .status.fail { |
| 50 | + color: #c62828; |
| 51 | + } |
| 52 | + #summary { |
| 53 | + margin-top: 20px; |
| 54 | + padding: 15px; |
| 55 | + background: #f5f5f5; |
| 56 | + border-radius: 4px; |
| 57 | + font-weight: 600; |
| 58 | + } |
| 59 | + </style> |
| 60 | + </head> |
3 | 61 |
|
4 | | -<head> |
5 | | - <meta charset="utf-8" /> |
6 | | - <script src="../../node_modules/@concordium/web-sdk/lib/min/concordium.web.min.js"></script> |
7 | | -</head> |
8 | | - |
9 | | -<body> |
10 | | - <div id="root"></div> |
11 | | - <script> |
12 | | - // Verifies that PLT works in UMD. |
13 | | - const account = concordiumSDK.AccountAddress.fromBase58('4UC8o4m8AgTxt5VBFMdLwMCwwJQVJwjesNzW7RPXkACynrULmd'); |
14 | | - const tokenAmount = concordiumSDK.TokenAmount.create(100, 2); |
15 | | - console.log(account, tokenAmount); |
16 | | - |
17 | | - // Verifies that UMD wasm functions work |
18 | | - const schema = concordiumSDK.toBuffer('FAACAAAABAAAAGtleXMQAR4gAAAADgAAAGF1eGlsaWFyeV9kYXRhEAEC', 'base64'); |
19 | | - console.log(concordiumSDK.displayTypeSchemaTemplate(schema)); |
20 | | - </script> |
21 | | -</body> |
| 62 | + <body> |
| 63 | + <h1>Concordium SDK - Web UMD Test</h1> |
| 64 | + <div id="results"></div> |
| 65 | + <div id="summary"></div> |
22 | 66 |
|
| 67 | + <script> |
| 68 | + const results = document.getElementById('results'); |
| 69 | + const summary = document.getElementById('summary'); |
| 70 | + let passed = 0, |
| 71 | + failed = 0; |
| 72 | + |
| 73 | + function test(name, fn) { |
| 74 | + const div = document.createElement('div'); |
| 75 | + div.className = 'test'; |
| 76 | + try { |
| 77 | + const result = fn(); |
| 78 | + div.className += ' pass'; |
| 79 | + div.innerHTML = `<span class="status pass">✓ PASS</span> <span class="test-name">${name}</span>`; |
| 80 | + if (result !== undefined) { |
| 81 | + div.innerHTML += `<div class="test-result">${escapeHtml(String(result))}</div>`; |
| 82 | + } |
| 83 | + passed++; |
| 84 | + } catch (e) { |
| 85 | + div.className += ' fail'; |
| 86 | + div.innerHTML = `<span class="status fail">✗ FAIL</span> <span class="test-name">${name}</span>`; |
| 87 | + div.innerHTML += `<div class="test-result">${escapeHtml(e.message)}</div>`; |
| 88 | + failed++; |
| 89 | + } |
| 90 | + results.appendChild(div); |
| 91 | + } |
| 92 | + |
| 93 | + function escapeHtml(str) { |
| 94 | + return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>'); |
| 95 | + } |
| 96 | + |
| 97 | + // Test: AccountAddress.fromBase58 |
| 98 | + test('AccountAddress.fromBase58()', () => { |
| 99 | + const account = concordiumSDK.AccountAddress.fromBase58( |
| 100 | + '4UC8o4m8AgTxt5VBFMdLwMCwwJQVJwjesNzW7RPXkACynrULmd' |
| 101 | + ); |
| 102 | + return account.address; |
| 103 | + }); |
| 104 | + |
| 105 | + // Test: TokenAmount.create (PLT functionality) |
| 106 | + test('TokenAmount.create() - PLT functionality', () => { |
| 107 | + const tokenAmount = concordiumSDK.TokenAmount.create(100, 2); |
| 108 | + return `TokenAmount: ${tokenAmount.toString()}`; |
| 109 | + }); |
| 110 | + |
| 111 | + // Test: displayTypeSchemaTemplate (WASM functionality) |
| 112 | + test('displayTypeSchemaTemplate() - WASM functionality', () => { |
| 113 | + const schema = concordiumSDK.toBuffer( |
| 114 | + 'FAACAAAABAAAAGtleXMQAR4gAAAADgAAAGF1eGlsaWFyeV9kYXRhEAEC', |
| 115 | + 'base64' |
| 116 | + ); |
| 117 | + const template = concordiumSDK.displayTypeSchemaTemplate(schema); |
| 118 | + return template.substring(0, 100) + (template.length > 100 ? '...' : ''); |
| 119 | + }); |
| 120 | + |
| 121 | + // Test: ConcordiumGRPCWebClient exists |
| 122 | + test('ConcordiumGRPCWebClient available', () => { |
| 123 | + if (typeof concordiumSDK.ConcordiumGRPCWebClient !== 'function') { |
| 124 | + throw new Error('ConcordiumGRPCWebClient is not a function'); |
| 125 | + } |
| 126 | + return 'Constructor available'; |
| 127 | + }); |
| 128 | + |
| 129 | + // Test: generateBakerKeys (WASM - wallet module) |
| 130 | + test('generateBakerKeys() - WASM wallet module', () => { |
| 131 | + const account = concordiumSDK.AccountAddress.fromBase58( |
| 132 | + '4UC8o4m8AgTxt5VBFMdLwMCwwJQVJwjesNzW7RPXkACynrULmd' |
| 133 | + ); |
| 134 | + const keys = concordiumSDK.generateBakerKeys(account); |
| 135 | + if (!keys.electionVerifyKey || !keys.signatureVerifyKey || !keys.aggregationVerifyKey) { |
| 136 | + throw new Error('Missing expected keys in result'); |
| 137 | + } |
| 138 | + return `electionVerifyKey: ${keys.electionVerifyKey.substring(0, 20)}...`; |
| 139 | + }); |
| 140 | + |
| 141 | + // Display summary |
| 142 | + const total = passed + failed; |
| 143 | + summary.innerHTML = |
| 144 | + `Tests: ${passed}/${total} passed` + |
| 145 | + (failed > 0 |
| 146 | + ? ` <span style="color: #c62828">(${failed} failed)</span>` |
| 147 | + : ' <span style="color: #2e7d32">✓</span>'); |
| 148 | + </script> |
| 149 | + </body> |
23 | 150 | </html> |
0 commit comments