toString.SPEC.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /* Import modules. */
  2. const Nito = require('../..')
  3. describe('Wallet:tostring', () => {
  4. test('it should convert a (wallet) node object to a readable (cash address) string', () => {
  5. /* Initialize 3 private keys. */
  6. const privateKeys = [
  7. Nito.Crypto.PrivateKey('L15iUH4nhFUvkg2uBtkumMgDgkFxLbsUKpCAqFVrDjUKWAUXL12X'),
  8. Nito.Crypto.PrivateKey('KyVP38d1DebS7rTBKNrF1dNJsKpr7QH3DKyXir8J2TbW93ikmz8e'),
  9. Nito.Crypto.PrivateKey('L3pNciKh2g1witySvvbqixxzFYj7yFKGUtxGbBWcRADKghfhf3u5'),
  10. ]
  11. /* Map the public keys. */
  12. const mappedKeys = privateKeys.map(Nito.Crypto.PublicKey)
  13. /* Set required number of signatures. */
  14. const numSigs = 2
  15. /* Build parameters. */
  16. const params = {
  17. mappedKeys,
  18. numSigs,
  19. }
  20. /* Generate a node from 2-of-3 multisig. */
  21. const node = new Nito.Wallet(params)
  22. /* Initialize cash address. */
  23. const cashAddress = 'bitcoincash:ppty0g202tc5lk652y64m9z8kuhgthrnwvq6nh047x'
  24. /* Evaluate test. */
  25. expect(node.toString()).toEqual(cashAddress)
  26. })
  27. })