hyperledger / iroha-javascript

JavaScript library for Iroha, a Distributed Ledger Technology (blockchain) platform.
https://wiki.hyperledger.org/display/iroha
Apache License 2.0
94 stars 64 forks source link

Add a check that block height is >= 1 #178

Closed mversic closed 7 months ago

mversic commented 10 months ago
const getBlocksListener = async () => {
    const stream = await Torii.listenForBlocksStream(pre, {
      // 1 is genesis block, which is committed before each test
      height: 0n,
    });

    return {
      /**
       * Do an operation that should trigger a block commit,
       * and wait until the block is emitted
       */

      awaitBlockCommit: async (fn) => {
        await Promise.all([stream.ee.once('block'), fn()]);
      },
    };
  };

  await blocks.awaitBlockCommit(async () => {
      await client.submitExecutable(pre, exec);
    });

This code results in a cryptic error message:

iroha::torii::routing: Failed to subscribe to blocks stream error=Error during versioned message decoding 

This happens because the code uses 0 instead of 1 to get the genesis block. Inside listenForBlocksStream we should check that the given height is in bounds before sending the request to the node

Sayalikukkar commented 7 months ago

Hi @mversic , Can I look into this