How to use the elliptic/lib/elliptic/utils.assert function in elliptic

To help you get started, we’ve selected a few elliptic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GridPlus / gridplus-sdk / test / btc-bcy.js View on Github external
client.addresses(req, (err, addresses) => {
      assert(err === null, err);
      assert(addresses.length === 2);
      assert(addresses[0].slice(0, 1) === 'B' || addresses[0].slice(0, 1) === 'C', 'Address 1 is not a BCY address');
      assert(addresses[1].slice(0, 1) === 'B' || addresses[1].slice(0, 1) === 'C', 'Address 2 is not a BCY address')
      deviceAddresses = addresses;
      // // Get the baseline balance for the addresses
      client.getBalance('BTC', { address: deviceAddresses }, (err) => {
        assert(err === null, err);
        done()
      });
    });
  });
github GridPlus / gridplus-sdk / test / btc-bcy.js View on Github external
client.addresses(req, (err, addresses) => {
      assert(err === null, err);
      assert(addresses.length === 2);
      assert(addresses[0].slice(0, 1) === 'B' || addresses[0].slice(0, 1) === 'C', 'Address 1 is not a BCY address');
      assert(addresses[1].slice(0, 1) === 'B' || addresses[1].slice(0, 1) === 'C', 'Address 2 is not a BCY address')
      deviceAddresses = addresses;
      // // Get the baseline balance for the addresses
      client.getBalance('BTC', { address: deviceAddresses }, (err) => {
        assert(err === null, err);
        done()
      });
    });
  });
github GridPlus / gridplus-sdk / test / btc-bcy.js View on Github external
client.addresses(req, (err, addresses) => {
      assert(err === null, err);
      assert(addresses.length === 2);
      assert(addresses[0].slice(0, 1) === 'B' || addresses[0].slice(0, 1) === 'C', 'Address 1 is not a BCY address');
      assert(addresses[1].slice(0, 1) === 'B' || addresses[1].slice(0, 1) === 'C', 'Address 2 is not a BCY address')
      deviceAddresses = addresses;
      // // Get the baseline balance for the addresses
      client.getBalance('BTC', { address: deviceAddresses }, (err) => {
        assert(err === null, err);
        done()
      });
    });
  });
github GridPlus / gridplus-sdk / test / btc-bcy.js View on Github external
client.getTxHistory('BTC', { addresses }, (err, txs) => {
      assert(err === null, err);
      assert(txs.length > 0);
      done();
    })
  })
github GridPlus / gridplus-sdk / test / btc-bcy.js View on Github external
client.getBalance('BTC', { address: holderAddress }, (err, data) => {
      assert.equal(err, null, err);
      assert(data.utxos.length > 0, `address (${holderAddress}) has not sent or received any bitcoins. Please request funds from the faucet (https://coinfaucet.eu/en/btc-testnet/) and try again.`);
      data.utxos.some((u) => {
        if (u.value >= 10000 && u.height > 0 && u.index !== undefined) {
          utxo = u;
          return true;
        }
      });
      assert(utxo !== undefined, `Unable to find an output with value >=10000 for address ${holderAddress}`);
      done();  
    });
  });
github GridPlus / gridplus-sdk / test / btc-bcy.js View on Github external
client.sign(req, (err, res) => {
      assert(err === null, err);
      setTimeout(() => {
        client.broadcast('BTC', res, (err2, txHash) => {
          assert(err2 === null, err2);
          let count = 0;
          const interval = setInterval(() => {
            client.getTx('BTC', txHash, (err, tx) => {
              if (count > 10) {
                assert.equal(err, null, err);      
                throw new Error('Transaction did not mine in time');
              } else if (tx.height > -1) {
                assert(tx.timestamp !== undefined);
                clearInterval(interval);
                done();
              } else {
                count += 1;
              }
github GridPlus / gridplus-sdk / test / btc-bcy.js View on Github external
client.connect(serial, (err, res) => {
      assert(err === null, err);
      assert(client.client.ecdhPub === res.key, 'Mismatched key on response')
      done()
    });
  });
github GridPlus / gridplus-sdk / test / btc-bcy.js View on Github external
client.getBalance('BTC', { address: a }, (err, data) => {
        if (count > 10) {
          assert.equal(err, null, err);      
          assert(data.utxos.length > 0, `Address (${a}) has not sent or received any bitcoins. Please request funds from the faucet (https://coinfaucet.eu/en/btc-testnet/) and try again.`);
          assert(data.utxos[0].height > 0 && data.utxos[0].index !== undefined, `Address (${a}) has a transaction, but it has not been confirmed. Please wait until it has`);
          done();
        } else if (data.utxos.length > 0 && data.utxos[0].height > 0) {
          clearInterval(interval);
          done();
        } else {
          count += 1;
        }
      });
    }, 10000);
github GridPlus / gridplus-sdk / test / btc-bcy.js View on Github external
client.getTxHistory('BTC', { addresses: holderAddress }, (err, txs) => {
      assert(err === null, err);
      assert(txs.length > 0, 'btcHolder address should have more than one transaction in history');      
      done();     
    })
  })
github GridPlus / gridplus-sdk / test / btc-bcy.js View on Github external
client.broadcast('BTC', res, (err2, txHash) => {
          assert(err2 === null, err2);
          let count = 0;
          const interval = setInterval(() => {
            client.getTx('BTC', txHash, (err, tx) => {
              if (count > 10) {
                assert.equal(err, null, err);      
                throw new Error('Transaction did not mine in time');
              } else if (tx && tx.height > -1) {
                const o1 = tx.data.outputs[0].addresses[0];
                if (o1 !== recipient) throw new Error(`Recipient did not receive output. Sent to ${o1}, but expected ${recipient}`);
                const v1 = tx.data.outputs[0].value;
                if (v1 !== req.params.value) throw new Error(`Output value incorrect. Sent ${v1}, but expected ${req.params.value}`);
                const o2 = tx.data.outputs[1].addresses[0];
                const expectedO2 = deviceAddresses[req.params.changeAccountIndex]
                if (o2 !== expectedO2) throw new Error(`Change did not go to correct address. Sent to ${o2} but expected ${expectedO2}`);
                clearInterval(interval);
                done();