Skip to content

Feat/ethan/getcurrencyinfo#167

Open
christroutner wants to merge 6 commits intomasterfrom
feat/ethan/getcurrencyinfo
Open

Feat/ethan/getcurrencyinfo#167
christroutner wants to merge 6 commits intomasterfrom
feat/ethan/getcurrencyinfo

Conversation

@christroutner
Copy link
Contributor

This PR continues from this PR
#166

@christroutner
Copy link
Contributor Author

For reference, here is the getcurrencyinfo RPC call this endpoint exercises.

In order to merge the PR into the master branch, I'd like to see the following additions:

  • Move the code from the util.js library to the price.js library. This is more appropriate since this endpoint has to do with calculations of price relative to the satoshi base unit.
  • Add unit tests to the test/v5/ folder.
  • Add integration tests to the test/v5/integration folder

The v4 route can be ignored as that will be deprecated and deleted in the few months.

@ethanmackie
Copy link

  • Removed v4 endpoint per feedback
  • Moved v5 endpoint from util.js to price.js
  • Added unit tests to test/v5/
  • Added integration tests to test/v5/integration

@christroutner
Copy link
Contributor Author

christroutner commented Nov 11, 2021

All unit tests pass, which is good. But when those tests are run against live eCash infrastructure (full node, Fulcrum indexer, & SLPDB), I get the following errors. I suspect the issue may be with the use of nock. I think it might be messing up the network connections of downstream tests.

I've been trying to phase out the use of nock, in favor of mocking using sinon.stub(). Nock is an artifact left over before unit tests using sinon became the norm.

I'm also getting the same errors against BCH infrastructure too. Since bch-api is used for both blockchains, integration tests for both need to pass.

413 passing (45s)
  2 pending
  19 failing

  1) #PriceRouter
       #getCurrencyInfo
         should get the currency settings of the full node:

      AssertionError: expected { Object (error) } to have keys 'ticker', 'satoshisperunit', and 'decimals'
      + expected - actual

       [
      -  "error"
      +  "decimals"
      +  "satoshisperunit"
      +  "ticker"
       ]
      
      at Context.<anonymous> (test/v5/price.js:382:14)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)

  2) #Raw-Transactions
       decodeRawTransactionSingle()
         should GET /decodeRawTransaction:

      AssertionError: expected { Object (error) } to have keys 'txid', 'hash', 'size', 'version', 'locktime', 'vin', or 'vout'
      + expected - actual

       [
      -  "error"
      +  "hash"
      +  "locktime"
      +  "size"
      +  "txid"
      +  "version"
      +  "vin"
      +  "vout"
       ]
      
      at Context.<anonymous> (test/v5/raw-transactions.js:194:14)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)

  3) #Raw-Transactions
       decodeRawTransactionBulk()
         should decode an array with a single hex:
     AssertionError: expected { Object (error) } to be an array
      at Context.<anonymous> (test/v5/raw-transactions.js:305:14)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)

  4) #Raw-Transactions
       decodeRawTransactionBulk()
         should decode an array with multiple hexes:
     AssertionError: expected { Object (error) } to be an array
      at Context.<anonymous> (test/v5/raw-transactions.js:335:14)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)

  5) #Raw-Transactions
       decodeScriptSingle()
         should GET /decodeScriptSingle:

      AssertionError: expected { Object (error) } to have keys 'asm', 'type', and 'p2sh'
      + expected - actual

       [
      -  "error"
      +  "asm"
      +  "p2sh"
      +  "type"
       ]
      
      at Context.<anonymous> (test/v5/raw-transactions.js:447:14)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)

  6) #Raw-Transactions
       decodeScriptBulk()
         should decode an array with a single hex:
     AssertionError: expected { Object (error) } to be an array
      at Context.<anonymous> (test/v5/raw-transactions.js:565:14)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)

  7) #Raw-Transactions
       decodeScriptBulk()
         should decode an array with a multiple hexes:
     AssertionError: expected { Object (error) } to be an array
      at Context.<anonymous> (test/v5/raw-transactions.js:585:14)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)

  8) #Raw-Transactions
       getRawTransactionBulk()
         should get concise transaction data:
     AssertionError: expected { Object (error) } to be an array
      at Context.<anonymous> (test/v5/raw-transactions.js:708:14)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)

  9) #Raw-Transactions
       getRawTransactionBulk()
         should get verbose transaction data:
     AssertionError: expected { Object (error) } to be an array
      at Context.<anonymous> (test/v5/raw-transactions.js:728:14)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)

  10) #Raw-Transactions
       getRawTransactionSingle()
         should get concise transaction data:
     AssertionError: expected { Object (error) } to be a string
      at Context.<anonymous> (test/v5/raw-transactions.js:840:14)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)

  11) #Raw-Transactions
       getRawTransactionSingle()
         should get verbose transaction data:

      AssertionError: expected { Object (error) } to have keys 'hex', 'txid', 'hash', 'size', 'version', 'locktime', 'vin', 'vout', 'blockhash', 'confirmations', 'time', or 'blocktime'
      + expected - actual

       [
      -  "error"
      +  "blockhash"
      +  "blocktime"
      +  "confirmations"
      +  "hash"
      +  "hex"
      +  "locktime"
      +  "size"
      +  "time"
      +  "txid"
      +  "version"
      +  "vin"
      +  "vout"
       ]
      
      at Context.<anonymous> (test/v5/raw-transactions.js:858:14)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)

  12) #Raw-Transactions
       sendRawTransactionBulk()
         should throw 400 error if hex is invalid:

      HTTP status code 400 expected.
      + expected - actual

      -503
      +400
      
      at Context.<anonymous> (test/v5/raw-transactions.js:925:14)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)

  13) #Raw-Transactions
       sendRawTransactionBulk()
         should submit hex encoded transaction:
     AssertionError: expected 'Network error: Could not communicate with full node or other external service.' to include 'bad-txns-inputs-missingorspent'
      at Context.<anonymous> (test/v5/raw-transactions.js:1013:18)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)

  14) #Raw-Transactions
       sendRawTransactionSingle()
         should throw an error for invalid hex:

      HTTP status code 400 expected.
      + expected - actual

      -503
      +400
      
      at Context.<anonymous> (test/v5/raw-transactions.js:1090:14)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)

  15) #Raw-Transactions
       sendRawTransactionSingle()
         should GET /sendRawTransaction/:hex:
     AssertionError: expected 'Network error: Could not communicate with full node or other external service.' to include 'bad-txns-inputs-missingorspent'
      at Context.<anonymous> (test/v5/raw-transactions.js:1176:18)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)

  16) #SLP
       txDetails()
         should get tx details with token info:

      AssertionError: expected { Object (error) } to have keys 'tokenIsValid', or 'tokenInfo'
      + expected - actual

       [
      -  "error"
      +  "tokenInfo"
      +  "tokenIsValid"
       ]
      
      at Context.<anonymous> (test/v5/slp.js:1166:16)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)

  17) #Util
       #validateAddressSingle
         should validate address:

      AssertionError: expected { Object (error) } to have keys 'isvalid', 'address', 'scriptPubKey', 'ismine', 'iswatchonly', or 'isscript'
      + expected - actual

       [
      -  "error"
      +  "address"
      +  "ismine"
      +  "isscript"
      +  "isvalid"
      +  "iswatchonly"
      +  "scriptPubKey"
       ]
      
      at Context.<anonymous> (test/v5/util.js:164:14)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)

  18) #Util
       #validateAddressBulk
         should validate a single address:
     AssertionError: expected { Object (error) } to be an array
      at Context.<anonymous> (test/v5/util.js:286:14)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)

  19) #Util
       #validateAddressBulk
         should validate a multiple addresses:
     AssertionError: expected { Object (error) } to be an array
      at Context.<anonymous> (test/v5/util.js:314:14)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)


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

Successfully merging this pull request may close these issues.

2 participants