mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2024-12-04 18:00:18 +00:00
Switching from AVM interpreter to AVM runner with background execution (#111)
This commit is contained in:
parent
4aefddecaa
commit
9d0c7b2bb8
5
.github/workflows/js_sdk_ci.yml
vendored
5
.github/workflows/js_sdk_ci.yml
vendored
@ -13,8 +13,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [14.x, 15.x]
|
||||
node-env: ['', ':node']
|
||||
node-version: [14.x, 15.x, 16.x, 17.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@ -37,6 +36,6 @@ jobs:
|
||||
docker run -d --rm -e RUST_LOG="info" -p 1210:1210 -p 4310:4310 fluencelabs/fluence -t 1210 -w 4310 -k gKdiCSUr1TFGFEgu2t8Ch1XEUsrN5A2UfBLjSZvfci9SPR3NvZpACfcpPGC3eY4zma1pk7UvYv5zb1VjvPHwCjj --local --aqua-pool-size 2
|
||||
|
||||
- run: npm install
|
||||
- run: npm run test${{ matrix.node-env }}:all
|
||||
- run: npm run test:all
|
||||
env:
|
||||
CI: true
|
||||
|
File diff suppressed because one or more lines are too long
@ -121,7 +121,7 @@
|
||||
<li class="tsd-description">
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/FluencePeer.ts#L140">internal/FluencePeer.ts:140</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/FluencePeer.ts#L138">internal/FluencePeer.ts:138</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
@ -146,7 +146,7 @@
|
||||
<li class="tsd-description">
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/FluencePeer.ts#L237">internal/FluencePeer.ts:237</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/FluencePeer.ts#L243">internal/FluencePeer.ts:243</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
@ -325,7 +325,7 @@
|
||||
<li class="tsd-description">
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/FluencePeer.ts#L158">internal/FluencePeer.ts:158</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/FluencePeer.ts#L156">internal/FluencePeer.ts:156</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
@ -347,7 +347,7 @@
|
||||
<li class="tsd-description">
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/FluencePeer.ts#L173">internal/FluencePeer.ts:173</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/FluencePeer.ts#L172">internal/FluencePeer.ts:172</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
@ -379,7 +379,7 @@
|
||||
<li class="tsd-description">
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/FluencePeer.ts#L222">internal/FluencePeer.ts:222</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/FluencePeer.ts#L225">internal/FluencePeer.ts:225</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
@ -402,7 +402,7 @@
|
||||
<li class="tsd-description">
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/FluencePeer.ts#L147">internal/FluencePeer.ts:147</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/FluencePeer.ts#L145">internal/FluencePeer.ts:145</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
|
@ -92,7 +92,9 @@
|
||||
<section class="tsd-index-section ">
|
||||
<h3>Methods</h3>
|
||||
<ul class="tsd-index-list">
|
||||
<li class="tsd-kind-method tsd-parent-kind-class"><a href="KeyPair.html#signBytes" class="tsd-kind-icon">sign<wbr>Bytes</a></li>
|
||||
<li class="tsd-kind-method tsd-parent-kind-class"><a href="KeyPair.html#toEd25519PrivateKey" class="tsd-kind-icon">to<wbr>Ed25519<wbr>Private<wbr>Key</a></li>
|
||||
<li class="tsd-kind-method tsd-parent-kind-class"><a href="KeyPair.html#verify" class="tsd-kind-icon">verify</a></li>
|
||||
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="KeyPair.html#fromEd25519SK" class="tsd-kind-icon">from<wbr>Ed25519SK</a></li>
|
||||
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="KeyPair.html#randomEd25519" class="tsd-kind-icon">random<wbr>Ed25519</a></li>
|
||||
</ul>
|
||||
@ -112,7 +114,7 @@
|
||||
<li class="tsd-description">
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/KeyPair.ts#L26">internal/KeyPair.ts:26</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/KeyPair.ts#L26">internal/KeyPair.ts:26</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<h4 class="tsd-parameters-title">Parameters</h4>
|
||||
@ -134,7 +136,7 @@
|
||||
<div class="tsd-signature tsd-kind-icon">Libp2p<wbr>Peer<wbr>Id<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">PeerId</span></div>
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/KeyPair.ts#L24">internal/KeyPair.ts:24</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/KeyPair.ts#L24">internal/KeyPair.ts:24</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
@ -146,6 +148,29 @@
|
||||
</section>
|
||||
<section class="tsd-panel-group tsd-member-group ">
|
||||
<h2>Methods</h2>
|
||||
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
|
||||
<a name="signBytes" class="tsd-anchor"></a>
|
||||
<h3>sign<wbr>Bytes</h3>
|
||||
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
|
||||
<li class="tsd-signature tsd-kind-icon">sign<wbr>Bytes<span class="tsd-signature-symbol">(</span>data<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Uint8Array</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">Uint8Array</span><span class="tsd-signature-symbol">></span></li>
|
||||
</ul>
|
||||
<ul class="tsd-descriptions">
|
||||
<li class="tsd-description">
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/KeyPair.ts#L58">internal/KeyPair.ts:58</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<h4 class="tsd-parameters-title">Parameters</h4>
|
||||
<ul class="tsd-parameters">
|
||||
<li>
|
||||
<h5>data: <span class="tsd-signature-type">Uint8Array</span></h5>
|
||||
</li>
|
||||
</ul>
|
||||
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">Uint8Array</span><span class="tsd-signature-symbol">></span></h4>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
|
||||
<a name="toEd25519PrivateKey" class="tsd-anchor"></a>
|
||||
<h3>to<wbr>Ed25519<wbr>Private<wbr>Key</h3>
|
||||
@ -156,7 +181,7 @@
|
||||
<li class="tsd-description">
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/KeyPair.ts#L54">internal/KeyPair.ts:54</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/KeyPair.ts#L54">internal/KeyPair.ts:54</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Uint8Array</span></h4>
|
||||
@ -164,6 +189,32 @@
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
|
||||
<a name="verify" class="tsd-anchor"></a>
|
||||
<h3>verify</h3>
|
||||
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
|
||||
<li class="tsd-signature tsd-kind-icon">verify<span class="tsd-signature-symbol">(</span>data<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Uint8Array</span>, signature<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Uint8Array</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">></span></li>
|
||||
</ul>
|
||||
<ul class="tsd-descriptions">
|
||||
<li class="tsd-description">
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/KeyPair.ts#L62">internal/KeyPair.ts:62</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<h4 class="tsd-parameters-title">Parameters</h4>
|
||||
<ul class="tsd-parameters">
|
||||
<li>
|
||||
<h5>data: <span class="tsd-signature-type">Uint8Array</span></h5>
|
||||
</li>
|
||||
<li>
|
||||
<h5>signature: <span class="tsd-signature-type">Uint8Array</span></h5>
|
||||
</li>
|
||||
</ul>
|
||||
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">></span></h4>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static">
|
||||
<a name="fromEd25519SK" class="tsd-anchor"></a>
|
||||
<h3><span class="tsd-flag ts-flagStatic">Static</span> from<wbr>Ed25519SK</h3>
|
||||
@ -174,7 +225,7 @@
|
||||
<li class="tsd-description">
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/KeyPair.ts#L35">internal/KeyPair.ts:35</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/KeyPair.ts#L35">internal/KeyPair.ts:35</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
@ -205,7 +256,7 @@
|
||||
<li class="tsd-description">
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/KeyPair.ts#L46">internal/KeyPair.ts:46</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/KeyPair.ts#L46">internal/KeyPair.ts:46</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
@ -246,9 +297,15 @@
|
||||
<li class=" tsd-kind-property tsd-parent-kind-class">
|
||||
<a href="KeyPair.html#Libp2pPeerId" class="tsd-kind-icon">Libp2p<wbr>Peer<wbr>Id</a>
|
||||
</li>
|
||||
<li class=" tsd-kind-method tsd-parent-kind-class">
|
||||
<a href="KeyPair.html#signBytes" class="tsd-kind-icon">sign<wbr>Bytes</a>
|
||||
</li>
|
||||
<li class=" tsd-kind-method tsd-parent-kind-class">
|
||||
<a href="KeyPair.html#toEd25519PrivateKey" class="tsd-kind-icon">to<wbr>Ed25519<wbr>Private<wbr>Key</a>
|
||||
</li>
|
||||
<li class=" tsd-kind-method tsd-parent-kind-class">
|
||||
<a href="KeyPair.html#verify" class="tsd-kind-icon">verify</a>
|
||||
</li>
|
||||
<li class=" tsd-kind-method tsd-parent-kind-class tsd-is-static">
|
||||
<a href="KeyPair.html#fromEd25519SK" class="tsd-kind-icon">from<wbr>Ed25519SK</a>
|
||||
</li>
|
||||
|
@ -118,7 +118,7 @@
|
||||
<div class="tsd-signature tsd-kind-icon">init<wbr>Peer<wbr>Id<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/commonTypes.ts#L37">internal/commonTypes.ts:37</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/commonTypes.ts#L37">internal/commonTypes.ts:37</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
@ -133,7 +133,7 @@
|
||||
<div class="tsd-signature tsd-kind-icon">particle<wbr>Id<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/commonTypes.ts#L32">internal/commonTypes.ts:32</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/commonTypes.ts#L32">internal/commonTypes.ts:32</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
@ -148,7 +148,7 @@
|
||||
<div class="tsd-signature tsd-kind-icon">signature<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/commonTypes.ts#L52">internal/commonTypes.ts:52</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/commonTypes.ts#L52">internal/commonTypes.ts:52</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
@ -163,7 +163,7 @@
|
||||
<div class="tsd-signature tsd-kind-icon">tetraplets<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{</span><span class="tsd-signature-symbol">[ </span><span class="tsd-signature-type">key</span><span class="tsd-signature-symbol"> in </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">SecurityTetraplet</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol"> }</span></div>
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/commonTypes.ts#L57">internal/commonTypes.ts:57</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/commonTypes.ts#L57">internal/commonTypes.ts:57</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
@ -178,7 +178,7 @@
|
||||
<div class="tsd-signature tsd-kind-icon">timestamp<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div>
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/commonTypes.ts#L42">internal/commonTypes.ts:42</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/commonTypes.ts#L42">internal/commonTypes.ts:42</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
@ -193,7 +193,7 @@
|
||||
<div class="tsd-signature tsd-kind-icon">ttl<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div>
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/commonTypes.ts#L47">internal/commonTypes.ts:47</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/commonTypes.ts#L47">internal/commonTypes.ts:47</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
|
@ -89,6 +89,7 @@
|
||||
<ul class="tsd-index-list">
|
||||
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="PeerConfig.html#KeyPair" class="tsd-kind-icon">Key<wbr>Pair</a></li>
|
||||
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="PeerConfig.html#avmLogLevel" class="tsd-kind-icon">avm<wbr>Log<wbr>Level</a></li>
|
||||
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="PeerConfig.html#avmRunner" class="tsd-kind-icon">avm<wbr>Runner</a></li>
|
||||
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="PeerConfig.html#checkConnectionTimeoutMs" class="tsd-kind-icon">check<wbr>Connection<wbr>Timeout<wbr>Ms</a></li>
|
||||
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="PeerConfig.html#connectTo" class="tsd-kind-icon">connect<wbr>To</a></li>
|
||||
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="PeerConfig.html#defaultTtlMs" class="tsd-kind-icon">default<wbr>Ttl<wbr>Ms</a></li>
|
||||
@ -107,7 +108,7 @@
|
||||
<div class="tsd-signature tsd-kind-icon">Key<wbr>Pair<span class="tsd-signature-symbol">:</span> <a href="../classes/KeyPair.html" class="tsd-signature-type" data-tsd-kind="Class">KeyPair</a></div>
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/FluencePeer.ts#L78">internal/FluencePeer.ts:78</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/FluencePeer.ts#L71">internal/FluencePeer.ts:71</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
@ -123,7 +124,7 @@
|
||||
<div class="tsd-signature tsd-kind-icon">avm<wbr>Log<wbr>Level<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">LogLevel</span></div>
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/FluencePeer.ts#L72">internal/FluencePeer.ts:72</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/FluencePeer.ts#L65">internal/FluencePeer.ts:65</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
@ -132,13 +133,28 @@
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
|
||||
<a name="avmRunner" class="tsd-anchor"></a>
|
||||
<h3><span class="tsd-flag ts-flagOptional">Optional</span> avm<wbr>Runner</h3>
|
||||
<div class="tsd-signature tsd-kind-icon">avm<wbr>Runner<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">AvmRunner</span></div>
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/FluencePeer.ts#L102">internal/FluencePeer.ts:102</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
<div class="lead">
|
||||
<p>Plugable AVM runner implementation. If not specified AvmBackgroundRunner will be used</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
|
||||
<a name="checkConnectionTimeoutMs" class="tsd-anchor"></a>
|
||||
<h3><span class="tsd-flag ts-flagOptional">Optional</span> check<wbr>Connection<wbr>Timeout<wbr>Ms</h3>
|
||||
<div class="tsd-signature tsd-kind-icon">check<wbr>Connection<wbr>Timeout<wbr>Ms<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div>
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/FluencePeer.ts#L85">internal/FluencePeer.ts:85</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/FluencePeer.ts#L78">internal/FluencePeer.ts:78</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
@ -155,7 +171,7 @@
|
||||
<div class="tsd-signature tsd-kind-icon">connect<wbr>To<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Multiaddr</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Node</span></div>
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/FluencePeer.ts#L67">internal/FluencePeer.ts:67</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/FluencePeer.ts#L60">internal/FluencePeer.ts:60</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
@ -177,7 +193,7 @@
|
||||
<div class="tsd-signature tsd-kind-icon">default<wbr>Ttl<wbr>Ms<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div>
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/FluencePeer.ts#L104">internal/FluencePeer.ts:104</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/FluencePeer.ts#L97">internal/FluencePeer.ts:97</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
@ -194,7 +210,7 @@
|
||||
<div class="tsd-signature tsd-kind-icon">dial<wbr>Timeout<wbr>Ms<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div>
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/FluencePeer.ts#L97">internal/FluencePeer.ts:97</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/FluencePeer.ts#L90">internal/FluencePeer.ts:90</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
@ -209,7 +225,7 @@
|
||||
<div class="tsd-signature tsd-kind-icon">skip<wbr>Check<wbr>Connection<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">boolean</span></div>
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/FluencePeer.ts#L92">internal/FluencePeer.ts:92</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/FluencePeer.ts#L85">internal/FluencePeer.ts:85</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
@ -252,6 +268,9 @@
|
||||
<li class=" tsd-kind-property tsd-parent-kind-interface">
|
||||
<a href="PeerConfig.html#avmLogLevel" class="tsd-kind-icon">avm<wbr>Log<wbr>Level</a>
|
||||
</li>
|
||||
<li class=" tsd-kind-property tsd-parent-kind-interface">
|
||||
<a href="PeerConfig.html#avmRunner" class="tsd-kind-icon">avm<wbr>Runner</a>
|
||||
</li>
|
||||
<li class=" tsd-kind-property tsd-parent-kind-interface">
|
||||
<a href="PeerConfig.html#checkConnectionTimeoutMs" class="tsd-kind-icon">check<wbr>Connection<wbr>Timeout<wbr>Ms</a>
|
||||
</li>
|
||||
|
@ -104,7 +104,7 @@
|
||||
<div class="tsd-signature tsd-kind-icon">is<wbr>Connected<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Boolean</span></div>
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/FluencePeer.ts#L119">internal/FluencePeer.ts:119</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/FluencePeer.ts#L117">internal/FluencePeer.ts:117</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
@ -119,7 +119,7 @@
|
||||
<div class="tsd-signature tsd-kind-icon">is<wbr>Initialized<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Boolean</span></div>
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/FluencePeer.ts#L114">internal/FluencePeer.ts:114</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/FluencePeer.ts#L112">internal/FluencePeer.ts:112</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
@ -134,7 +134,7 @@
|
||||
<div class="tsd-signature tsd-kind-icon">peer<wbr>Id<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/FluencePeer.ts#L124">internal/FluencePeer.ts:124</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/FluencePeer.ts#L122">internal/FluencePeer.ts:122</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
@ -149,7 +149,7 @@
|
||||
<div class="tsd-signature tsd-kind-icon">relay<wbr>Peer<wbr>Id<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/FluencePeer.ts#L129">internal/FluencePeer.ts:129</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/FluencePeer.ts#L127">internal/FluencePeer.ts:127</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
|
@ -106,7 +106,7 @@
|
||||
<div class="tsd-signature tsd-kind-icon">Avm<wbr>Loglevel<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">LogLevel</span></div>
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/FluencePeer.ts#L51">internal/FluencePeer.ts:51</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/FluencePeer.ts#L44">internal/FluencePeer.ts:44</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
@ -122,7 +122,7 @@
|
||||
<div class="tsd-signature tsd-kind-icon">Peer<wbr>IdB58<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/internal/commonTypes.ts#L22">internal/commonTypes.ts:22</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/internal/commonTypes.ts#L22">internal/commonTypes.ts:22</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
@ -140,7 +140,7 @@
|
||||
<div class="tsd-signature tsd-kind-icon">Fluence<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{ </span>getPeer<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><a href="classes/FluencePeer.html" class="tsd-signature-type" data-tsd-kind="Class">FluencePeer</a><span class="tsd-signature-symbol">; </span>getStatus<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><a href="interfaces/PeerStatus.html" class="tsd-signature-type" data-tsd-kind="Interface">PeerStatus</a><span class="tsd-signature-symbol">; </span>start<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">(</span>config<span class="tsd-signature-symbol">?: </span><a href="interfaces/PeerConfig.html" class="tsd-signature-type" data-tsd-kind="Interface">PeerConfig</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">; </span>stop<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol"> }</span><span class="tsd-signature-symbol"> = ...</span></div>
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/index.ts#L36">index.ts:36</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/index.ts#L36">index.ts:36</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
@ -260,7 +260,7 @@
|
||||
<li class="tsd-description">
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/7577170/src/index.ts#L25">index.ts:25</a></li>
|
||||
<li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/c3512fd/src/index.ts#L25">index.ts:25</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<h4 class="tsd-parameters-title">Parameters</h4>
|
||||
|
@ -1,14 +0,0 @@
|
||||
const Environment = require('jest-environment-jsdom');
|
||||
|
||||
module.exports = class CustomTestEnvironment extends Environment {
|
||||
async setup() {
|
||||
await super.setup();
|
||||
if (typeof this.global.TextEncoder === 'undefined') {
|
||||
const { TextEncoder, TextDecoder } = require('util');
|
||||
this.global.TextEncoder = TextEncoder;
|
||||
this.global.TextDecoder = TextDecoder;
|
||||
this.global.Uint8Array = Uint8Array;
|
||||
this.global.ArrayBuffer = ArrayBuffer;
|
||||
}
|
||||
}
|
||||
};
|
@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: './jest-patched-jsdom.js',
|
||||
testEnvironment: 'node',
|
||||
};
|
||||
|
157
package-lock.json
generated
157
package-lock.json
generated
@ -10,7 +10,9 @@
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@chainsafe/libp2p-noise": "4.0.0",
|
||||
"@fluencelabs/avm": "^0.19.3",
|
||||
"@fluencelabs/avm": "0.19.6",
|
||||
"@fluencelabs/avm-runner-background": "0.1.1",
|
||||
"@fluencelabs/avm-runner-interface": "^0.2.0",
|
||||
"async": "3.2.0",
|
||||
"bs58": "4.0.1",
|
||||
"cids": "0.8.1",
|
||||
@ -27,6 +29,9 @@
|
||||
"ts-pattern": "^3.3.3",
|
||||
"uuid": "8.3.0"
|
||||
},
|
||||
"bin": {
|
||||
"copy-avm-public": "dist/tools/copyAvmPublic"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^26.0.22",
|
||||
"jest": "^26.6.3",
|
||||
@ -646,13 +651,31 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@fluencelabs/avm": {
|
||||
"version": "0.19.3",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.19.3.tgz",
|
||||
"integrity": "sha512-KvrQrh41dpKzYzgbozmTykwD/E3me3Boiz7rC/zjs5xma738YibjymCV30ZXMfe3iNT5JlXsj3LJML6HlkjNfA==",
|
||||
"dependencies": {
|
||||
"base64-js": "1.5.1"
|
||||
"version": "0.19.6",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.19.6.tgz",
|
||||
"integrity": "sha512-T6UQsIuGVltf13Wc3bFmuCYmQzu/00Y4lPS7atBauQ2R4+BqhRg1dc5reSZ+MbAW3Vy+NmJY1EEYOFRpLCGBwg==",
|
||||
"bin": {
|
||||
"copy-avm": "dist/copyAvm.js"
|
||||
}
|
||||
},
|
||||
"node_modules/@fluencelabs/avm-runner-background": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/avm-runner-background/-/avm-runner-background-0.1.1.tgz",
|
||||
"integrity": "sha512-XUnw3eUakBDngLZMIhTUXIT3Oz6N+6aclo7p2YIvjRHqhUUnL5/VEZcbuxLdkdzMdSdbQE7C/btKNVTO2kWJBw==",
|
||||
"dependencies": {
|
||||
"@fluencelabs/avm-runner-interface": "^0.2.0",
|
||||
"browser-or-node": "^2.0.0",
|
||||
"threads": "^1.7.0"
|
||||
},
|
||||
"bin": {
|
||||
"copy-avm-runner": "dist/copyRunnerScript.js"
|
||||
}
|
||||
},
|
||||
"node_modules/@fluencelabs/avm-runner-interface": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/avm-runner-interface/-/avm-runner-interface-0.2.0.tgz",
|
||||
"integrity": "sha512-Y41pL+UwZZVdormxju8cJQsNRp6tdER0VqJ9Kg9gH2wd1KJAaYTJkyVbn8NB7fEFRUbqfbb1BXHi9wWBYOgGYQ=="
|
||||
},
|
||||
"node_modules/@istanbuljs/load-nyc-config": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",
|
||||
@ -1829,6 +1852,11 @@
|
||||
"resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz",
|
||||
"integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8="
|
||||
},
|
||||
"node_modules/browser-or-node": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/browser-or-node/-/browser-or-node-2.0.0.tgz",
|
||||
"integrity": "sha512-3Lrks/Okgof+/cRguUNG+qRXSeq79SO3hY4QrXJayJofwJwHiGC0qi99uDjsfTwULUFSr1OGVsBkdIkygKjTUA=="
|
||||
},
|
||||
"node_modules/browser-process-hrtime": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz",
|
||||
@ -1940,7 +1968,6 @@
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
|
||||
"integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
@ -2583,6 +2610,15 @@
|
||||
"source-map": "~0.6.1"
|
||||
}
|
||||
},
|
||||
"node_modules/esm": {
|
||||
"version": "3.2.25",
|
||||
"resolved": "https://registry.npmjs.org/esm/-/esm-3.2.25.tgz",
|
||||
"integrity": "sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==",
|
||||
"optional": true,
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/esprima": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
|
||||
@ -3687,6 +3723,17 @@
|
||||
"node": ">=0.12.0"
|
||||
}
|
||||
},
|
||||
"node_modules/is-observable": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/is-observable/-/is-observable-2.1.0.tgz",
|
||||
"integrity": "sha512-DailKdLb0WU+xX8K5w7VsJhapwHLZ9jjmazqCJq4X12CTgqq73TKnbRcnSLuXYPOoLQgV5IrD7ePiX/h1vnkBw==",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/is-plain-obj": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz",
|
||||
@ -5784,6 +5831,11 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/observable-fns": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/observable-fns/-/observable-fns-0.6.1.tgz",
|
||||
"integrity": "sha512-9gRK4+sRWzeN6AOewNBTLXir7Zl/i3GB6Yl26gK4flxz8BXVpD3kt8amREmWNb0mxYOGDotvE5a4N+PtGGKdkg=="
|
||||
},
|
||||
"node_modules/once": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
@ -7461,6 +7513,23 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/threads": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/threads/-/threads-1.7.0.tgz",
|
||||
"integrity": "sha512-Mx5NBSHX3sQYR6iI9VYbgHKBLisyB+xROCBGjjWm1O9wb9vfLxdaGtmT/KCjUqMsSNW6nERzCW3T6H43LqjDZQ==",
|
||||
"dependencies": {
|
||||
"callsites": "^3.1.0",
|
||||
"debug": "^4.2.0",
|
||||
"is-observable": "^2.1.0",
|
||||
"observable-fns": "^0.6.1"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/andywer/threads.js?sponsor=1"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"tiny-worker": ">= 2"
|
||||
}
|
||||
},
|
||||
"node_modules/throat": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/throat/-/throat-5.0.0.tgz",
|
||||
@ -7481,6 +7550,15 @@
|
||||
"resolved": "https://registry.npmjs.org/retimer/-/retimer-2.0.0.tgz",
|
||||
"integrity": "sha512-KLXY85WkEq2V2bKex/LOO1ViXVn2KGYe4PYysAdYdjmraYIUsVkXu8O4am+8+5UbaaGl1qho4aqAAPHNQ4GSbg=="
|
||||
},
|
||||
"node_modules/tiny-worker": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/tiny-worker/-/tiny-worker-2.3.0.tgz",
|
||||
"integrity": "sha512-pJ70wq5EAqTAEl9IkGzA+fN0836rycEuz2Cn6yeZ6FRzlVS5IDOkFHpIoEsksPRQV34GDqXm65+OlnZqUSyK2g==",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"esm": "^3.2.25"
|
||||
}
|
||||
},
|
||||
"node_modules/tmpl": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.4.tgz",
|
||||
@ -8693,13 +8771,25 @@
|
||||
}
|
||||
},
|
||||
"@fluencelabs/avm": {
|
||||
"version": "0.19.3",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.19.3.tgz",
|
||||
"integrity": "sha512-KvrQrh41dpKzYzgbozmTykwD/E3me3Boiz7rC/zjs5xma738YibjymCV30ZXMfe3iNT5JlXsj3LJML6HlkjNfA==",
|
||||
"version": "0.19.6",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.19.6.tgz",
|
||||
"integrity": "sha512-T6UQsIuGVltf13Wc3bFmuCYmQzu/00Y4lPS7atBauQ2R4+BqhRg1dc5reSZ+MbAW3Vy+NmJY1EEYOFRpLCGBwg=="
|
||||
},
|
||||
"@fluencelabs/avm-runner-background": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/avm-runner-background/-/avm-runner-background-0.1.1.tgz",
|
||||
"integrity": "sha512-XUnw3eUakBDngLZMIhTUXIT3Oz6N+6aclo7p2YIvjRHqhUUnL5/VEZcbuxLdkdzMdSdbQE7C/btKNVTO2kWJBw==",
|
||||
"requires": {
|
||||
"base64-js": "1.5.1"
|
||||
"@fluencelabs/avm-runner-interface": "^0.2.0",
|
||||
"browser-or-node": "^2.0.0",
|
||||
"threads": "^1.7.0"
|
||||
}
|
||||
},
|
||||
"@fluencelabs/avm-runner-interface": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/avm-runner-interface/-/avm-runner-interface-0.2.0.tgz",
|
||||
"integrity": "sha512-Y41pL+UwZZVdormxju8cJQsNRp6tdER0VqJ9Kg9gH2wd1KJAaYTJkyVbn8NB7fEFRUbqfbb1BXHi9wWBYOgGYQ=="
|
||||
},
|
||||
"@istanbuljs/load-nyc-config": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",
|
||||
@ -9702,6 +9792,11 @@
|
||||
"resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz",
|
||||
"integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8="
|
||||
},
|
||||
"browser-or-node": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/browser-or-node/-/browser-or-node-2.0.0.tgz",
|
||||
"integrity": "sha512-3Lrks/Okgof+/cRguUNG+qRXSeq79SO3hY4QrXJayJofwJwHiGC0qi99uDjsfTwULUFSr1OGVsBkdIkygKjTUA=="
|
||||
},
|
||||
"browser-process-hrtime": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz",
|
||||
@ -9782,8 +9877,7 @@
|
||||
"callsites": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
|
||||
"integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==",
|
||||
"dev": true
|
||||
"integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ=="
|
||||
},
|
||||
"camelcase": {
|
||||
"version": "5.3.1",
|
||||
@ -10289,6 +10383,12 @@
|
||||
"source-map": "~0.6.1"
|
||||
}
|
||||
},
|
||||
"esm": {
|
||||
"version": "3.2.25",
|
||||
"resolved": "https://registry.npmjs.org/esm/-/esm-3.2.25.tgz",
|
||||
"integrity": "sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==",
|
||||
"optional": true
|
||||
},
|
||||
"esprima": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
|
||||
@ -11142,6 +11242,11 @@
|
||||
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
|
||||
"dev": true
|
||||
},
|
||||
"is-observable": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/is-observable/-/is-observable-2.1.0.tgz",
|
||||
"integrity": "sha512-DailKdLb0WU+xX8K5w7VsJhapwHLZ9jjmazqCJq4X12CTgqq73TKnbRcnSLuXYPOoLQgV5IrD7ePiX/h1vnkBw=="
|
||||
},
|
||||
"is-plain-obj": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz",
|
||||
@ -12855,6 +12960,11 @@
|
||||
"isobject": "^3.0.1"
|
||||
}
|
||||
},
|
||||
"observable-fns": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/observable-fns/-/observable-fns-0.6.1.tgz",
|
||||
"integrity": "sha512-9gRK4+sRWzeN6AOewNBTLXir7Zl/i3GB6Yl26gK4flxz8BXVpD3kt8amREmWNb0mxYOGDotvE5a4N+PtGGKdkg=="
|
||||
},
|
||||
"once": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
@ -14176,6 +14286,18 @@
|
||||
"minimatch": "^3.0.4"
|
||||
}
|
||||
},
|
||||
"threads": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/threads/-/threads-1.7.0.tgz",
|
||||
"integrity": "sha512-Mx5NBSHX3sQYR6iI9VYbgHKBLisyB+xROCBGjjWm1O9wb9vfLxdaGtmT/KCjUqMsSNW6nERzCW3T6H43LqjDZQ==",
|
||||
"requires": {
|
||||
"callsites": "^3.1.0",
|
||||
"debug": "^4.2.0",
|
||||
"is-observable": "^2.1.0",
|
||||
"observable-fns": "^0.6.1",
|
||||
"tiny-worker": ">= 2"
|
||||
}
|
||||
},
|
||||
"throat": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/throat/-/throat-5.0.0.tgz",
|
||||
@ -14198,6 +14320,15 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"tiny-worker": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/tiny-worker/-/tiny-worker-2.3.0.tgz",
|
||||
"integrity": "sha512-pJ70wq5EAqTAEl9IkGzA+fN0836rycEuz2Cn6yeZ6FRzlVS5IDOkFHpIoEsksPRQV34GDqXm65+OlnZqUSyK2g==",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"esm": "^3.2.25"
|
||||
}
|
||||
},
|
||||
"tmpl": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.4.tgz",
|
||||
|
11
package.json
11
package.json
@ -9,19 +9,20 @@
|
||||
"test:all": "jest",
|
||||
"test:unit": "jest --testPathPattern=src/__test__/unit",
|
||||
"test:integration": "jest --testPathPattern=src/__test__/integration",
|
||||
"test:node": "jest --env=node --watch",
|
||||
"test:node:all": "jest --env=node",
|
||||
"test:node:unit": "jest --env=node --testPathPattern=src/__test__/unit",
|
||||
"test:node:integration": "jest --env=node --testPathPattern=src/__test__/integration",
|
||||
"build": "tsc",
|
||||
"build:docs": "typedoc"
|
||||
},
|
||||
"repository": "https://github.com/fluencelabs/fluence-js",
|
||||
"author": "Fluence Labs",
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"copy-avm-public": "dist/tools/copyAvmPublic.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@chainsafe/libp2p-noise": "4.0.0",
|
||||
"@fluencelabs/avm": "^0.19.3",
|
||||
"@fluencelabs/avm-runner-background": "0.1.1",
|
||||
"@fluencelabs/avm": "0.19.6",
|
||||
"@fluencelabs/avm-runner-interface": "^0.2.0",
|
||||
"async": "3.2.0",
|
||||
"bs58": "4.0.1",
|
||||
"cids": "0.8.1",
|
||||
|
@ -3,10 +3,21 @@ import { Particle } from '../../internal/Particle';
|
||||
import { handleTimeout } from '../../internal/utils';
|
||||
import { registerHandlersHelper } from '../util';
|
||||
|
||||
let peer: FluencePeer;
|
||||
|
||||
describe('Avm spec', () => {
|
||||
afterEach(async () => {
|
||||
if (peer) {
|
||||
await peer.stop();
|
||||
}
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
peer = new FluencePeer();
|
||||
});
|
||||
|
||||
it('Simple call', async () => {
|
||||
// arrange
|
||||
const peer = new FluencePeer();
|
||||
await peer.start();
|
||||
|
||||
// act
|
||||
@ -36,7 +47,6 @@ describe('Avm spec', () => {
|
||||
|
||||
it('Par call', async () => {
|
||||
// arrange
|
||||
const peer = new FluencePeer();
|
||||
await peer.start();
|
||||
|
||||
// act
|
||||
@ -75,7 +85,6 @@ describe('Avm spec', () => {
|
||||
|
||||
it('Timeout in par call: race', async () => {
|
||||
// arrange
|
||||
const peer = new FluencePeer();
|
||||
await peer.start();
|
||||
|
||||
// act
|
||||
@ -113,7 +122,6 @@ describe('Avm spec', () => {
|
||||
|
||||
it('Timeout in par call: wait', async () => {
|
||||
// arrange
|
||||
const peer = new FluencePeer();
|
||||
await peer.start();
|
||||
|
||||
// act
|
||||
|
@ -205,5 +205,7 @@ describe('Compiler support infrastructure tests', () => {
|
||||
|
||||
// assert
|
||||
await expect(action).rejects.toMatch(/incorrect air script/);
|
||||
|
||||
await anotherPeer.stop();
|
||||
});
|
||||
});
|
||||
|
@ -5,15 +5,19 @@ import { checkConnection, doNothing, handleTimeout } from '../../internal/utils'
|
||||
import { Particle } from '../../internal/Particle';
|
||||
import { registerHandlersHelper } from '../util';
|
||||
|
||||
const anotherPeer = new FluencePeer();
|
||||
let peer;
|
||||
|
||||
describe('Typescript usage suite', () => {
|
||||
afterEach(async () => {
|
||||
if (anotherPeer) {
|
||||
await anotherPeer.stop();
|
||||
if (peer) {
|
||||
await peer.stop();
|
||||
}
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
peer = new FluencePeer();
|
||||
});
|
||||
|
||||
it('should perform test for FluencePeer class correctly', () => {
|
||||
// arrange
|
||||
const peer: any = new FluencePeer();
|
||||
@ -37,10 +41,10 @@ describe('Typescript usage suite', () => {
|
||||
describe('Should expose correct peer status', () => {
|
||||
it('Should expose correct status for uninitialized peer', () => {
|
||||
// arrange
|
||||
const peer = new FluencePeer();
|
||||
const nonStartedPeer = new FluencePeer();
|
||||
|
||||
// act
|
||||
const status = peer.getStatus();
|
||||
const status = nonStartedPeer.getStatus();
|
||||
|
||||
// assert
|
||||
expect(status.isConnected).toBe(false);
|
||||
@ -51,7 +55,6 @@ describe('Typescript usage suite', () => {
|
||||
|
||||
it('Should expose correct status for initialized but not connected peer', async () => {
|
||||
// arrange
|
||||
const peer = new FluencePeer();
|
||||
await peer.start();
|
||||
|
||||
// act
|
||||
@ -68,7 +71,6 @@ describe('Typescript usage suite', () => {
|
||||
|
||||
it('Should expose correct status for connected peer', async () => {
|
||||
// arrange
|
||||
const peer = new FluencePeer();
|
||||
await peer.start({ connectTo: nodes[0] });
|
||||
|
||||
// act
|
||||
@ -86,7 +88,7 @@ describe('Typescript usage suite', () => {
|
||||
|
||||
it('should make a call through network', async () => {
|
||||
// arrange
|
||||
await anotherPeer.start({ connectTo: nodes[0] });
|
||||
await peer.start({ connectTo: nodes[0] });
|
||||
|
||||
// act
|
||||
const promise = new Promise<string[]>((resolve, reject) => {
|
||||
@ -105,10 +107,10 @@ describe('Typescript usage suite', () => {
|
||||
)
|
||||
)`;
|
||||
const particle = Particle.createNew(script);
|
||||
registerHandlersHelper(anotherPeer, particle, {
|
||||
registerHandlersHelper(peer, particle, {
|
||||
load: {
|
||||
relay: (args) => {
|
||||
return anotherPeer.getStatus().relayPeerId;
|
||||
return peer.getStatus().relayPeerId;
|
||||
},
|
||||
},
|
||||
callback: {
|
||||
@ -123,7 +125,7 @@ describe('Typescript usage suite', () => {
|
||||
},
|
||||
});
|
||||
|
||||
anotherPeer.internals.initiateParticle(particle, handleTimeout(reject));
|
||||
peer.internals.initiateParticle(particle, handleTimeout(reject));
|
||||
});
|
||||
|
||||
// assert
|
||||
@ -132,17 +134,17 @@ describe('Typescript usage suite', () => {
|
||||
});
|
||||
|
||||
it('check connection should work', async function () {
|
||||
await anotherPeer.start({ connectTo: nodes[0] });
|
||||
await peer.start({ connectTo: nodes[0] });
|
||||
|
||||
let isConnected = await checkConnection(anotherPeer);
|
||||
let isConnected = await checkConnection(peer);
|
||||
|
||||
expect(isConnected).toEqual(true);
|
||||
});
|
||||
|
||||
it('check connection should work with ttl', async function () {
|
||||
await anotherPeer.start({ connectTo: nodes[0] });
|
||||
await peer.start({ connectTo: nodes[0] });
|
||||
|
||||
let isConnected = await checkConnection(anotherPeer, 10000);
|
||||
let isConnected = await checkConnection(peer, 10000);
|
||||
|
||||
expect(isConnected).toEqual(true);
|
||||
});
|
||||
@ -184,8 +186,8 @@ describe('Typescript usage suite', () => {
|
||||
const addr = nodes[0];
|
||||
|
||||
// act
|
||||
await anotherPeer.start({ connectTo: addr });
|
||||
const isConnected = await checkConnection(anotherPeer);
|
||||
await peer.start({ connectTo: addr });
|
||||
const isConnected = await checkConnection(peer);
|
||||
|
||||
// assert
|
||||
expect(isConnected).toBeTruthy();
|
||||
@ -196,8 +198,8 @@ describe('Typescript usage suite', () => {
|
||||
const addr = new Multiaddr(nodes[0].multiaddr);
|
||||
|
||||
// act
|
||||
await anotherPeer.start({ connectTo: addr });
|
||||
const isConnected = await checkConnection(anotherPeer);
|
||||
await peer.start({ connectTo: addr });
|
||||
const isConnected = await checkConnection(peer);
|
||||
|
||||
// assert
|
||||
expect(isConnected).toBeTruthy();
|
||||
@ -208,8 +210,8 @@ describe('Typescript usage suite', () => {
|
||||
const addr = nodes[0];
|
||||
|
||||
// act
|
||||
await anotherPeer.start({ connectTo: addr });
|
||||
const isConnected = await checkConnection(anotherPeer);
|
||||
await peer.start({ connectTo: addr });
|
||||
const isConnected = await checkConnection(peer);
|
||||
|
||||
// assert
|
||||
expect(isConnected).toBeTruthy();
|
||||
@ -220,8 +222,8 @@ describe('Typescript usage suite', () => {
|
||||
const addr = nodes[0];
|
||||
|
||||
// act
|
||||
await anotherPeer.start({ connectTo: addr });
|
||||
const isConnected = await checkConnection(anotherPeer);
|
||||
await peer.start({ connectTo: addr });
|
||||
const isConnected = await checkConnection(peer);
|
||||
|
||||
// assert
|
||||
expect(isConnected).toBeTruthy();
|
||||
@ -232,8 +234,8 @@ describe('Typescript usage suite', () => {
|
||||
const addr = nodes[0];
|
||||
|
||||
// act
|
||||
await anotherPeer.start({ connectTo: addr });
|
||||
const isConnected = await checkConnection(anotherPeer);
|
||||
await peer.start({ connectTo: addr });
|
||||
const isConnected = await checkConnection(peer);
|
||||
|
||||
// assert
|
||||
expect(isConnected).toBeTruthy();
|
||||
@ -244,8 +246,8 @@ describe('Typescript usage suite', () => {
|
||||
const addr = nodes[0];
|
||||
|
||||
// act
|
||||
await anotherPeer.start({ connectTo: addr, dialTimeoutMs: 100000 });
|
||||
const isConnected = await checkConnection(anotherPeer);
|
||||
await peer.start({ connectTo: addr, dialTimeoutMs: 100000 });
|
||||
const isConnected = await checkConnection(peer);
|
||||
|
||||
// assert
|
||||
expect(isConnected).toBeTruthy();
|
||||
@ -256,8 +258,8 @@ describe('Typescript usage suite', () => {
|
||||
const addr = nodes[0];
|
||||
|
||||
// act
|
||||
await anotherPeer.start({ connectTo: addr, skipCheckConnection: true });
|
||||
const isConnected = await checkConnection(anotherPeer);
|
||||
await peer.start({ connectTo: addr, skipCheckConnection: true });
|
||||
const isConnected = await checkConnection(peer);
|
||||
|
||||
// assert
|
||||
expect(isConnected).toBeTruthy();
|
||||
@ -268,8 +270,8 @@ describe('Typescript usage suite', () => {
|
||||
const addr = nodes[0];
|
||||
|
||||
// act
|
||||
await anotherPeer.start({ connectTo: addr, checkConnectionTimeoutMs: 1000 });
|
||||
const isConnected = await checkConnection(anotherPeer);
|
||||
await peer.start({ connectTo: addr, checkConnectionTimeoutMs: 1000 });
|
||||
const isConnected = await checkConnection(peer);
|
||||
|
||||
// assert
|
||||
expect(isConnected).toBeTruthy();
|
||||
@ -280,8 +282,8 @@ describe('Typescript usage suite', () => {
|
||||
const addr = nodes[0];
|
||||
|
||||
// act
|
||||
await anotherPeer.start({ connectTo: addr, defaultTtlMs: 1 });
|
||||
const isConnected = await checkConnection(anotherPeer);
|
||||
await peer.start({ connectTo: addr, defaultTtlMs: 1 });
|
||||
const isConnected = await checkConnection(peer);
|
||||
|
||||
// assert
|
||||
expect(isConnected).toBeFalsy();
|
||||
@ -290,7 +292,7 @@ describe('Typescript usage suite', () => {
|
||||
|
||||
it('Should successfully call identity on local peer', async function () {
|
||||
// arrange
|
||||
await anotherPeer.start();
|
||||
await peer.start();
|
||||
|
||||
// act
|
||||
const promise = new Promise<string>((resolve, reject) => {
|
||||
@ -301,7 +303,7 @@ describe('Typescript usage suite', () => {
|
||||
)
|
||||
`;
|
||||
const particle = Particle.createNew(script);
|
||||
registerHandlersHelper(anotherPeer, particle, {
|
||||
registerHandlersHelper(peer, particle, {
|
||||
callback: {
|
||||
callback: async (args) => {
|
||||
const [res] = args;
|
||||
@ -310,7 +312,7 @@ describe('Typescript usage suite', () => {
|
||||
},
|
||||
});
|
||||
|
||||
anotherPeer.internals.initiateParticle(particle, handleTimeout(reject));
|
||||
peer.internals.initiateParticle(particle, handleTimeout(reject));
|
||||
});
|
||||
|
||||
// assert
|
||||
@ -320,23 +322,25 @@ describe('Typescript usage suite', () => {
|
||||
|
||||
it('Should throw correct message when calling non existing local service', async function () {
|
||||
// arrange
|
||||
await anotherPeer.start({ connectTo: nodes[0] });
|
||||
await peer.start({ connectTo: nodes[0] });
|
||||
|
||||
// act
|
||||
const res = callIncorrectService(anotherPeer);
|
||||
const res = callIncorrectService(peer);
|
||||
|
||||
// console.log(await res);
|
||||
|
||||
// assert
|
||||
await expect(res).rejects.toMatchObject({
|
||||
msg: expect.stringContaining(
|
||||
`No handler has been registered for serviceId='incorrect' fnName='incorrect' args=''\"'`,
|
||||
message: expect.stringContaining(
|
||||
`No handler has been registered for serviceId='incorrect' fnName='incorrect' args='[]'\"'`,
|
||||
),
|
||||
instruction: 'call %init_peer_id% ("incorrect" "incorrect") [] res',
|
||||
// instruction: 'call %init_peer_id% ("incorrect" "incorrect") [] res',
|
||||
});
|
||||
});
|
||||
|
||||
it('Should not crash if undefined is passed as a variable', async () => {
|
||||
// arrange;
|
||||
await anotherPeer.start();
|
||||
await peer.start();
|
||||
|
||||
// act
|
||||
const promise = new Promise<any>((resolve, reject) => {
|
||||
@ -350,7 +354,7 @@ describe('Typescript usage suite', () => {
|
||||
)`;
|
||||
const particle = Particle.createNew(script);
|
||||
|
||||
registerHandlersHelper(anotherPeer, particle, {
|
||||
registerHandlersHelper(peer, particle, {
|
||||
load: {
|
||||
arg: (args) => {
|
||||
return undefined;
|
||||
@ -368,7 +372,7 @@ describe('Typescript usage suite', () => {
|
||||
},
|
||||
});
|
||||
|
||||
anotherPeer.internals.initiateParticle(particle, handleTimeout(reject));
|
||||
peer.internals.initiateParticle(particle, handleTimeout(reject));
|
||||
});
|
||||
|
||||
// assert
|
||||
@ -378,7 +382,7 @@ describe('Typescript usage suite', () => {
|
||||
|
||||
it('Should not crash if an error ocurred in user-defined handler', async () => {
|
||||
// arrange;
|
||||
await anotherPeer.start();
|
||||
await peer.start();
|
||||
|
||||
// act
|
||||
const promise = new Promise<any>((resolve, reject) => {
|
||||
@ -389,7 +393,7 @@ describe('Typescript usage suite', () => {
|
||||
)`;
|
||||
const particle = Particle.createNew(script);
|
||||
|
||||
registerHandlersHelper(anotherPeer, particle, {
|
||||
registerHandlersHelper(peer, particle, {
|
||||
load: {
|
||||
arg: (args) => {
|
||||
throw 'my super custom error message';
|
||||
@ -403,12 +407,12 @@ describe('Typescript usage suite', () => {
|
||||
},
|
||||
});
|
||||
|
||||
anotherPeer.internals.initiateParticle(particle, handleTimeout(reject));
|
||||
peer.internals.initiateParticle(particle, handleTimeout(reject));
|
||||
});
|
||||
|
||||
// assert
|
||||
await expect(promise).rejects.toMatchObject({
|
||||
msg: expect.stringContaining('my super custom error message'),
|
||||
message: expect.stringContaining('my super custom error message'),
|
||||
});
|
||||
});
|
||||
|
||||
@ -430,7 +434,7 @@ describe('Typescript usage suite', () => {
|
||||
|
||||
it.skip('Should throw correct error when the client tries to send a particle not to the relay', async () => {
|
||||
// arrange;
|
||||
await anotherPeer.start({ connectTo: nodes[0] });
|
||||
await peer.start({ connectTo: nodes[0] });
|
||||
|
||||
// act
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
@ -441,7 +445,7 @@ describe('Typescript usage suite', () => {
|
||||
)`;
|
||||
const particle = Particle.createNew(script);
|
||||
|
||||
registerHandlersHelper(anotherPeer, particle, {
|
||||
registerHandlersHelper(peer, particle, {
|
||||
callback: {
|
||||
error: (args) => {
|
||||
const [error] = args;
|
||||
@ -450,7 +454,7 @@ describe('Typescript usage suite', () => {
|
||||
},
|
||||
});
|
||||
|
||||
anotherPeer.internals.initiateParticle(particle, doNothing);
|
||||
peer.internals.initiateParticle(particle, doNothing);
|
||||
});
|
||||
|
||||
// assert
|
||||
|
@ -14,14 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
AirInterpreter,
|
||||
CallRequestsArray,
|
||||
CallResultsArray,
|
||||
InterpreterResult,
|
||||
LogLevel,
|
||||
CallServiceResult as AvmCallServiceResult,
|
||||
} from '@fluencelabs/avm';
|
||||
import { Multiaddr } from 'multiaddr';
|
||||
import { CallServiceData, CallServiceResult, GenericCallServiceHandler, ResultCodes } from './commonTypes';
|
||||
import { CallServiceHandler as LegacyCallServiceHandler } from './compilerSupport/LegacyCallServiceHandler';
|
||||
@ -29,12 +21,13 @@ import { PeerIdB58 } from './commonTypes';
|
||||
import { FluenceConnection } from './FluenceConnection';
|
||||
import { Particle, ParticleExecutionStage, ParticleQueueItem } from './Particle';
|
||||
import { KeyPair } from './KeyPair';
|
||||
import { createInterpreter, dataToString } from './utils';
|
||||
import { filter, pipe, Subject, tap } from 'rxjs';
|
||||
import { dataToString, jsonify } from './utils';
|
||||
import { concatMap, filter, pipe, Subject, tap } from 'rxjs';
|
||||
import { RequestFlow } from './compilerSupport/v1';
|
||||
import log from 'loglevel';
|
||||
import { BuiltInServiceContext, builtInServices } from './builtInServices';
|
||||
import { instanceOf } from 'ts-pattern';
|
||||
import { AvmRunner, InterpreterResult, LogLevel } from '@fluencelabs/avm-runner-interface';
|
||||
import { AvmRunnerBackground } from '@fluencelabs/avm-runner-background';
|
||||
|
||||
/**
|
||||
* Node of the Fluence network specified as a pair of node's multiaddr and it's peer id
|
||||
@ -102,6 +95,11 @@ export interface PeerConfig {
|
||||
* If the option is not set default TTL will be 7000
|
||||
*/
|
||||
defaultTtlMs?: number;
|
||||
|
||||
/**
|
||||
* Plugable AVM runner implementation. If not specified AvmBackgroundRunner will be used
|
||||
*/
|
||||
avmRunner?: AvmRunner;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -158,6 +156,7 @@ export class FluencePeer {
|
||||
getStatus(): PeerStatus {
|
||||
const hasKeyPair = this._keyPair !== undefined;
|
||||
return {
|
||||
// TODO:: use explicit mechanism for peer's state
|
||||
isInitialized: hasKeyPair,
|
||||
isConnected: this._connection !== undefined,
|
||||
peerId: this._keyPair?.Libp2pPeerId?.toB58String() || null,
|
||||
@ -182,7 +181,8 @@ export class FluencePeer {
|
||||
? config?.defaultTtlMs
|
||||
: DEFAULT_TTL;
|
||||
|
||||
this._interpreter = await createInterpreter(config?.avmLogLevel || 'off');
|
||||
this._avmRunner = config?.avmRunner || new AvmRunnerBackground();
|
||||
await this._avmRunner.init(config?.avmLogLevel || 'off');
|
||||
|
||||
if (config?.connectTo) {
|
||||
let connectToMultiAddr: Multiaddr;
|
||||
@ -223,9 +223,12 @@ export class FluencePeer {
|
||||
* and disconnects from the Fluence network
|
||||
*/
|
||||
async stop() {
|
||||
this._keyPair = undefined; // This will set peer to non-initialized state and stop particle processing
|
||||
this._relayPeerId = null;
|
||||
this._stopParticleProcessing();
|
||||
await this._disconnect();
|
||||
this._relayPeerId = null;
|
||||
await this._avmRunner?.terminate();
|
||||
this._avmRunner = undefined;
|
||||
this._legacyCallServiceHandler = null;
|
||||
|
||||
this._particleSpecificHandlers.clear();
|
||||
@ -361,7 +364,7 @@ export class FluencePeer {
|
||||
private _relayPeerId: PeerIdB58 | null = null;
|
||||
private _keyPair: KeyPair;
|
||||
private _connection: FluenceConnection;
|
||||
private _interpreter: AirInterpreter;
|
||||
private _avmRunner: AvmRunner;
|
||||
private _timeouts: Array<NodeJS.Timeout> = [];
|
||||
private _particleQueues = new Map<string, Subject<ParticleQueueItem>>();
|
||||
|
||||
@ -392,6 +395,11 @@ export class FluencePeer {
|
||||
});
|
||||
|
||||
this._outgoingParticles.subscribe(async (item) => {
|
||||
// Do not send particle after the peer has been stopped
|
||||
if (!this.getStatus().isInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this._connection) {
|
||||
item.particle.logTo('error', 'cannot send particle, peer is not connected');
|
||||
item.onStageChange({ stage: 'sendingError' });
|
||||
@ -422,14 +430,43 @@ export class FluencePeer {
|
||||
.pipe(
|
||||
// force new line
|
||||
filterExpiredParticles(this._expireParticle.bind(this)),
|
||||
|
||||
concatMap(async (item) => {
|
||||
// Is `.stop()` was called we need to stop particle processing immediately
|
||||
if (!this.getStatus().isInitialized) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// IMPORTANT!
|
||||
// AVM runner execution and prevData <-> newData swapping
|
||||
// MUST happen sequentially (in a critical section).
|
||||
// Otherwise the race between runner might occur corrupting the prevData
|
||||
|
||||
const result = await runAvmRunner(
|
||||
this.getStatus().peerId,
|
||||
this._avmRunner,
|
||||
item.particle,
|
||||
prevData,
|
||||
);
|
||||
const newData = Buffer.from(result.data);
|
||||
prevData = newData;
|
||||
|
||||
return {
|
||||
...item,
|
||||
result: result,
|
||||
newData: newData,
|
||||
};
|
||||
}),
|
||||
)
|
||||
.subscribe((item) => {
|
||||
const particle = item.particle;
|
||||
const result = runInterpreter(this.getStatus().peerId, this._interpreter, particle, prevData);
|
||||
.subscribe(async (item) => {
|
||||
// Is `.stop()` was called we need to stop particle processing immediately
|
||||
if (!this.getStatus().isInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Do not continue if there was an error in particle interpretation
|
||||
if (!isInterpretationSuccessful(result)) {
|
||||
item.onStageChange({ stage: 'interpreterError', errorMessage: result.errorMessage });
|
||||
if (!isInterpretationSuccessful(item.result)) {
|
||||
item.onStageChange({ stage: 'interpreterError', errorMessage: item.result.errorMessage });
|
||||
return;
|
||||
}
|
||||
|
||||
@ -437,26 +474,23 @@ export class FluencePeer {
|
||||
item.onStageChange({ stage: 'interpreted' });
|
||||
}, 0);
|
||||
|
||||
const newData = Buffer.from(result.data);
|
||||
prevData = newData;
|
||||
|
||||
// send particle further if requested
|
||||
if (result.nextPeerPks.length > 0) {
|
||||
const newParticle = particle.clone();
|
||||
newParticle.data = newData;
|
||||
if (item.result.nextPeerPks.length > 0) {
|
||||
const newParticle = item.particle.clone();
|
||||
newParticle.data = item.newData;
|
||||
this._outgoingParticles.next({ ...item, particle: newParticle });
|
||||
}
|
||||
|
||||
// execute call requests if needed
|
||||
// and put particle with the results back to queue
|
||||
if (result.callRequests.length > 0) {
|
||||
for (let [key, cr] of result.callRequests) {
|
||||
if (item.result.callRequests.length > 0) {
|
||||
for (let [key, cr] of item.result.callRequests) {
|
||||
const req = {
|
||||
fnName: cr.functionName,
|
||||
args: cr.arguments,
|
||||
serviceId: cr.serviceId,
|
||||
tetraplets: cr.tetraplets,
|
||||
particleContext: particle.getParticleContext(),
|
||||
particleContext: item.particle.getParticleContext(),
|
||||
};
|
||||
|
||||
this._execSingleCallRequest(req)
|
||||
@ -470,11 +504,11 @@ export class FluencePeer {
|
||||
)
|
||||
.then((res) => {
|
||||
const serviceResult = {
|
||||
result: JSON.stringify(res.result),
|
||||
result: jsonify(res.result),
|
||||
retCode: res.retCode,
|
||||
};
|
||||
|
||||
const newParticle = particle.clone();
|
||||
const newParticle = item.particle.clone();
|
||||
newParticle.callResults = [[key, serviceResult]];
|
||||
newParticle.data = Buffer.from([]);
|
||||
|
||||
@ -490,7 +524,7 @@ export class FluencePeer {
|
||||
}
|
||||
|
||||
private async _execSingleCallRequest(req: CallServiceData): Promise<CallServiceResult> {
|
||||
log.debug('executing call service handler', req);
|
||||
log.debug('executing call service handler', jsonify(req));
|
||||
const particleId = req.particleContext.particleId;
|
||||
|
||||
// trying particle-specific handler
|
||||
@ -533,7 +567,9 @@ export class FluencePeer {
|
||||
? await handler(req)
|
||||
: {
|
||||
retCode: ResultCodes.error,
|
||||
result: `No handler has been registered for serviceId='${req.serviceId}' fnName='${req.fnName}' args='${req.args}'`,
|
||||
result: `No handler has been registered for serviceId='${req.serviceId}' fnName='${
|
||||
req.fnName
|
||||
}' args='${jsonify(req.args)}'`,
|
||||
};
|
||||
}
|
||||
|
||||
@ -541,7 +577,7 @@ export class FluencePeer {
|
||||
res.result = null;
|
||||
}
|
||||
|
||||
log.debug('executed call service handler, req and res are: ', req, res);
|
||||
log.debug('executed call service handler, req and res are: ', jsonify(req), jsonify(res));
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -589,16 +625,15 @@ function registerDefaultServices(peer: FluencePeer, context: BuiltInServiceConte
|
||||
}
|
||||
}
|
||||
|
||||
function runInterpreter(
|
||||
async function runAvmRunner(
|
||||
currentPeerId: PeerIdB58,
|
||||
interpreter: AirInterpreter,
|
||||
runner: AvmRunner,
|
||||
particle: Particle,
|
||||
prevData: Uint8Array,
|
||||
): InterpreterResult {
|
||||
): Promise<InterpreterResult> {
|
||||
particle.logTo('debug', 'Sending particle to interpreter');
|
||||
log.debug('prevData: ', dataToString(prevData));
|
||||
log.debug('data: ', dataToString(particle.data));
|
||||
const interpreterResult = interpreter.invoke(
|
||||
const interpreterResult = await runner.run(
|
||||
particle.script,
|
||||
prevData,
|
||||
particle.data,
|
||||
@ -613,9 +648,9 @@ function runInterpreter(
|
||||
toLog.data = dataToString(toLog.data);
|
||||
|
||||
if (isInterpretationSuccessful(interpreterResult)) {
|
||||
log.debug('Interpreter result: ', toLog);
|
||||
log.debug('Interpreter result: ', jsonify(toLog));
|
||||
} else {
|
||||
log.error('Interpreter failed: ', toLog);
|
||||
log.error('Interpreter failed: ', jsonify(toLog));
|
||||
}
|
||||
return interpreterResult;
|
||||
}
|
||||
|
@ -16,10 +16,10 @@
|
||||
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { fromByteArray, toByteArray } from 'base64-js';
|
||||
import { CallResultsArray, LogLevel } from '@fluencelabs/avm';
|
||||
import { CallResultsArray, LogLevel } from '@fluencelabs/avm-runner-interface';
|
||||
import log from 'loglevel';
|
||||
import { ParticleContext } from './commonTypes';
|
||||
import { dataToString } from './utils';
|
||||
import { dataToString, jsonify } from './utils';
|
||||
|
||||
export class Particle {
|
||||
id: string;
|
||||
@ -119,7 +119,7 @@ export class Particle {
|
||||
fn = log.info;
|
||||
break;
|
||||
case 'trace':
|
||||
fn = log.trace;
|
||||
fn = log.info;
|
||||
break;
|
||||
case 'warn':
|
||||
fn = log.warn;
|
||||
@ -128,15 +128,19 @@ export class Particle {
|
||||
return;
|
||||
}
|
||||
|
||||
fn(message, {
|
||||
id: this.id,
|
||||
init_peer_id: this.initPeerId,
|
||||
timestamp: this.timestamp,
|
||||
ttl: this.ttl,
|
||||
script: this.script,
|
||||
signature: this.signature,
|
||||
data: data,
|
||||
});
|
||||
fn(
|
||||
message,
|
||||
jsonify({
|
||||
id: this.id,
|
||||
init_peer_id: this.initPeerId,
|
||||
timestamp: this.timestamp,
|
||||
ttl: this.ttl,
|
||||
script: this.script,
|
||||
signature: this.signature,
|
||||
callResults: this.callResults,
|
||||
data: data,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { CallServiceResult } from '@fluencelabs/avm';
|
||||
import { CallServiceResult } from '@fluencelabs/avm-runner-interface';
|
||||
import { encode, decode } from 'bs58';
|
||||
import { PeerIdB58 } from 'src';
|
||||
import { GenericCallServiceHandler, ResultCodes } from './commonTypes';
|
||||
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { CallRequest, SecurityTetraplet } from '@fluencelabs/avm';
|
||||
import { SecurityTetraplet } from '@fluencelabs/avm-runner-interface';
|
||||
|
||||
/**
|
||||
* Peer ID's id as a base58 string (multihash/CIDv0).
|
||||
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { SecurityTetraplet } from '@fluencelabs/avm';
|
||||
import { SecurityTetraplet } from '@fluencelabs/avm-runner-interface';
|
||||
import { match } from 'ts-pattern';
|
||||
import { CallParams, Fluence, FluencePeer } from '../../index';
|
||||
import { CallServiceData, GenericCallServiceHandler, CallServiceResult, ResultCodes } from '../commonTypes';
|
||||
|
@ -14,35 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AirInterpreter, LogLevel as AvmLogLevel } from '@fluencelabs/avm';
|
||||
import log from 'loglevel';
|
||||
import { CallServiceData, CallServiceResult, CallServiceResultType, ResultCodes } from './commonTypes';
|
||||
import { AvmLoglevel, FluencePeer } from './FluencePeer';
|
||||
import { FluencePeer } from './FluencePeer';
|
||||
import { Particle, ParticleExecutionStage } from './Particle';
|
||||
|
||||
export const createInterpreter = (logLevel: AvmLoglevel): Promise<AirInterpreter> => {
|
||||
const logFn = (level: AvmLogLevel, msg: string) => {
|
||||
switch (level) {
|
||||
case 'error':
|
||||
log.error(msg);
|
||||
break;
|
||||
|
||||
case 'warn':
|
||||
log.warn(msg);
|
||||
break;
|
||||
|
||||
case 'info':
|
||||
log.info(msg);
|
||||
break;
|
||||
|
||||
case 'debug':
|
||||
case 'trace':
|
||||
log.log(msg);
|
||||
break;
|
||||
}
|
||||
};
|
||||
return AirInterpreter.create(logLevel, logFn);
|
||||
};
|
||||
import { LogLevel as AvmLoglevel } from '@fluencelabs/avm-runner-interface';
|
||||
|
||||
export const MakeServiceCall = (fn: (args: any[]) => CallServiceResultType) => {
|
||||
return (req: CallServiceData): CallServiceResult => {
|
||||
@ -156,5 +132,15 @@ export const checkConnection = async (peer: FluencePeer, ttl?: number): Promise<
|
||||
};
|
||||
|
||||
export function dataToString(data: Uint8Array) {
|
||||
return new TextDecoder().decode(Buffer.from(data));
|
||||
const text = new TextDecoder().decode(Buffer.from(data));
|
||||
// try to treat data as json and pretty-print it
|
||||
try {
|
||||
return JSON.stringify(JSON.parse(text), null, 4);
|
||||
} catch {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
export function jsonify(obj) {
|
||||
return JSON.stringify(obj, null, 4);
|
||||
}
|
||||
|
4
src/tools/copyAvmPublic.ts
Normal file
4
src/tools/copyAvmPublic.ts
Normal file
@ -0,0 +1,4 @@
|
||||
#! /usr/bin/env node
|
||||
|
||||
require('@fluencelabs/avm/dist/copyAvm');
|
||||
require('@fluencelabs/avm-runner-background/dist/copyRunnerScript');
|
Loading…
Reference in New Issue
Block a user