Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Case: should understand transitive conditions #46

Open
coolaj86 opened this issue Apr 18, 2023 · 0 comments
Open

Test Case: should understand transitive conditions #46

coolaj86 opened this issue Apr 18, 2023 · 0 comments

Comments

@coolaj86
Copy link
Collaborator

If we assign one variable to another and test the new variables properties, we should know that the same applies to the previous variable:

    /**
     * @param {Object} opts
     * @param {Array<CoreUtxo>?} [opts.inputs]
     * @param {Number} [opts.satoshis]
     * @param {Number} [opts.now] - ms
     */
    function mustSelectInputs({ inputs, satoshis, now = Date.now() }) {
      if (inputs) {
        return inputs;
      }

      let fullTransfer = !satoshis;   <=== satoshis is assigned to fullTransfer, which is tested for truthy-ness
      if (fullTransfer) {
        let msg = `'satoshis' must be a positive number unless 'inputs' are specified`;
        let err = new Error(msg);
        throw err;
      }

      let coins = wallet.utxos();
      inputs = DashApi.selectOptimalUtxos(coins, satoshis);   <=== should know that satoshis is NOT undefined

      if (!inputs.length) {
        throw createInsufficientFundsError(coins, satoshis);
      }

      return inputs;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant