Repository: oasisprotocol/oasis-sdk
Pull request #55 (2021-03-22 21:59:33)

ts-web/core: use client node for playground grpc
depends #54 

This seems to need a little something more, with our test hanging when directed at the client node instead of the validator

codecov[bot]: # [Codecov](https://codecov.io/gh/oasisprotocol/oasis-sdk/pull/55?src=pr&el=h1) Report
> Merging [#55](https://codecov.io/gh/oasisprotocol/oasis-sdk/pull/55?src=pr&el=desc) (acb7868) into [main](https://codecov.io/gh/oasisprotocol/oasis-sdk/commit/fdda3859da1fde8b8b9aab28ec9d3e55315f62c9?el=desc) (fdda385) will **not change** coverage.
> The diff coverage is `n/a`.

> :exclamation: Current head acb7868 differs from pull request most recent head 1f8fbc9. Consider uploading reports for the commit 1f8fbc9 to get more accurate results
[![Impacted file tree graph](https://codecov.io/gh/oasisprotocol/oasis-sdk/pull/55/graphs/tree.svg?width=650&height=150&src=pr&token=uscfoYjSZn)](https://codecov.io/gh/oasisprotocol/oasis-sdk/pull/55?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##             main      #55   +/-   ##
=======================================
  Coverage   56.14%   56.14%           
=======================================
  Files          24       24           
  Lines        1122     1122           
=======================================
  Hits          630      630           
  Misses        492      492           
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/oasisprotocol/oasis-sdk/pull/55?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/oasisprotocol/oasis-sdk/pull/55?src=pr&el=footer). Last update [fdda385...1f8fbc9](https://codecov.io/gh/oasisprotocol/oasis-sdk/pull/55?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

pro-wh: it works locally, but admittedly I don't start the test as fast as CI does. maybe there's something else we need to wait for
pro-wh: I tried launching it fast manually, and the test fails with `consensus: no committed blocks`. Maybe we can add a step to wait for the first block
pro-wh: after some more experimentation, I've found that it takes ~30 seconds on my computer for client-0 to connect to the testnet. maybe it's taking longer on CI, where there's a 60 second timeout

Patch:
diff --git a/client-sdk/ts-web/core/playground/sample-envoy.yaml b/client-sdk/ts-web/core/playground/sample-envoy.yaml
index 8583668a2a..62aac6e0e6 100644
--- a/client-sdk/ts-web/core/playground/sample-envoy.yaml
+++ b/client-sdk/ts-web/core/playground/sample-envoy.yaml
@@ -21,7 +21,7 @@ static_resources:
                   safe_regex:
                     google_re2:
                       max_program_size: 1000000
-                    regex: '/oasis-core\.(Registry/(GetNodes)|Staking/(Account|DelegationsTo|GetEvents)|Consensus/(SubmitTx|EstimateGas|GetBlock|GetTransactionsWithResults|GetGenesisDocument|WatchBlocks))'
+                    regex: '/oasis-core\.(Registry/(GetNodes)|Staking/(Account|DelegationsTo|GetEvents)|Consensus/(SubmitTx|EstimateGas|GetBlock|GetTransactionsWithResults|GetGenesisDocument|WatchBlocks)|NodeController/(WaitReady))'
                 route:
                   cluster: oasis_node_grpc
                   timeout: 0s
@@ -56,7 +56,7 @@ static_resources:
         - endpoint:
             address:
               pipe:
-                path: /tmp/oasis-net-runner-sdk-core/net-runner/network/validator-0/internal.sock
+                path: /tmp/oasis-net-runner-sdk-core/net-runner/network/client-0/internal.sock
     http2_protocol_options: {}
   - name: dev_static
     connect_timeout: 0.25s
diff --git a/client-sdk/ts-web/core/playground/src/index.js b/client-sdk/ts-web/core/playground/src/index.js
index 905d2b9c43..f6f7035299 100644
--- a/client-sdk/ts-web/core/playground/src/index.js
+++ b/client-sdk/ts-web/core/playground/src/index.js
@@ -7,6 +7,15 @@ const nic = new oasis.client.NodeInternal('http://localhost:42280');
 
 (async function () {
     try {
+        // Wait for ready.
+        {
+            console.log('waiting for node to be ready');
+            const waitStart = Date.now();
+            await nic.nodeControllerWaitReady();
+            const waitEnd = Date.now();
+            console.log(`ready ${waitEnd - waitStart} ms`);
+        }
+
         // Get something with addresses.
         {
             console.log('nodes', await nic.registryGetNodes(oasis.consensus.HEIGHT_LATEST));


Test patch:
diff --git a/.github/workflows/ci-test.yaml b/.github/workflows/ci-test.yaml
index 8df02e0def..46c0a5c45a 100644
--- a/.github/workflows/ci-test.yaml
+++ b/.github/workflows/ci-test.yaml
@@ -139,7 +139,7 @@ jobs:
 
       - name: 'testnet: Wait for node socket'
         run: |
-          while [ ! -e /tmp/oasis-net-runner-sdk-core/net-runner/network/validator-0/internal.sock ]; do
+          while [ ! -e /tmp/oasis-net-runner-sdk-core/net-runner/network/client-0/internal.sock ]; do
             sleep 1
           done