Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

channelchanges-test.js 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. 'use strict'
  2. var assert = require('assert-diff')
  3. var parseChannelChanges = require('../src/index').parseChannelChanges
  4. describe('parseChannelChanges', function() {
  5. it('parses PayChannel metadata', function() {
  6. var metadata = {
  7. 'AffectedNodes': [
  8. {
  9. 'ModifiedNode': {
  10. 'FinalFields': {
  11. 'Account': 'rJNa71cLCjzQG68oNjh4fCUqCZSGNkWDrM',
  12. 'Balance': '512724201',
  13. 'Flags': 0,
  14. 'OwnerCount': 98,
  15. 'Sequence': 24166
  16. },
  17. 'LedgerEntryType': 'AccountRoot',
  18. 'LedgerIndex': 'D16BF3F23AFB01CA5AC7860F9AF8037117972D5A389DDFDBB5A1064742B154D8',
  19. 'PreviousFields': {
  20. 'Balance': '512714213',
  21. 'Sequence': 24165
  22. },
  23. 'PreviousTxnID': '9345E3B3578F8F6C8DC55F7B39F7C48F9E79E7BD2A77ADE2714D5910C501980F',
  24. 'PreviousTxnLgrSeq': 39792515
  25. }
  26. },
  27. {
  28. 'ModifiedNode': {
  29. 'FinalFields': {
  30. 'Account': 'rpyC4JM5kifsNG6YbARDAxAJQLBDZw9ZFQ',
  31. 'Amount': '10000000',
  32. 'Balance': '40000',
  33. 'Destination': 'rJNa71cLCjzQG68oNjh4fCUqCZSGNkWDrM',
  34. 'Flags': 0,
  35. 'OwnerNode': '0000000000000000',
  36. 'PublicKey': 'ED4DB1CE76AB25FAACE3E13BF57EA7767614FB52A250E1D04426A28B383A31A652',
  37. 'SettleDelay': 3600,
  38. 'SourceTag': 3382712545
  39. },
  40. 'LedgerEntryType': 'PayChannel',
  41. 'LedgerIndex': 'EC4DACE3360DCBF76FE80874931F2C75C5B4B6A05D615FA3E62DFF2BE34A8ACB',
  42. 'PreviousFields': {
  43. 'Balance': '30000'
  44. },
  45. 'PreviousTxnID': '5E854E78A51C45FC626C61924C20EA25670EF18E5609DA5F1F7898E833DCB257',
  46. 'PreviousTxnLgrSeq': 39749577
  47. }
  48. }
  49. ],
  50. 'TransactionIndex': 24,
  51. 'TransactionResult': 'tesSUCCESS'
  52. }
  53. var result = parseChannelChanges(metadata)
  54. var expectedResult = {
  55. status: 'modified',
  56. channelId: 'EC4DACE3360DCBF76FE80874931F2C75C5B4B6A05D615FA3E62DFF2BE34A8ACB',
  57. source: 'rpyC4JM5kifsNG6YbARDAxAJQLBDZw9ZFQ',
  58. destination: 'rJNa71cLCjzQG68oNjh4fCUqCZSGNkWDrM',
  59. channelBalanceChangeDrops: '10000',
  60. channelAmountDrops: '10000000',
  61. channelBalanceDrops: '40000',
  62. previousTxnId: '5E854E78A51C45FC626C61924C20EA25670EF18E5609DA5F1F7898E833DCB257'
  63. }
  64. assert.deepEqual(result, expectedResult)
  65. })
  66. })