viz-js-lib 0.11.0 → 0.12.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.qoder/docs/spec/viz-dns-nameserver-spec.md +982 -0
- package/.qoder/docs/viz-cpp-node-docs/data-types.md +322 -0
- package/.qoder/docs/viz-cpp-node-docs/index.md +160 -0
- package/.qoder/docs/viz-cpp-node-docs/op-account-market.md +236 -0
- package/.qoder/docs/viz-cpp-node-docs/op-account.md +199 -0
- package/.qoder/docs/viz-cpp-node-docs/op-award.md +162 -0
- package/.qoder/docs/viz-cpp-node-docs/op-committee.md +193 -0
- package/.qoder/docs/viz-cpp-node-docs/op-content.md +157 -0
- package/.qoder/docs/viz-cpp-node-docs/op-escrow.md +224 -0
- package/.qoder/docs/viz-cpp-node-docs/op-invite.md +219 -0
- package/.qoder/docs/viz-cpp-node-docs/op-proposal.md +229 -0
- package/.qoder/docs/viz-cpp-node-docs/op-recovery.md +188 -0
- package/.qoder/docs/viz-cpp-node-docs/op-subscription.md +146 -0
- package/.qoder/docs/viz-cpp-node-docs/op-transfer-vesting.md +224 -0
- package/.qoder/docs/viz-cpp-node-docs/op-witness.md +252 -0
- package/.qoder/docs/viz-cpp-node-docs/plugins.md +887 -0
- package/.qoder/docs/viz-cpp-node-docs/virtual-operations.md +513 -0
- package/.qoder/repowiki/en/content/API Reference/API Reference.md +724 -0
- package/.qoder/repowiki/en/content/API Reference/Configuration Options.md +410 -0
- package/.qoder/repowiki/en/content/API Reference/Core API Methods.md +547 -0
- package/.qoder/repowiki/en/content/API Reference/Streaming APIs.md +380 -0
- package/.qoder/repowiki/en/content/API Reference/Transport Layer.md +341 -0
- package/.qoder/repowiki/en/content/API Reference/VIZ Blockchain Operations Coverage Status.md +427 -0
- package/.qoder/repowiki/en/content/Authentication & Cryptography/Authentication & Cryptography.md +430 -0
- package/.qoder/repowiki/en/content/Authentication & Cryptography/Digital Signatures.md +462 -0
- package/.qoder/repowiki/en/content/Authentication & Cryptography/Key Management.md +456 -0
- package/.qoder/repowiki/en/content/Authentication & Cryptography/Memo Encryption.md +331 -0
- package/.qoder/repowiki/en/content/Authentication & Cryptography/Security Practices.md +488 -0
- package/.qoder/repowiki/en/content/Broadcast Transactions/Broadcast Transactions.md +432 -0
- package/.qoder/repowiki/en/content/Broadcast Transactions/Network Broadcasting.md +418 -0
- package/.qoder/repowiki/en/content/Broadcast Transactions/Operation Construction.md +352 -0
- package/.qoder/repowiki/en/content/Broadcast Transactions/Transaction Preparation.md +353 -0
- package/.qoder/repowiki/en/content/Broadcast Transactions/Transaction Signing.md +404 -0
- package/.qoder/repowiki/en/content/Data Serialization/Data Serialization.md +540 -0
- package/.qoder/repowiki/en/content/Data Serialization/Encoding & Decoding.md +463 -0
- package/.qoder/repowiki/en/content/Data Serialization/Object Templates.md +413 -0
- package/.qoder/repowiki/en/content/Data Serialization/Type System.md +514 -0
- package/.qoder/repowiki/en/content/Data Serialization/Validation Rules.md +439 -0
- package/.qoder/repowiki/en/content/Examples & Tutorials.md +485 -0
- package/.qoder/repowiki/en/content/Getting Started.md +345 -0
- package/.qoder/repowiki/en/content/Testing & Development.md +637 -0
- package/.qoder/repowiki/en/content/Utilities & Helpers.md +557 -0
- package/.qoder/repowiki/en/meta/repowiki-metadata.json +1 -0
- package/VIZ-JS-LIB-COVERAGE-STATUS.md +356 -0
- package/config.json +3 -1
- package/dist/statistics.html +1 -1
- package/dist/viz-tests.min.js +32 -42
- package/dist/viz-tests.min.js.gz +0 -0
- package/dist/viz.min.js +8 -18
- package/dist/viz.min.js.gz +0 -0
- package/lib/api/methods.js +24 -0
- package/lib/auth/serializer/src/ChainTypes.js +2 -1
- package/lib/auth/serializer/src/operations.js +35 -2
- package/lib/broadcast/index.js +29 -15
- package/lib/broadcast/operations.js +4 -0
- package/lib/dns.js +658 -0
- package/lib/index.js +3 -1
- package/package.json +3 -2
- package/test/dns.test.js +395 -0
- package/webpack/makeConfig.js +3 -0
|
@@ -0,0 +1,637 @@
|
|
|
1
|
+
# Testing & Development
|
|
2
|
+
|
|
3
|
+
<cite>
|
|
4
|
+
**Referenced Files in This Document**
|
|
5
|
+
- [package.json](file://package.json)
|
|
6
|
+
- [.travis.yml](file://.travis.yml)
|
|
7
|
+
- [webpack.config.js](file://webpack.config.js)
|
|
8
|
+
- [webpack/makeConfig.js](file://webpack/makeConfig.js)
|
|
9
|
+
- [.eslintrc](file://.eslintrc)
|
|
10
|
+
- [.editorconfig](file://.editorconfig)
|
|
11
|
+
- [src/index.js](file://src/index.js)
|
|
12
|
+
- [src/api/index.js](file://src/api/index.js)
|
|
13
|
+
- [src/auth/index.js](file://src/auth/index.js)
|
|
14
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js)
|
|
15
|
+
- [src/dns.js](file://src/dns.js)
|
|
16
|
+
- [src/browser.js](file://src/browser.js)
|
|
17
|
+
- [test/test_helper.js](file://test/test_helper.js)
|
|
18
|
+
- [test/browser/BrowserTests.js](file://test/browser/BrowserTests.js)
|
|
19
|
+
- [test/test.html](file://test/test.html)
|
|
20
|
+
- [test/api.test.js](file://test/api.test.js)
|
|
21
|
+
- [test/broadcast.test.js](file://test/broadcast.test.js)
|
|
22
|
+
- [test/methods.test.js](file://test/methods.test.js)
|
|
23
|
+
- [test/memo.test.js](file://test/memo.test.js)
|
|
24
|
+
- [test/comment.test.js](file://test/comment.test.js)
|
|
25
|
+
- [test/dns.test.js](file://test/dns.test.js)
|
|
26
|
+
- [test/test-post.json](file://test/test-post.json)
|
|
27
|
+
</cite>
|
|
28
|
+
|
|
29
|
+
## Update Summary
|
|
30
|
+
**Changes Made**
|
|
31
|
+
- Enhanced webpack configuration documentation to reflect async_hooks shim implementation for browser compatibility
|
|
32
|
+
- Updated Browser Testing Procedures section to explain async_hooks module handling
|
|
33
|
+
- Added Browser Compatibility Notes section explaining async_hooks shim configuration
|
|
34
|
+
- Updated Cross-Browser Compatibility Testing section to include async_hooks considerations
|
|
35
|
+
- Enhanced Build System Architecture diagram to show async_hooks shim integration
|
|
36
|
+
|
|
37
|
+
## Table of Contents
|
|
38
|
+
1. [Introduction](#introduction)
|
|
39
|
+
2. [Project Structure](#project-structure)
|
|
40
|
+
3. [Core Components](#core-components)
|
|
41
|
+
4. [Architecture Overview](#architecture-overview)
|
|
42
|
+
5. [Detailed Component Analysis](#detailed-component-analysis)
|
|
43
|
+
6. [Dependency Analysis](#dependency-analysis)
|
|
44
|
+
7. [Performance Considerations](#performance-considerations)
|
|
45
|
+
8. [Security Testing](#security-testing)
|
|
46
|
+
9. [Cross-Browser Compatibility Testing](#cross-browser-compatibility-testing)
|
|
47
|
+
10. [Development Workflow](#development-workflow)
|
|
48
|
+
11. [Code Quality Standards](#code-quality-standards)
|
|
49
|
+
12. [Contribution Guidelines](#contribution-guidelines)
|
|
50
|
+
13. [Troubleshooting Guide](#troubleshooting-guide)
|
|
51
|
+
14. [Conclusion](#conclusion)
|
|
52
|
+
|
|
53
|
+
## Introduction
|
|
54
|
+
This document provides comprehensive testing and development guidance for the VIZ JavaScript library. It covers the testing framework, unit test structure, browser testing procedures, continuous integration setup, and practical workflows for writing tests against API methods, authentication functions, broadcast operations, and the newly enhanced DNS module functionality. It also includes environment setup, mock data usage, debugging strategies, performance and security testing approaches, and cross-browser compatibility testing with special attention to async_hooks module handling for browser compatibility.
|
|
55
|
+
|
|
56
|
+
## Project Structure
|
|
57
|
+
The repository is organized around a modular JavaScript library with dedicated test suites and build tooling:
|
|
58
|
+
- Source code under src/ exposes the public API surface for API access, authentication, broadcasting, DNS functionality, formatters, and utilities.
|
|
59
|
+
- Tests under test/ cover Node.js unit tests, browser-specific tests, and HTML-based test harnesses.
|
|
60
|
+
- Build and packaging are handled via Webpack and NPM scripts with enhanced async_hooks module compatibility.
|
|
61
|
+
|
|
62
|
+
```mermaid
|
|
63
|
+
graph TB
|
|
64
|
+
subgraph "Source"
|
|
65
|
+
SRC_API["src/api/index.js"]
|
|
66
|
+
SRC_AUTH["src/auth/index.js"]
|
|
67
|
+
SRC_BROADCAST["src/broadcast/index.js"]
|
|
68
|
+
SRC_DNS["src/dns.js"]
|
|
69
|
+
SRC_BROWSER["src/browser.js"]
|
|
70
|
+
SRC_INDEX["src/index.js"]
|
|
71
|
+
end
|
|
72
|
+
subgraph "Tests"
|
|
73
|
+
T_API["test/api.test.js"]
|
|
74
|
+
T_BROADCAST["test/broadcast.test.js"]
|
|
75
|
+
T_METHODS["test/methods.test.js"]
|
|
76
|
+
T_MEMO["test/memo.test.js"]
|
|
77
|
+
T_COMMENT["test/comment.test.js"]
|
|
78
|
+
T_DNS["test/dns.test.js"]
|
|
79
|
+
T_BROWSER["test/browser/BrowserTests.js"]
|
|
80
|
+
T_TEST_HTML["test/test.html"]
|
|
81
|
+
end
|
|
82
|
+
subgraph "Tooling"
|
|
83
|
+
PKG["package.json"]
|
|
84
|
+
TRAVIS[".travis.yml"]
|
|
85
|
+
WEBPACK_CFG["webpack.config.js"]
|
|
86
|
+
MAKECFG["webpack/makeConfig.js"]
|
|
87
|
+
ESLINT[".eslintrc"]
|
|
88
|
+
EDITOR[".editorconfig"]
|
|
89
|
+
end
|
|
90
|
+
SRC_INDEX --> SRC_API
|
|
91
|
+
SRC_INDEX --> SRC_AUTH
|
|
92
|
+
SRC_INDEX --> SRC_BROADCAST
|
|
93
|
+
SRC_INDEX --> SRC_DNS
|
|
94
|
+
SRC_BROWSER --> SRC_API
|
|
95
|
+
SRC_BROWSER --> SRC_AUTH
|
|
96
|
+
SRC_BROWSER --> SRC_BROADCAST
|
|
97
|
+
SRC_BROWSER --> SRC_DNS
|
|
98
|
+
T_API --> SRC_API
|
|
99
|
+
T_BROADCAST --> SRC_BROADCAST
|
|
100
|
+
T_METHODS --> SRC_API
|
|
101
|
+
T_MEMO --> SRC_AUTH
|
|
102
|
+
T_COMMENT --> SRC_BROADCAST
|
|
103
|
+
T_DNS --> SRC_DNS
|
|
104
|
+
T_TEST_HTML --> T_API
|
|
105
|
+
WEBPACK_CFG --> MAKECFG
|
|
106
|
+
PKG --> WEBPACK_CFG
|
|
107
|
+
PKG --> ESLINT
|
|
108
|
+
PKG --> TRAVIS
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**Diagram sources**
|
|
112
|
+
- [src/index.js:1-22](file://src/index.js#L1-L22)
|
|
113
|
+
- [src/api/index.js:1-271](file://src/api/index.js#L1-L271)
|
|
114
|
+
- [src/auth/index.js:1-133](file://src/auth/index.js#L1-L133)
|
|
115
|
+
- [src/broadcast/index.js:1-137](file://src/broadcast/index.js#L1-L137)
|
|
116
|
+
- [src/dns.js:1-575](file://src/dns.js#L1-L575)
|
|
117
|
+
- [src/browser.js:1-30](file://src/browser.js#L1-L30)
|
|
118
|
+
- [test/api.test.js:1-202](file://test/api.test.js#L1-L202)
|
|
119
|
+
- [test/broadcast.test.js:1-154](file://test/broadcast.test.js#L1-L154)
|
|
120
|
+
- [test/methods.test.js:1-23](file://test/methods.test.js#L1-L23)
|
|
121
|
+
- [test/memo.test.js:1-38](file://test/memo.test.js#L1-L38)
|
|
122
|
+
- [test/comment.test.js:1-62](file://test/comment.test.js#L1-L62)
|
|
123
|
+
- [test/dns.test.js:1-396](file://test/dns.test.js#L1-L396)
|
|
124
|
+
- [test/browser/BrowserTests.js:1-56](file://test/browser/BrowserTests.js#L1-L56)
|
|
125
|
+
- [test/test.html:1-14](file://test/test.html#L1-L14)
|
|
126
|
+
- [webpack.config.js:1-3](file://webpack.config.js#L1-L3)
|
|
127
|
+
- [webpack/makeConfig.js:1-103](file://webpack/makeConfig.js#L1-L103)
|
|
128
|
+
- [package.json:1-85](file://package.json#L1-L85)
|
|
129
|
+
- [.travis.yml:1-18](file://.travis.yml#L1-L18)
|
|
130
|
+
- [.eslintrc:1-27](file://.eslintrc#L1-L27)
|
|
131
|
+
- [.editorconfig:1-21](file://.editorconfig#L1-L21)
|
|
132
|
+
|
|
133
|
+
**Section sources**
|
|
134
|
+
- [src/index.js:1-22](file://src/index.js#L1-L22)
|
|
135
|
+
- [src/browser.js:1-30](file://src/browser.js#L1-L30)
|
|
136
|
+
- [webpack.config.js:1-3](file://webpack.config.js#L1-L3)
|
|
137
|
+
- [webpack/makeConfig.js:1-103](file://webpack/makeConfig.js#L1-L103)
|
|
138
|
+
- [package.json:1-85](file://package.json#L1-L85)
|
|
139
|
+
- [.travis.yml:1-18](file://.travis.yml#L1-L18)
|
|
140
|
+
- [.eslintrc:1-27](file://.eslintrc#L1-L27)
|
|
141
|
+
- [.editorconfig:1-21](file://.editorconfig#L1-L21)
|
|
142
|
+
|
|
143
|
+
## Core Components
|
|
144
|
+
- API client: Provides WebSocket/HTTP transport abstraction, streaming utilities, and generated API methods. See [src/api/index.js:1-271](file://src/api/index.js#L1-L271).
|
|
145
|
+
- Authentication: Handles key derivation, WIF conversion, public key validation, and transaction signing. See [src/auth/index.js:1-133](file://src/auth/index.js#L1-L133).
|
|
146
|
+
- Broadcast: Prepares transactions, signs them, and broadcasts to the network. See [src/broadcast/index.js:1-137](file://src/broadcast/index.js#L1-L137).
|
|
147
|
+
- DNS Module: Comprehensive DNS nameserver helpers for managing A and TXT records in VIZ blockchain account metadata. See [src/dns.js:1-575](file://src/dns.js#L1-L575).
|
|
148
|
+
- Browser Facade: Exposes the library's public API surface for browser environments with async_hooks shim handling. See [src/browser.js:1-30](file://src/browser.js#L1-L30).
|
|
149
|
+
- Public facade: Exposes the library's public API surface including DNS functionality. See [src/index.js:1-22](file://src/index.js#L1-L22).
|
|
150
|
+
|
|
151
|
+
Key testing coverage areas:
|
|
152
|
+
- API methods and reconnection behavior: [test/api.test.js:1-202](file://test/api.test.js#L1-L202)
|
|
153
|
+
- Broadcast operations and transaction preparation: [test/broadcast.test.js:1-154](file://test/broadcast.test.js#L1-L154), [test/comment.test.js:1-62](file://test/comment.test.js#L1-L62)
|
|
154
|
+
- Generated methods completeness: [test/methods.test.js:1-23](file://test/methods.test.js#L1-L23)
|
|
155
|
+
- Memo encryption/decryption: [test/memo.test.js:1-38](file://test/memo.test.js#L1-L38)
|
|
156
|
+
- DNS module functionality: [test/dns.test.js:1-396](file://test/dns.test.js#L1-L396)
|
|
157
|
+
- Browser crypto tests: [test/browser/BrowserTests.js:1-56](file://test/browser/BrowserTests.js#L1-L56)
|
|
158
|
+
|
|
159
|
+
**Section sources**
|
|
160
|
+
- [src/api/index.js:1-271](file://src/api/index.js#L1-L271)
|
|
161
|
+
- [src/auth/index.js:1-133](file://src/auth/index.js#L1-L133)
|
|
162
|
+
- [src/broadcast/index.js:1-137](file://src/broadcast/index.js#L1-L137)
|
|
163
|
+
- [src/dns.js:1-575](file://src/dns.js#L1-L575)
|
|
164
|
+
- [src/browser.js:1-30](file://src/browser.js#L1-L30)
|
|
165
|
+
- [src/index.js:1-22](file://src/index.js#L1-L22)
|
|
166
|
+
- [test/api.test.js:1-202](file://test/api.test.js#L1-L202)
|
|
167
|
+
- [test/broadcast.test.js:1-154](file://test/broadcast.test.js#L1-L154)
|
|
168
|
+
- [test/methods.test.js:1-23](file://test/methods.test.js#L1-L23)
|
|
169
|
+
- [test/memo.test.js:1-38](file://test/memo.test.js#L1-L38)
|
|
170
|
+
- [test/comment.test.js:1-62](file://test/comment.test.js#L1-L62)
|
|
171
|
+
- [test/dns.test.js:1-396](file://test/dns.test.js#L1-L396)
|
|
172
|
+
- [test/browser/BrowserTests.js:1-56](file://test/browser/BrowserTests.js#L1-L56)
|
|
173
|
+
|
|
174
|
+
## Architecture Overview
|
|
175
|
+
The testing architecture integrates Node.js unit tests with a browser test harness. Webpack bundles the library and test suite for browser execution with enhanced async_hooks module compatibility for browser environments.
|
|
176
|
+
|
|
177
|
+
```mermaid
|
|
178
|
+
graph TB
|
|
179
|
+
subgraph "Build"
|
|
180
|
+
PKG_SCRIPTS["NPM Scripts<br/>test, build, build-browser, build-node"]
|
|
181
|
+
WEBPACK["Webpack Config<br/>entry viz-tests"]
|
|
182
|
+
ASYNC_HOOKS["Async Hooks Shim<br/>node.async_hooks: 'empty'"]
|
|
183
|
+
end
|
|
184
|
+
subgraph "Runtime"
|
|
185
|
+
LIB["viz Library<br/>src/index.js"]
|
|
186
|
+
API["API Module<br/>src/api/index.js"]
|
|
187
|
+
AUTH["Auth Module<br/>src/auth/index.js"]
|
|
188
|
+
BROADCAST["Broadcast Module<br/>src/broadcast/index.js"]
|
|
189
|
+
DNS["DNS Module<br/>src/dns.js"]
|
|
190
|
+
BROWSER["Browser Facade<br/>src/browser.js"]
|
|
191
|
+
end
|
|
192
|
+
subgraph "Tests"
|
|
193
|
+
NODE_TESTS["Node Tests<br/>Mocha + Babel"]
|
|
194
|
+
BROWSER_TESTS["Browser Harness<br/>test.html + BrowserTests.js"]
|
|
195
|
+
DNS_TESTS["DNS Tests<br/>Comprehensive Validation Suite"]
|
|
196
|
+
end
|
|
197
|
+
PKG_SCRIPTS --> WEBPACK
|
|
198
|
+
WEBPACK --> ASYNC_HOOKS
|
|
199
|
+
ASYNC_HOOKS --> LIB
|
|
200
|
+
LIB --> API
|
|
201
|
+
LIB --> AUTH
|
|
202
|
+
LIB --> BROADCAST
|
|
203
|
+
LIB --> DNS
|
|
204
|
+
BROWSER --> LIB
|
|
205
|
+
NODE_TESTS --> API
|
|
206
|
+
NODE_TESTS --> AUTH
|
|
207
|
+
NODE_TESTS --> BROADCAST
|
|
208
|
+
NODE_TESTS --> DNS
|
|
209
|
+
BROWSER_TESTS --> AUTH
|
|
210
|
+
BROWSER_TESTS --> API
|
|
211
|
+
DNS_TESTS --> DNS
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**Diagram sources**
|
|
215
|
+
- [package.json:6-13](file://package.json#L6-L13)
|
|
216
|
+
- [webpack.config.js:1-3](file://webpack.config.js#L1-L3)
|
|
217
|
+
- [webpack/makeConfig.js:76-78](file://webpack/makeConfig.js#L76-L78)
|
|
218
|
+
- [src/index.js:1-22](file://src/index.js#L1-L22)
|
|
219
|
+
- [src/api/index.js:1-271](file://src/api/index.js#L1-L271)
|
|
220
|
+
- [src/auth/index.js:1-133](file://src/auth/index.js#L1-L133)
|
|
221
|
+
- [src/broadcast/index.js:1-137](file://src/broadcast/index.js#L1-L137)
|
|
222
|
+
- [src/dns.js:1-575](file://src/dns.js#L1-L575)
|
|
223
|
+
- [src/browser.js:1-30](file://src/browser.js#L1-L30)
|
|
224
|
+
- [test/test.html:1-14](file://test/test.html#L1-L14)
|
|
225
|
+
- [test/browser/BrowserTests.js:1-56](file://test/browser/BrowserTests.js#L1-L56)
|
|
226
|
+
- [test/dns.test.js:1-396](file://test/dns.test.js#L1-L396)
|
|
227
|
+
|
|
228
|
+
## Detailed Component Analysis
|
|
229
|
+
|
|
230
|
+
### API Testing
|
|
231
|
+
- Purpose: Validate API connectivity, method generation, streaming, and reconnection behavior.
|
|
232
|
+
- Key aspects:
|
|
233
|
+
- Transport selection and lazy connection opening.
|
|
234
|
+
- Streaming block/transaction/operation streams.
|
|
235
|
+
- Reconnection logic on WebSocket close events.
|
|
236
|
+
- Async method coverage and listener cleanup.
|
|
237
|
+
|
|
238
|
+
```mermaid
|
|
239
|
+
sequenceDiagram
|
|
240
|
+
participant Test as "Mocha Test"
|
|
241
|
+
participant VIZ as "VIZ Instance"
|
|
242
|
+
participant Transport as "Transport (HTTP/WS)"
|
|
243
|
+
participant API as "Blockchain API"
|
|
244
|
+
Test->>VIZ : "new VIZ()"
|
|
245
|
+
Test->>VIZ : "start()"
|
|
246
|
+
VIZ->>Transport : "start()"
|
|
247
|
+
Transport->>API : "connect"
|
|
248
|
+
Test->>VIZ : "getFollowersAsync(...)"
|
|
249
|
+
VIZ->>Transport : "send(api, data)"
|
|
250
|
+
Transport->>API : "request"
|
|
251
|
+
API-->>Transport : "response"
|
|
252
|
+
Transport-->>VIZ : "onMessage"
|
|
253
|
+
VIZ-->>Test : "resolve result"
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
**Diagram sources**
|
|
257
|
+
- [test/api.test.js:14-29](file://test/api.test.js#L14-L29)
|
|
258
|
+
- [test/api.test.js:42-78](file://test/api.test.js#L42-L78)
|
|
259
|
+
- [test/api.test.js:80-166](file://test/api.test.js#L80-L166)
|
|
260
|
+
- [test/api.test.js:168-200](file://test/api.test.js#L168-L200)
|
|
261
|
+
- [src/api/index.js:52-62](file://src/api/index.js#L52-L62)
|
|
262
|
+
- [src/api/index.js:98-119](file://src/api/index.js#L98-L119)
|
|
263
|
+
|
|
264
|
+
**Section sources**
|
|
265
|
+
- [test/api.test.js:1-202](file://test/api.test.js#L1-L202)
|
|
266
|
+
- [src/api/index.js:1-271](file://src/api/index.js#L1-L271)
|
|
267
|
+
|
|
268
|
+
### Authentication and Memo Encryption Testing
|
|
269
|
+
- Purpose: Verify key derivation, WIF handling, public key parsing, and memo encryption/decryption.
|
|
270
|
+
- Key aspects:
|
|
271
|
+
- Private/public key pair generation and WIF round-trips.
|
|
272
|
+
- Memo encryption with known inputs and expected outputs.
|
|
273
|
+
- Error handling for unsupported memo encryption scenarios.
|
|
274
|
+
|
|
275
|
+
```mermaid
|
|
276
|
+
flowchart TD
|
|
277
|
+
Start(["Start"]) --> Seed["Derive Private Key from Seed"]
|
|
278
|
+
Seed --> PubKey["Compute Public Key"]
|
|
279
|
+
PubKey --> EncodeMemo["Encode Memo (with keys)"]
|
|
280
|
+
EncodeMemo --> DecodeMemo["Decode Memo (with keys)"]
|
|
281
|
+
DecodeMemo --> Compare{"Decoded equals original?"}
|
|
282
|
+
Compare --> |Yes| Pass["Pass"]
|
|
283
|
+
Compare --> |No| Fallback["Fallback to plaintext or flag"]
|
|
284
|
+
Fallback --> Pass
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
**Diagram sources**
|
|
288
|
+
- [test/memo.test.js:6-36](file://test/memo.test.js#L6-L36)
|
|
289
|
+
- [src/auth/index.js:56-101](file://src/auth/index.js#L56-L101)
|
|
290
|
+
|
|
291
|
+
**Section sources**
|
|
292
|
+
- [test/memo.test.js:1-38](file://test/memo.test.js#L1-L38)
|
|
293
|
+
- [src/auth/index.js:1-133](file://src/auth/index.js#L1-L133)
|
|
294
|
+
|
|
295
|
+
### Broadcast Operations Testing
|
|
296
|
+
- Purpose: Validate transaction preparation, signing, and broadcasting for operations like vote, transfer, and content with beneficiaries.
|
|
297
|
+
- Key aspects:
|
|
298
|
+
- Transaction patching with dynamic global properties.
|
|
299
|
+
- Signing with posting WIF and callback/promise variants.
|
|
300
|
+
- Content operations with permlink generation and metadata.
|
|
301
|
+
|
|
302
|
+
```mermaid
|
|
303
|
+
sequenceDiagram
|
|
304
|
+
participant Test as "Mocha Test"
|
|
305
|
+
participant Broadcast as "Broadcast Module"
|
|
306
|
+
participant Formatter as "Formatter"
|
|
307
|
+
participant Auth as "Auth.signTransaction"
|
|
308
|
+
participant API as "Broadcast API"
|
|
309
|
+
Test->>Broadcast : "_prepareTransaction(tx)"
|
|
310
|
+
Broadcast->>API : "getDynamicGlobalPropertiesAsync()"
|
|
311
|
+
API-->>Broadcast : "properties"
|
|
312
|
+
Broadcast-->>Test : "tx with ref_block_num/prefix, expiration"
|
|
313
|
+
Test->>Broadcast : "send(tx, {posting : wif})"
|
|
314
|
+
Broadcast->>Auth : "signTransaction(tx, keys)"
|
|
315
|
+
Auth-->>Broadcast : "signed tx"
|
|
316
|
+
Broadcast->>API : "broadcastTransactionWithCallbackAsync(...) or broadcastTransactionAsync"
|
|
317
|
+
API-->>Broadcast : "success"
|
|
318
|
+
Broadcast-->>Test : "return signed tx"
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
**Diagram sources**
|
|
322
|
+
- [test/broadcast.test.js:33-52](file://test/broadcast.test.js#L33-L52)
|
|
323
|
+
- [test/broadcast.test.js:75-120](file://test/broadcast.test.js#L75-L120)
|
|
324
|
+
- [test/comment.test.js:19-60](file://test/comment.test.js#L19-L60)
|
|
325
|
+
- [src/broadcast/index.js:49-84](file://src/broadcast/index.js#L49-L84)
|
|
326
|
+
- [src/broadcast/index.js:24-47](file://src/broadcast/index.js#L24-L47)
|
|
327
|
+
|
|
328
|
+
**Section sources**
|
|
329
|
+
- [test/broadcast.test.js:1-154](file://test/broadcast.test.js#L1-L154)
|
|
330
|
+
- [test/comment.test.js:1-62](file://test/comment.test.js#L1-L62)
|
|
331
|
+
- [src/broadcast/index.js:1-137](file://src/broadcast/index.js#L1-L137)
|
|
332
|
+
|
|
333
|
+
### DNS Module Testing
|
|
334
|
+
- Purpose: Comprehensive validation of DNS nameserver helpers for managing A and TXT records in VIZ blockchain account metadata.
|
|
335
|
+
- Key aspects:
|
|
336
|
+
- IPv4 address validation and SHA256 hash validation.
|
|
337
|
+
- Record creation functions for A records and SSL TXT records.
|
|
338
|
+
- Metadata parsing and extraction utilities.
|
|
339
|
+
- Metadata manipulation functions for adding/removing records.
|
|
340
|
+
- Validation of NS metadata structure and error handling.
|
|
341
|
+
|
|
342
|
+
**Updated** Added comprehensive DNS module testing coverage with over 300 lines of test validation for all helper functions, edge cases, and error conditions.
|
|
343
|
+
|
|
344
|
+
```mermaid
|
|
345
|
+
flowchart TD
|
|
346
|
+
Start(["DNS Test Suite"]) --> Validation["Validation Functions"]
|
|
347
|
+
Validation --> RecordCreation["Record Creation Functions"]
|
|
348
|
+
RecordCreation --> Parsing["Parsing Functions"]
|
|
349
|
+
Parsing --> Manipulation["Metadata Manipulation Functions"]
|
|
350
|
+
Manipulation --> Validation2["Validation"]
|
|
351
|
+
Validation --> ValidIPv4["isValidIPv4"]
|
|
352
|
+
ValidIPv4 --> ValidSHA256["isValidSHA256Hash"]
|
|
353
|
+
ValidSHA256 --> ValidTTL["isValidTTL"]
|
|
354
|
+
ValidTTL --> ValidSSL["isValidSslTxtRecord"]
|
|
355
|
+
RecordCreation --> CreateA["createARecord"]
|
|
356
|
+
CreateA --> CreateSSL["createSslTxtRecord"]
|
|
357
|
+
CreateSSL --> CreateTxt["createTxtRecord"]
|
|
358
|
+
CreateTxt --> CreateNS["createNsMetadata"]
|
|
359
|
+
Parsing --> ParseNS["parseNsMetadata"]
|
|
360
|
+
ParseNS --> ExtractA["extractARecords"]
|
|
361
|
+
ExtractA --> ExtractSSL["extractSslHash"]
|
|
362
|
+
ExtractSSL --> ExtractTXT["extractTxtRecords"]
|
|
363
|
+
Manipulation --> MergeNS["mergeNsMetadata"]
|
|
364
|
+
MergeNS --> AddA["addARecord"]
|
|
365
|
+
AddA --> RemoveA["removeARecord"]
|
|
366
|
+
RemoveA --> SetSSL["setSslHash"]
|
|
367
|
+
SetSSL --> RemoveSSL["removeSslHash"]
|
|
368
|
+
RemoveSSL --> SetTTL["setTtl"]
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
**Diagram sources**
|
|
372
|
+
- [test/dns.test.js:8-396](file://test/dns.test.js#L8-L396)
|
|
373
|
+
- [src/dns.js:25-575](file://src/dns.js#L25-L575)
|
|
374
|
+
|
|
375
|
+
**Section sources**
|
|
376
|
+
- [test/dns.test.js:1-396](file://test/dns.test.js#L1-L396)
|
|
377
|
+
- [src/dns.js:1-575](file://src/dns.js#L1-L575)
|
|
378
|
+
|
|
379
|
+
### Browser Testing Procedures
|
|
380
|
+
- Purpose: Run browser-side crypto and encoding tests in a real browser environment with async_hooks module compatibility.
|
|
381
|
+
- Setup:
|
|
382
|
+
- Webpack bundles a test bundle named viz-tests with async_hooks shim configuration.
|
|
383
|
+
- The HTML harness loads Mocha and runs the test bundle.
|
|
384
|
+
- Browser tests exercise ECC key generation, WIF parsing, and memo encryption/decryption.
|
|
385
|
+
- Async Hooks Compatibility:
|
|
386
|
+
- The webpack configuration includes `node.async_hooks: 'empty'` to prevent async_hooks module from causing issues in browser environments.
|
|
387
|
+
- Package.json browser field disables async_hooks module for browser builds.
|
|
388
|
+
|
|
389
|
+
```mermaid
|
|
390
|
+
sequenceDiagram
|
|
391
|
+
participant Browser as "Browser"
|
|
392
|
+
participant Mocha as "Mocha Runner"
|
|
393
|
+
participant Bundle as "viz-tests.min.js"
|
|
394
|
+
participant Tests as "BrowserTests.js"
|
|
395
|
+
Browser->>Mocha : "load test.html"
|
|
396
|
+
Mocha->>Bundle : "load viz-tests.min.js"
|
|
397
|
+
Bundle->>Tests : "execute exported runTests()"
|
|
398
|
+
Tests-->>Mocha : "report results/errors"
|
|
399
|
+
Note over Bundle : "async_hooks shim enabled<br/>node.async_hooks : 'empty'"
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
**Diagram sources**
|
|
403
|
+
- [test/test.html:1-14](file://test/test.html#L1-L14)
|
|
404
|
+
- [webpack/makeConfig.js:67-70](file://webpack/makeConfig.js#L67-L70)
|
|
405
|
+
- [webpack/makeConfig.js:76-78](file://webpack/makeConfig.js#L76-L78)
|
|
406
|
+
- [package.json:15-19](file://package.json#L15-L19)
|
|
407
|
+
- [test/browser/BrowserTests.js:8-56](file://test/browser/BrowserTests.js#L8-L56)
|
|
408
|
+
|
|
409
|
+
**Section sources**
|
|
410
|
+
- [test/test.html:1-14](file://test/test.html#L1-L14)
|
|
411
|
+
- [webpack/makeConfig.js:1-103](file://webpack/makeConfig.js#L1-L103)
|
|
412
|
+
- [package.json:15-19](file://package.json#L15-L19)
|
|
413
|
+
- [test/browser/BrowserTests.js:1-56](file://test/browser/BrowserTests.js#L1-L56)
|
|
414
|
+
|
|
415
|
+
## Dependency Analysis
|
|
416
|
+
- Test runner and transpilation:
|
|
417
|
+
- Mocha is configured via NPM scripts and Babel registration.
|
|
418
|
+
- ESLint enforces style and correctness rules across Node, browser, and Mocha environments.
|
|
419
|
+
- Build-time dependencies:
|
|
420
|
+
- Webpack bundles the library and test suite; production builds enable minification and deduplication.
|
|
421
|
+
- Async hooks shim configuration prevents module resolution conflicts in browser builds.
|
|
422
|
+
- Runtime dependencies:
|
|
423
|
+
- Bluebird for promises, cross-fetch for HTTP transport, debug for logging, and others for cryptography and serialization.
|
|
424
|
+
|
|
425
|
+
```mermaid
|
|
426
|
+
graph LR
|
|
427
|
+
PKG["package.json"]
|
|
428
|
+
ESL["ESLint (.eslintrc)"]
|
|
429
|
+
WEB["Webpack (makeConfig.js)"]
|
|
430
|
+
ASYNC_HOOKS["Async Hooks Shim<br/>node.async_hooks: 'empty'"]
|
|
431
|
+
API["src/api/index.js"]
|
|
432
|
+
AUTH["src/auth/index.js"]
|
|
433
|
+
BROAD["src/broadcast/index.js"]
|
|
434
|
+
DNS["src/dns.js"]
|
|
435
|
+
BROWSER["src/browser.js"]
|
|
436
|
+
PKG --> ESL
|
|
437
|
+
PKG --> WEB
|
|
438
|
+
WEB --> ASYNC_HOOKS
|
|
439
|
+
WEB --> API
|
|
440
|
+
WEB --> AUTH
|
|
441
|
+
WEB --> BROAD
|
|
442
|
+
WEB --> DNS
|
|
443
|
+
WEB --> BROWSER
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
**Diagram sources**
|
|
447
|
+
- [package.json:56-75](file://package.json#L56-L75)
|
|
448
|
+
- [package.json:15-19](file://package.json#L15-L19)
|
|
449
|
+
- [.eslintrc:1-27](file://.eslintrc#L1-L27)
|
|
450
|
+
- [webpack/makeConfig.js:1-103](file://webpack/makeConfig.js#L1-L103)
|
|
451
|
+
- [src/api/index.js:1-271](file://src/api/index.js#L1-L271)
|
|
452
|
+
- [src/auth/index.js:1-133](file://src/auth/index.js#L1-L133)
|
|
453
|
+
- [src/broadcast/index.js:1-137](file://src/broadcast/index.js#L1-L137)
|
|
454
|
+
- [src/dns.js:1-575](file://src/dns.js#L1-L575)
|
|
455
|
+
- [src/browser.js:1-30](file://src/browser.js#L1-L30)
|
|
456
|
+
|
|
457
|
+
**Section sources**
|
|
458
|
+
- [package.json:1-85](file://package.json#L1-L85)
|
|
459
|
+
- [.eslintrc:1-27](file://.eslintrc#L1-L27)
|
|
460
|
+
- [webpack/makeConfig.js:1-103](file://webpack/makeConfig.js#L1-L103)
|
|
461
|
+
|
|
462
|
+
## Performance Considerations
|
|
463
|
+
- Streaming APIs:
|
|
464
|
+
- The API module provides streaming utilities for block number, blocks, transactions, and operations. Tests validate that streams emit expected properties and can be released cleanly.
|
|
465
|
+
- Transaction preparation:
|
|
466
|
+
- Broadcasting prepares transactions using dynamic global properties and block references. Tests ensure the presence of required fields and signatures.
|
|
467
|
+
- DNS module operations:
|
|
468
|
+
- DNS metadata parsing and validation operations are optimized for performance with regex-based validation and efficient array filtering.
|
|
469
|
+
- Async Hooks Performance:
|
|
470
|
+
- The async_hooks shim prevents unnecessary module loading overhead in browser environments.
|
|
471
|
+
- Browser builds benefit from reduced bundle size due to async_hooks module exclusion.
|
|
472
|
+
- Recommendations:
|
|
473
|
+
- Use timeouts and resource cleanup in long-running streams.
|
|
474
|
+
- Batch operations where appropriate to reduce network overhead.
|
|
475
|
+
- Monitor performance metrics emitted by the API client during tests.
|
|
476
|
+
- Optimize DNS metadata operations by caching validated results where appropriate.
|
|
477
|
+
- Leverage async_hooks shim for improved browser performance.
|
|
478
|
+
|
|
479
|
+
**Section sources**
|
|
480
|
+
- [src/api/index.js:121-235](file://src/api/index.js#L121-L235)
|
|
481
|
+
- [test/api.test.js:80-166](file://test/api.test.js#L80-L166)
|
|
482
|
+
- [src/broadcast/index.js:49-84](file://src/broadcast/index.js#L49-L84)
|
|
483
|
+
- [test/broadcast.test.js:33-52](file://test/broadcast.test.js#L33-L52)
|
|
484
|
+
- [src/dns.js:19-74](file://src/dns.js#L19-L74)
|
|
485
|
+
- [test/dns.test.js:1-396](file://test/dns.test.js#L1-L396)
|
|
486
|
+
- [webpack/makeConfig.js:76-78](file://webpack/makeConfig.js#L76-L78)
|
|
487
|
+
- [package.json:15-19](file://package.json#L15-L19)
|
|
488
|
+
|
|
489
|
+
## Security Testing
|
|
490
|
+
- Key handling:
|
|
491
|
+
- Validate WIF validity and public key derivation.
|
|
492
|
+
- Ensure memo encryption/decryption works with provided keys and falls back gracefully when unsupported.
|
|
493
|
+
- Transaction signing:
|
|
494
|
+
- Confirm that signing produces valid signatures and that broadcast methods return signed transactions with required fields.
|
|
495
|
+
- DNS security validation:
|
|
496
|
+
- Validate IPv4 addresses and SHA256 hashes to prevent injection attacks.
|
|
497
|
+
- Ensure TXT record length validation prevents buffer overflow scenarios.
|
|
498
|
+
- Test error handling for malformed DNS metadata to prevent crashes.
|
|
499
|
+
- Async Hooks Security:
|
|
500
|
+
- The async_hooks shim prevents potential security issues from async_hooks module usage in browser environments.
|
|
501
|
+
- Browser builds exclude async_hooks module to reduce attack surface.
|
|
502
|
+
- Recommendations:
|
|
503
|
+
- Use deterministic seeds and known-good test vectors for cryptographic routines.
|
|
504
|
+
- Avoid logging secrets; mask sensitive data in test logs.
|
|
505
|
+
- Prefer environment variables for credentials in integration-style tests.
|
|
506
|
+
- Implement comprehensive input sanitization for DNS metadata operations.
|
|
507
|
+
- Leverage async_hooks shim for enhanced browser security.
|
|
508
|
+
|
|
509
|
+
**Section sources**
|
|
510
|
+
- [src/auth/index.js:65-101](file://src/auth/index.js#L65-L101)
|
|
511
|
+
- [test/memo.test.js:6-36](file://test/memo.test.js#L6-L36)
|
|
512
|
+
- [src/broadcast/index.js:107-130](file://src/broadcast/index.js#L107-L130)
|
|
513
|
+
- [test/broadcast.test.js:75-120](file://test/broadcast.test.js#L75-L120)
|
|
514
|
+
- [src/dns.js:19-74](file://src/dns.js#L19-L74)
|
|
515
|
+
- [test/dns.test.js:1-396](file://test/dns.test.js#L1-L396)
|
|
516
|
+
- [webpack/makeConfig.js:76-78](file://webpack/makeConfig.js#L76-L78)
|
|
517
|
+
- [package.json:15-19](file://package.json#L15-L19)
|
|
518
|
+
|
|
519
|
+
## Cross-Browser Compatibility Testing
|
|
520
|
+
- Browser harness:
|
|
521
|
+
- The browser test suite executes in a real browser using the bundled viz-tests.min.js and the Mocha HTML harness.
|
|
522
|
+
- Async hooks shim configuration ensures compatibility across modern browsers.
|
|
523
|
+
- Practical steps:
|
|
524
|
+
- Build the browser bundle and open the test page in target browsers.
|
|
525
|
+
- Observe console output and error reporting from the browser test runner.
|
|
526
|
+
- Async Hooks Compatibility:
|
|
527
|
+
- The webpack configuration includes `node.async_hooks: 'empty'` to prevent async_hooks module resolution in browser builds.
|
|
528
|
+
- Package.json browser field disables async_hooks module for browser-specific builds.
|
|
529
|
+
- This prevents "Module not found" errors when async_hooks is referenced in dependencies.
|
|
530
|
+
- DNS compatibility considerations:
|
|
531
|
+
- DNS module operations rely on standard JavaScript APIs and should be compatible across modern browsers.
|
|
532
|
+
- Regex validation functions are supported in all major browsers.
|
|
533
|
+
- Recommendations:
|
|
534
|
+
- Test across multiple browser versions to ensure async_hooks shim compatibility.
|
|
535
|
+
- Verify that browser builds load without async_hooks-related errors.
|
|
536
|
+
- Test DNS module functionality in various browser environments.
|
|
537
|
+
|
|
538
|
+
**Section sources**
|
|
539
|
+
- [test/test.html:1-14](file://test/test.html#L1-L14)
|
|
540
|
+
- [webpack/makeConfig.js:67-70](file://webpack/makeConfig.js#L67-L70)
|
|
541
|
+
- [webpack/makeConfig.js:76-78](file://webpack/makeConfig.js#L76-L78)
|
|
542
|
+
- [package.json:15-19](file://package.json#L15-L19)
|
|
543
|
+
- [test/browser/BrowserTests.js:1-56](file://test/browser/BrowserTests.js#L1-L56)
|
|
544
|
+
- [src/dns.js:19-74](file://src/dns.js#L19-L74)
|
|
545
|
+
|
|
546
|
+
## Development Workflow
|
|
547
|
+
- Local setup:
|
|
548
|
+
- Install dependencies and build artifacts using NPM scripts.
|
|
549
|
+
- Run unit tests with Mocha and Babel transpilation.
|
|
550
|
+
- Build browser bundles with async_hooks shim configuration.
|
|
551
|
+
- Writing tests:
|
|
552
|
+
- Place new tests under test/ following existing patterns.
|
|
553
|
+
- Use async/await or callbacks consistently.
|
|
554
|
+
- Leverage helper assertions and stubs where applicable.
|
|
555
|
+
- For DNS module testing, follow the established pattern of validation, creation, parsing, and manipulation functions.
|
|
556
|
+
- Test browser compatibility with async_hooks shim in place.
|
|
557
|
+
- Running subsets:
|
|
558
|
+
- Use NPM script aliases to run focused test suites (e.g., auth-related tests).
|
|
559
|
+
- Run DNS-specific tests using: `npm test -- --grep 'DNS Helpers'`
|
|
560
|
+
- Test browser builds with: `npm run build-browser`
|
|
561
|
+
- Continuous integration:
|
|
562
|
+
- Travis CI runs tests on multiple Node.js versions and caches dependencies.
|
|
563
|
+
- Browser builds automatically include async_hooks shim configuration.
|
|
564
|
+
|
|
565
|
+
**Section sources**
|
|
566
|
+
- [package.json:6-13](file://package.json#L6-L13)
|
|
567
|
+
- [.travis.yml:1-18](file://.travis.yml#L1-L18)
|
|
568
|
+
|
|
569
|
+
## Code Quality Standards
|
|
570
|
+
- Linting:
|
|
571
|
+
- ESLint configuration targets ES6 modules, Node, browser, and Mocha environments with warnings for unused variables and unreachable code.
|
|
572
|
+
- Formatting:
|
|
573
|
+
- EditorConfig enforces consistent indentation and line endings.
|
|
574
|
+
- Style expectations:
|
|
575
|
+
- Prefer const/let, avoid unreachable code, and follow module boundaries.
|
|
576
|
+
- DNS module standards:
|
|
577
|
+
- Comprehensive test coverage with validation functions, error handling, and edge case testing.
|
|
578
|
+
- Consistent error message formatting and validation patterns.
|
|
579
|
+
- Async Hooks Standards:
|
|
580
|
+
- Proper shim configuration in webpack for browser compatibility.
|
|
581
|
+
- Browser field configuration in package.json for module resolution control.
|
|
582
|
+
|
|
583
|
+
**Section sources**
|
|
584
|
+
- [.eslintrc:1-27](file://.eslintrc#L1-L27)
|
|
585
|
+
- [.editorconfig:1-21](file://.editorconfig#L1-L21)
|
|
586
|
+
- [webpack/makeConfig.js:76-78](file://webpack/makeConfig.js#L76-L78)
|
|
587
|
+
- [package.json:15-19](file://package.json#L15-L19)
|
|
588
|
+
|
|
589
|
+
## Contribution Guidelines
|
|
590
|
+
- Testing requirements:
|
|
591
|
+
- Add unit tests for new features and bug fixes.
|
|
592
|
+
- Include browser tests for crypto-related functionality.
|
|
593
|
+
- For DNS module contributions, ensure comprehensive test coverage following the established pattern.
|
|
594
|
+
- Verify browser compatibility with async_hooks shim when adding new functionality.
|
|
595
|
+
- Pull requests:
|
|
596
|
+
- Ensure tests pass locally and in CI.
|
|
597
|
+
- Keep diffs minimal and focused.
|
|
598
|
+
- Include DNS module tests for any DNS-related functionality changes.
|
|
599
|
+
- Test browser builds to ensure async_hooks compatibility.
|
|
600
|
+
- Documentation:
|
|
601
|
+
- Update inline documentation and examples where relevant.
|
|
602
|
+
- Add test coverage for new DNS module functions following the existing test structure.
|
|
603
|
+
- Document any async_hooks-related changes in build configuration.
|
|
604
|
+
|
|
605
|
+
## Troubleshooting Guide
|
|
606
|
+
- Test environment setup:
|
|
607
|
+
- Ensure Node.js and dependencies are installed.
|
|
608
|
+
- Use NPM scripts to run tests; verify Mocha and Babel are available.
|
|
609
|
+
- Check webpack configuration for async_hooks shim settings.
|
|
610
|
+
- Mock data usage:
|
|
611
|
+
- Utilize provided fixtures (e.g., test-post.json) to validate API responses.
|
|
612
|
+
- For DNS testing, use the established test patterns and validation scenarios.
|
|
613
|
+
- Debugging test failures:
|
|
614
|
+
- Enable debug logging in the API client to inspect request/response timing and errors.
|
|
615
|
+
- Inspect browser test console for stack traces and error messages.
|
|
616
|
+
- Stub transports selectively to simulate network conditions in unit tests.
|
|
617
|
+
- Check for async_hooks-related errors in browser builds.
|
|
618
|
+
- DNS-specific debugging:
|
|
619
|
+
- Use the comprehensive validation functions to identify specific failure points.
|
|
620
|
+
- Test individual DNS helper functions in isolation to pinpoint issues.
|
|
621
|
+
- Leverage the extensive error messages in DNS validation functions.
|
|
622
|
+
- Async Hooks debugging:
|
|
623
|
+
- Verify that webpack configuration includes `node.async_hooks: 'empty'`.
|
|
624
|
+
- Check package.json browser field for async_hooks module disabling.
|
|
625
|
+
- Test browser builds to ensure async_hooks shim is working correctly.
|
|
626
|
+
|
|
627
|
+
**Section sources**
|
|
628
|
+
- [test/test_helper.js:1-19](file://test/test_helper.js#L1-L19)
|
|
629
|
+
- [test/test-post.json:1-14](file://test/test-post.json#L1-L14)
|
|
630
|
+
- [src/api/index.js:12-15](file://src/api/index.js#L12-L15)
|
|
631
|
+
- [test/browser/BrowserTests.js:10-22](file://test/browser/BrowserTests.js#L10-L22)
|
|
632
|
+
- [test/dns.test.js:1-396](file://test/dns.test.js#L1-L396)
|
|
633
|
+
- [webpack/makeConfig.js:76-78](file://webpack/makeConfig.js#L76-L78)
|
|
634
|
+
- [package.json:15-19](file://package.json#L15-L19)
|
|
635
|
+
|
|
636
|
+
## Conclusion
|
|
637
|
+
This guide consolidates testing and development practices for the VIZ JavaScript library, now enhanced with comprehensive DNS module testing and improved async_hooks module compatibility for browser environments. The enhanced webpack configuration with async_hooks shim (`node.async_hooks: 'empty'`) ensures seamless browser compatibility while maintaining Node.js functionality. By leveraging the existing Mocha-based Node tests, browser harness, and Webpack build pipeline with proper async_hooks handling, contributors can confidently add new features, fix bugs, and maintain high-quality code. The addition of over 300 lines of DNS module test coverage ensures robust validation of all helper functions, edge cases, and error conditions. Adhering to linting standards, using mock data, following the outlined workflows, and maintaining comprehensive test coverage ensures reliable and secure integrations with the VIZ blockchain and DNS functionality, while the async_hooks shim provides optimal browser compatibility.
|